-
-
Notifications
You must be signed in to change notification settings - Fork 50
fix _initFromMnemonic bug + get test coverage to 100% #62
Conversation
da2e2dc
to
f98c952
Compare
@@ -36,6 +43,17 @@ describe('hd-keyring', () => { | |||
expect(accounts[1]).toStrictEqual(secondAcct); | |||
}); | |||
|
|||
it('constructs with a typeof array mnemonic', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a third type accepted: Buffer
.
keyring.generateRandomMnemonic(); | ||
const output = await keyring.serialize(); | ||
expect(output.numberOfAccounts).toBe(0); | ||
expect(Array.isArray(output.mnemonic)).toBe(true); | ||
}); | ||
|
||
it('serializes mnemonic stored as a string in a class variable into a buffer array and does not add accounts', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I suppose this test is useful because the mnemonic
field isn't marked as private, but I really was thinking of it as private 🤔 Maybe we should have noted the type change of this field in the changelog as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can note the change when we push a patch release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can amend the v4 changelog in that same PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Though I left one suggestion for an additional test case
@Gudahtt added a test to cover the case you noted. |
Thank you @adonesky1 for stepping in to fix the bugs that I must have missed in the original patch 😣 |
Fix bug where we are passing the unbuffered mnemonic to
bip39.mnemonicToSeedSync
when_initFromMnemonic
is passed a typeof string mnemonicBump unit test coverage to 100%