@@ -4,12 +4,19 @@ var Wallet = require('../')
4
4
var Thirdparty = require ( '../thirdparty.js' )
5
5
var ethUtil = require ( 'ethereumjs-util' )
6
6
7
- var fixturekey = Buffer . from ( 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378' , 'hex' )
8
- var fixturewallet = Wallet . fromPrivateKey ( fixturekey )
7
+ var fixturePrivateKey = 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378'
8
+ var fixturePrivateKeyStr = '0x' + fixturePrivateKey
9
+ var fixturePrivateKeyBuffer = Buffer . from ( fixturePrivateKey , 'hex' )
10
+
11
+ var fixturePublicKey = '5d4392f450262b276652c1fc037606abac500f3160830ce9df53aa70d95ce7cfb8b06010b2f3691c78c65c21eb4cf3dfdbfc0745d89b664ee10435bb3a0f906c'
12
+ var fixturePublicKeyStr = '0x' + fixturePublicKey
13
+ var fixturePublicKeyBuffer = Buffer . from ( fixturePublicKey , 'hex' )
14
+
15
+ var fixtureWallet = Wallet . fromPrivateKey ( fixturePrivateKeyBuffer )
9
16
10
17
describe ( '.getPrivateKey()' , function ( ) {
11
18
it ( 'should work' , function ( ) {
12
- assert . equal ( fixturewallet . getPrivateKey ( ) . toString ( 'hex' ) , 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378' )
19
+ assert . equal ( fixtureWallet . getPrivateKey ( ) . toString ( 'hex' ) , fixturePrivateKey )
13
20
} )
14
21
it ( 'should fail' , function ( ) {
15
22
assert . throws ( function ( ) {
@@ -20,45 +27,45 @@ describe('.getPrivateKey()', function () {
20
27
21
28
describe ( '.getPrivateKeyString()' , function ( ) {
22
29
it ( 'should work' , function ( ) {
23
- assert . equal ( fixturewallet . getPrivateKeyString ( ) , '0xefca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378' )
30
+ assert . equal ( fixtureWallet . getPrivateKeyString ( ) , fixturePrivateKeyStr )
24
31
} )
25
32
} )
26
33
27
34
describe ( '.getPublicKey()' , function ( ) {
28
35
it ( 'should work' , function ( ) {
29
- assert . equal ( fixturewallet . getPublicKey ( ) . toString ( 'hex' ) , '5d4392f450262b276652c1fc037606abac500f3160830ce9df53aa70d95ce7cfb8b06010b2f3691c78c65c21eb4cf3dfdbfc0745d89b664ee10435bb3a0f906c' )
36
+ assert . equal ( fixtureWallet . getPublicKey ( ) . toString ( 'hex' ) , fixturePublicKey )
30
37
} )
31
38
} )
32
39
33
40
describe ( '.getPublicKeyString()' , function ( ) {
34
41
it ( 'should work' , function ( ) {
35
- assert . equal ( fixturewallet . getPublicKeyString ( ) , '0x5d4392f450262b276652c1fc037606abac500f3160830ce9df53aa70d95ce7cfb8b06010b2f3691c78c65c21eb4cf3dfdbfc0745d89b664ee10435bb3a0f906c' )
42
+ assert . equal ( fixtureWallet . getPublicKeyString ( ) , fixturePublicKeyStr )
36
43
} )
37
44
} )
38
45
39
46
describe ( '.getAddress()' , function ( ) {
40
47
it ( 'should work' , function ( ) {
41
- assert . equal ( fixturewallet . getAddress ( ) . toString ( 'hex' ) , 'b14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
48
+ assert . equal ( fixtureWallet . getAddress ( ) . toString ( 'hex' ) , 'b14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
42
49
} )
43
50
} )
44
51
45
52
describe ( '.getAddressString()' , function ( ) {
46
53
it ( 'should work' , function ( ) {
47
- assert . equal ( fixturewallet . getAddressString ( ) , '0xb14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
54
+ assert . equal ( fixtureWallet . getAddressString ( ) , '0xb14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
48
55
} )
49
56
} )
50
57
51
58
describe ( '.getChecksumAddressString()' , function ( ) {
52
59
it ( 'should work' , function ( ) {
53
- assert . equal ( fixturewallet . getChecksumAddressString ( ) , '0xB14Ab53E38DA1C172f877DBC6d65e4a1B0474C3c' )
60
+ assert . equal ( fixtureWallet . getChecksumAddressString ( ) , '0xB14Ab53E38DA1C172f877DBC6d65e4a1B0474C3c' )
54
61
} )
55
62
} )
56
63
57
64
describe ( 'public key only wallet' , function ( ) {
58
- var pubKey = Buffer . from ( '5d4392f450262b276652c1fc037606abac500f3160830ce9df53aa70d95ce7cfb8b06010b2f3691c78c65c21eb4cf3dfdbfc0745d89b664ee10435bb3a0f906c' , 'hex' )
65
+ var pubKey = Buffer . from ( fixturePublicKey , 'hex' )
59
66
it ( '.fromPublicKey() should work' , function ( ) {
60
67
assert . equal ( Wallet . fromPublicKey ( pubKey ) . getPublicKey ( ) . toString ( 'hex' ) ,
61
- '5d4392f450262b276652c1fc037606abac500f3160830ce9df53aa70d95ce7cfb8b06010b2f3691c78c65c21eb4cf3dfdbfc0745d89b664ee10435bb3a0f906c' )
68
+ fixturePublicKey )
62
69
} )
63
70
it ( '.fromPublicKey() should not accept compressed keys in strict mode' , function ( ) {
64
71
assert . throws ( function ( ) {
@@ -122,7 +129,7 @@ describe('.generateVanityAddress()', function () {
122
129
123
130
describe ( '.getV3Filename()' , function ( ) {
124
131
it ( 'should work' , function ( ) {
125
- assert . equal ( fixturewallet . getV3Filename ( 1457917509265 ) , 'UTC--2016-03-14T01-05-09.265Z--b14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
132
+ assert . equal ( fixtureWallet . getV3Filename ( 1457917509265 ) , 'UTC--2016-03-14T01-05-09.265Z--b14ab53e38da1c172f877dbc6d65e4a1b0474c3c' )
126
133
} )
127
134
} )
128
135
@@ -132,14 +139,14 @@ describe('.toV3()', function () {
132
139
var uuid = Buffer . from ( '7e59dc028d42d09db29aa8a0f862cc81' , 'hex' )
133
140
134
141
it ( 'should work with PBKDF2' , function ( ) {
135
- var key = Buffer . from ( 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378' , 'hex' )
142
+ var key = Buffer . from ( fixturePrivateKey , 'hex' )
136
143
var wallet = Wallet . fromPrivateKey ( key )
137
144
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"}}'
138
145
// FIXME: just test for ciphertext and mac?
139
146
assert . equal ( wallet . toV3String ( 'testtest' , { kdf : 'pbkdf2' , uuid : uuid , salt : salt , iv : iv } ) , w )
140
147
} )
141
148
it ( 'should work with Scrypt' , function ( ) {
142
- var key = Buffer . from ( 'efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378' , 'hex' )
149
+ var key = Buffer . from ( fixturePrivateKey , 'hex' )
143
150
var wallet = Wallet . fromPrivateKey ( key )
144
151
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"}}'
145
152
this . timeout ( 180000 ) // 3minutes
0 commit comments