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

Commit 18ded5b

Browse files
committed
Added tests for covering fromV3() function branches
1 parent 0032880 commit 18ded5b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ describe('.generate()', function () {
120120

121121
describe('.generateVanityAddress()', function () {
122122
it('should generate an account with 000 prefix (object)', function () {
123+
this.timeout(180000) // 3minutes
123124
var wallet = Wallet.generateVanityAddress(/^000/)
124125
assert.equal(wallet.getPrivateKey().length, 32)
125126
assert.equal(wallet.getAddress()[0], 0)
126127
assert.equal(wallet.getAddress()[1] >>> 4, 0)
127128
})
128129
it('should generate an account with 000 prefix (string)', function () {
130+
this.timeout(180000) // 3minutes
129131
var wallet = Wallet.generateVanityAddress('^000')
130132
assert.equal(wallet.getPrivateKey().length, 32)
131133
assert.equal(wallet.getAddress()[0], 0)
@@ -155,10 +157,12 @@ describe('.toV3()', function () {
155157
// FIXME: just test for ciphertext and mac?
156158
assert.equal(fixtureWallet.toV3String('testtest', { kdf: 'scrypt', uuid: uuid, salt: salt, iv: iv }), w)
157159
})
158-
it('should work without providing options', function() {
160+
it('should work without providing options', function () {
161+
this.timeout(180000) // 3minutes
159162
assert.equal(fixtureWallet.toV3('testtest')['version'], 3)
160163
})
161164
it('should fail for unsupported kdf', function () {
165+
this.timeout(180000) // 3minutes
162166
assert.throws(function () {
163167
fixtureWallet.toV3('testtest', { kdf: 'superkey' })
164168
}, /^Error: Unsupported kdf$/)
@@ -204,6 +208,18 @@ describe('.fromV3()', function () {
204208
Wallet.fromV3(w, 'testpassword')
205209
}) // FIXME: check for assert message(s)
206210
})
211+
it('should fail for wrong version', function () {
212+
var w = '{"version":2}'
213+
assert.throws(function () {
214+
Wallet.fromV3(w, 'testpassword')
215+
}, /^Error: Not a V3 wallet$/)
216+
})
217+
it('should fail for wrong kdf', function () {
218+
var w = '{"Crypto":{"kdf":"superkey"},"version":3}'
219+
assert.throws(function () {
220+
Wallet.fromV3(w, 'testpassword', true)
221+
}, /^Error: Unsupported key derivation scheme$/)
222+
})
207223
})
208224

209225
describe('.fromEthSale()', function () {

0 commit comments

Comments
 (0)