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

Add comprehensive test coverage for fromV3 #62

Merged
merged 1 commit into from
Sep 24, 2018
Merged

Conversation

axic
Copy link
Member

@axic axic commented Jul 28, 2018

No description provided.

@coveralls
Copy link

coveralls commented Jul 28, 2018

Coverage Status

Coverage increased (+0.7%) to 89.199% when pulling 1ed1f2f on test-fromv3 into 5735026 on master.

@holgerd77
Copy link
Member

Rebased this.

it('should fail with invalid password', function () {
var w = '{"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"6087dab2f9fdbbfaddc31a909735c1e6"},"ciphertext":"5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"},"mac":"517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"},"id":"3198bc9c-6672-5ab3-d995-4942343ae5b6","version":3}'
assert.throws(function () {
Wallet.fromV3(w, 'wrongtestpassword')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just changing the password to an invalid one, unproblematic, looks good.

@@ -215,11 +221,17 @@ describe('.fromV3()', function () {
}, /^Error: Not a V3 wallet$/)
})
it('should fail for wrong kdf', function () {
var w = '{"Crypto":{"kdf":"superkey"},"version":3}'
var w = '{"crypto":{"kdf":"superkey"},"version":3}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to strict here, looks good.

var w = '{"crypto":{"kdf":"pbkdf2","kdfparams":{"prf":"invalid"}},"version":3}'
assert.throws(function () {
Wallet.fromV3(w, 'testpassword')
}, /^Error: Unsupported parameters to PBKDF2$/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test case with unsupported parameters, looks good.

@holgerd77 holgerd77 merged commit 3927a0e into master Sep 24, 2018
@holgerd77 holgerd77 deleted the test-fromv3 branch September 24, 2018 09:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants