@@ -145,19 +145,23 @@ describe('.toV3()', function () {
145
145
var uuid = Buffer . from ( '7e59dc028d42d09db29aa8a0f862cc81' , 'hex' )
146
146
147
147
it ( 'should work with PBKDF2' , function ( ) {
148
- var key = Buffer . from ( fixturePrivateKey , 'hex' )
149
- var wallet = Wallet . fromPrivateKey ( key )
150
148
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"}}'
151
149
// FIXME: just test for ciphertext and mac?
152
- assert . equal ( wallet . toV3String ( 'testtest' , { kdf : 'pbkdf2' , uuid : uuid , salt : salt , iv : iv } ) , w )
150
+ assert . equal ( fixtureWallet . toV3String ( 'testtest' , { kdf : 'pbkdf2' , uuid : uuid , salt : salt , iv : iv } ) , w )
153
151
} )
154
152
it ( 'should work with Scrypt' , function ( ) {
155
- var key = Buffer . from ( fixturePrivateKey , 'hex' )
156
- var wallet = Wallet . fromPrivateKey ( key )
157
153
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"}}'
158
154
this . timeout ( 180000 ) // 3minutes
159
155
// FIXME: just test for ciphertext and mac?
160
- assert . equal ( wallet . toV3String ( 'testtest' , { kdf : 'scrypt' , uuid : uuid , salt : salt , iv : iv } ) , w )
156
+ assert . equal ( fixtureWallet . toV3String ( 'testtest' , { kdf : 'scrypt' , uuid : uuid , salt : salt , iv : iv } ) , w )
157
+ } )
158
+ it ( 'should work without providing options' , function ( ) {
159
+ assert . equal ( fixtureWallet . toV3 ( 'testtest' ) [ 'version' ] , 3 )
160
+ } )
161
+ it ( 'should fail for unsupported kdf' , function ( ) {
162
+ assert . throws ( function ( ) {
163
+ fixtureWallet . toV3 ( 'testtest' , { kdf : 'superkey' } )
164
+ } , / ^ E r r o r : U n s u p p o r t e d k d f $ / )
161
165
} )
162
166
} )
163
167
0 commit comments