Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Added tests covering fromV3() function branches
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Feb 14, 2018
1 parent bc5fba0 commit 9b26e23
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ describe('.generate()', function () {

describe('.generateVanityAddress()', function () {
it('should generate an account with 000 prefix (object)', function () {
this.timeout(180000) // 3minutes
var wallet = Wallet.generateVanityAddress(/^000/)
assert.equal(wallet.getPrivateKey().length, 32)
assert.equal(wallet.getAddress()[0], 0)
assert.equal(wallet.getAddress()[1] >>> 4, 0)
})
it('should generate an account with 000 prefix (string)', function () {
this.timeout(180000) // 3minutes
var wallet = Wallet.generateVanityAddress('^000')
assert.equal(wallet.getPrivateKey().length, 32)
assert.equal(wallet.getAddress()[0], 0)
Expand Down Expand Up @@ -155,10 +157,12 @@ describe('.toV3()', function () {
// FIXME: just test for ciphertext and mac?
assert.equal(fixtureWallet.toV3String('testtest', { kdf: 'scrypt', uuid: uuid, salt: salt, iv: iv }), w)
})
it('should work without providing options', function() {
it('should work without providing options', function () {
this.timeout(180000) // 3minutes
assert.equal(fixtureWallet.toV3('testtest')['version'], 3)
})
it('should fail for unsupported kdf', function () {
this.timeout(180000) // 3minutes
assert.throws(function () {
fixtureWallet.toV3('testtest', { kdf: 'superkey' })
}, /^Error: Unsupported kdf$/)
Expand Down Expand Up @@ -204,6 +208,18 @@ describe('.fromV3()', function () {
Wallet.fromV3(w, 'testpassword')
}) // FIXME: check for assert message(s)
})
it('should fail for wrong version', function () {
var w = '{"version":2}'
assert.throws(function () {
Wallet.fromV3(w, 'testpassword')
}, /^Error: Not a V3 wallet$/)
})
it('should fail for wrong kdf', function () {
var w = '{"Crypto":{"kdf":"superkey"},"version":3}'
assert.throws(function () {
Wallet.fromV3(w, 'testpassword', true)
}, /^Error: Unsupported key derivation scheme$/)
})
})

describe('.fromEthSale()', function () {
Expand Down

0 comments on commit 9b26e23

Please sign in to comment.