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 toV3() function branches
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Feb 9, 2018
1 parent 6845499 commit bc5fba0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,23 @@ describe('.toV3()', function () {
var uuid = Buffer.from('7e59dc028d42d09db29aa8a0f862cc81', 'hex')

it('should work with PBKDF2', function () {
var key = Buffer.from(fixturePrivKey, 'hex')
var wallet = Wallet.fromPrivateKey(key)
var w = '{"version":3,"id":"7e59dc02-8d42-409d-b29a-a8a0f862cc81","address":"b14ab53e38da1c172f877dbc6d65e4a1b0474c3c","crypto":{"ciphertext":"01ee7f1a3c8d187ea244c92eea9e332ab0bb2b4c902d89bdd71f80dc384da1be","cipherparams":{"iv":"cecacd85e9cb89788b5aab2f93361233"},"cipher":"aes-128-ctr","kdf":"pbkdf2","kdfparams":{"dklen":32,"salt":"dc9e4a98886738bd8aae134a1f89aaa5a502c3fbd10e336136d4d5fe47448ad6","c":262144,"prf":"hmac-sha256"},"mac":"0c02cd0badfebd5e783e0cf41448f84086a96365fc3456716c33641a86ebc7cc"}}'
// FIXME: just test for ciphertext and mac?
assert.equal(wallet.toV3String('testtest', { kdf: 'pbkdf2', uuid: uuid, salt: salt, iv: iv }), w)
assert.equal(fixtureWallet.toV3String('testtest', { kdf: 'pbkdf2', uuid: uuid, salt: salt, iv: iv }), w)
})
it('should work with Scrypt', function () {
var key = Buffer.from(fixturePrivKey, 'hex')
var wallet = Wallet.fromPrivateKey(key)
var w = '{"version":3,"id":"7e59dc02-8d42-409d-b29a-a8a0f862cc81","address":"b14ab53e38da1c172f877dbc6d65e4a1b0474c3c","crypto":{"ciphertext":"c52682025b1e5d5c06b816791921dbf439afe7a053abb9fac19f38a57499652c","cipherparams":{"iv":"cecacd85e9cb89788b5aab2f93361233"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"dc9e4a98886738bd8aae134a1f89aaa5a502c3fbd10e336136d4d5fe47448ad6","n":262144,"r":8,"p":1},"mac":"27b98c8676dc6619d077453b38db645a4c7c17a3e686ee5adaf53c11ac1b890e"}}'
this.timeout(180000) // 3minutes
// FIXME: just test for ciphertext and mac?
assert.equal(wallet.toV3String('testtest', { kdf: 'scrypt', uuid: uuid, salt: salt, iv: iv }), w)
assert.equal(fixtureWallet.toV3String('testtest', { kdf: 'scrypt', uuid: uuid, salt: salt, iv: iv }), w)
})
it('should work without providing options', function() {
assert.equal(fixtureWallet.toV3('testtest')['version'], 3)
})
it('should fail for unsupported kdf', function () {
assert.throws(function () {
fixtureWallet.toV3('testtest', { kdf: 'superkey' })
}, /^Error: Unsupported kdf$/)
})
})

Expand Down

0 comments on commit bc5fba0

Please sign in to comment.