Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class KeyringController extends EventEmitter {

if ((!opts || !opts.mnemonic) && type === KEYRINGS_TYPE_MAP.HD_KEYRING) {
keyring.generateRandomMnemonic();
keyring.addAccounts();
await keyring.addAccounts();
}

const accounts = await keyring.getAccounts();
Expand Down
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ describe('KeyringController', function () {

sinon.assert.calledOnce(initSpy);
});

it('should add HD Key Tree when addAccounts is asynchronous', async function () {
const originalAccAccounts = HdKeyring.prototype.addAccounts;
sinon.stub(HdKeyring.prototype, 'addAccounts').callsFake(function () {
return new Promise((resolve) => {
setImmediate(() => {
resolve(originalAccAccounts.bind(this)());
});
});
});

const keyring = await keyringController.addNewKeyring('HD Key Tree');

const keyringAccounts = await keyring.getAccounts();
expect(keyringAccounts).toHaveLength(1);
});
});

describe('restoreKeyring', function () {
Expand Down