Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build
on:
push:
branches:
- master
tags:
- '*'
pull_request:
types: [opened, reopened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 13.x, 14.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: actions/checkout@v1

- run: npm install
- run: npm run test

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

test-browser:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: actions/checkout@v1

- run: npm install
- run: npm run test:browser

28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ethereumjs-wallet

[![NPM Package](https://img.shields.io/npm/v/ethereumjs-wallet.svg?style=flat-square)](https://www.npmjs.org/package/ethereumjs-wallet)
[![Build Status](https://travis-ci.org/ethereumjs/ethereumjs-wallet.svg?branch=master)](https://travis-ci.org/ethereumjs/ethereumjs-wallet)
[![Actions Status](https://github.com/ethereumjs/ethereumjs-wallet/workflows/Build/badge.svg)](https://github.com/ethereumjs/ethereumjs-wallet/actions)
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethereumjs-wallet.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethereumjs-wallet)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode

Expand Down
27 changes: 27 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'karma-typescript'],
files: ['src/**/*.ts', 'test/**/*.ts'],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
plugins: ['karma-mocha', 'karma-typescript', 'karma-chrome-launcher', 'karma-firefox-launcher'],
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
acornOptions: {
ecmaVersion: 8,
},
transforms: [require('karma-typescript-es6-transform')()],
},
},
colors: true,
reporters: ['progress', 'karma-typescript'],
browsers: ['FirefoxHeadless', 'ChromeHeadless'],
singleRun: true,
concurrency: Infinity,
// Extend timeouts for long tests
browserDisconnectTimeout: 1000000,
browserNoActivityTimeout: 1000000,
})
}
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
"prepublishOnly": "npm run format && npm run tslint && npm run test",
"docs:build": "typedoc --out docs --mode file --readme none --theme markdown --mdEngine github --excludeNotExported src",
"coverage": "ethereumjs-config-coverage",
"coveralls": "ethereumjs-config-coveralls",
"format": "ethereumjs-config-format",
"format:fix": "ethereumjs-config-format-fix",
"lint": "ethereumjs-config-lint",
"lint:fix": "ethereumjs-config-lint-fix",
"pretest": "npm run build",
"test": "nyc mocha ./test/**/*.ts",
"test": "npm run build && nyc --reporter=lcov mocha ./test/**/*.ts",
"test:browser": "karma start karma.conf.js",
"tsc": "ethereumjs-config-tsc",
"tslint": "ethereumjs-config-tslint",
"tslint:fix": "ethereumjs-config-tslint-fix"
Expand Down Expand Up @@ -62,19 +61,24 @@
"@types/lodash.zip": "^4.2.6",
"@types/mocha": "^5.2.7",
"@types/node": "^12.0.10",
"coveralls": "^3.0.0",
"ethers": "^4.0.33",
"husky": "^2.1.0",
"karma": "^5.0.2",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^2.0.0",
"karma-typescript": "^4.1.1",
"karma-typescript-es6-transform": "^5.0.2",
"lodash.zip": "^4.2.0",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"mocha": "^7.1.2",
"nyc": "^15.0.1",
"prettier": "^1.15.3",
"source-map-support": "^0.5.12",
"ts-node": "^8.3.0",
"ts-node": "^8.9.1",
"tslint": "^5.12.0",
"typescript": "^3.2.2",
"typestrict": "^1.0.2",
"typedoc": "^0.14.2",
"typedoc-plugin-markdown": "^1.2.0"
"typedoc-plugin-markdown": "^1.2.0",
"typescript": "^3.8.3",
"typestrict": "^1.0.2"
}
}
File renamed without changes.
18 changes: 16 additions & 2 deletions test/index.ts → test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const fixturePublicKeyBuffer = Buffer.from(fixturePublicKey, 'hex')
const fixtureWallet = Wallet.fromPrivateKey(fixturePrivateKeyBuffer)
const fixtureEthersWallet = new ethersWallet(fixtureWallet.getPrivateKeyString())

const isRunningInKarma = () => {
return typeof (global as any).window !== 'undefined' && (global as any).window.__karma__
}

describe('.getPrivateKey()', function() {
it('should work', function() {
assert.strictEqual(fixtureWallet.getPrivateKey().toString('hex'), fixturePrivateKey)
Expand Down Expand Up @@ -212,7 +216,7 @@ describe('.toV3()', function() {
const makePermutations = (...objs: Array<object>): Array<object> => {
const permus = []
const keys = Array.from(
objs.reduce((acc: Set<string>, curr: object) => {
objs.reduce((acc: any, curr: object) => {
Object.keys(curr).forEach(key => {
acc.add(key)
})
Expand Down Expand Up @@ -246,7 +250,13 @@ describe('.toV3()', function() {
return obj
}

const permutations = makePermutations(strKdfOptions, buffKdfOptions)
let permutations = makePermutations(strKdfOptions, buffKdfOptions)

if (isRunningInKarma()) {
// These tests take a long time in the browser due to
// the amount of permutations so we will shorten them.
permutations = permutations.slice(1)
}

it('should work with PBKDF2', async function() {
this.timeout(0) // never
Expand Down Expand Up @@ -669,19 +679,22 @@ describe('.fromV3()', function() {
it('should fail with invalid password', function() {
const w =
'{"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"6087dab2f9fdbbfaddc31a909735c1e6"},"ciphertext":"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"},"mac":"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"},"id":"3198bc9c-6672-5ab3-d995-4942343ae5b6","version":3}'
this.timeout(0) // never
assert.throws(function() {
Wallet.fromV3(w, 'wrongtestpassword')
}, /^Error: Key derivation failed - possibly wrong passphrase$/)
})
it('should work with (broken) mixed-case input files', function() {
const w =
'{"Crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"6087dab2f9fdbbfaddc31a909735c1e6"},"ciphertext":"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"},"mac":"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"},"id":"3198bc9c-6672-5ab3-d995-4942343ae5b6","version":3}'
this.timeout(0) // never
const wallet = Wallet.fromV3(w, 'testpassword', true)
assert.strictEqual(wallet.getAddressString(), '0x008aeeda4d805471df9b2a5b0f38a0c3bcba786b')
})
it("shouldn't work with (broken) mixed-case input files in strict mode", function() {
const w =
'{"Crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"6087dab2f9fdbbfaddc31a909735c1e6"},"ciphertext":"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"},"mac":"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"},"id":"3198bc9c-6672-5ab3-d995-4942343ae5b6","version":3}'
this.timeout(0) // never
assert.throws(function() {
Wallet.fromV3(w, 'testpassword')
}) // FIXME: check for assert message(s)
Expand Down Expand Up @@ -760,6 +773,7 @@ describe('.fromKryptoKit()', function() {
'qhah1VeT0RgTvff1UKrUrxtFViiQuki16dd353d59888c25',
'testtest',
)
this.timeout(0) // never
assert.strictEqual(wallet.getAddressString(), '0x3c753e27834db67329d1ec1fab67970ec1e27112')
})
})
Expand Down