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

Commit 122aa25

Browse files
authored
Merge branch 'main' into bump-eth-hd-keyring-to-v5
2 parents d9e6c33 + 5474c1b commit 122aa25

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class KeyringController extends EventEmitter {
247247

248248
if ((!opts || !opts.mnemonic) && type === KEYRINGS_TYPE_MAP.HD_KEYRING) {
249249
keyring.generateRandomMnemonic();
250-
keyring.addAccounts();
250+
await keyring.addAccounts();
251251
}
252252

253253
const accounts = await keyring.getAccounts();

test/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ describe('KeyringController', function () {
280280

281281
sinon.assert.calledOnce(initSpy);
282282
});
283+
284+
it('should add HD Key Tree when addAccounts is asynchronous', async function () {
285+
const originalAccAccounts = HdKeyring.prototype.addAccounts;
286+
sinon.stub(HdKeyring.prototype, 'addAccounts').callsFake(function () {
287+
return new Promise((resolve) => {
288+
setImmediate(() => {
289+
resolve(originalAccAccounts.bind(this)());
290+
});
291+
});
292+
});
293+
294+
const keyring = await keyringController.addNewKeyring('HD Key Tree');
295+
296+
const keyringAccounts = await keyring.getAccounts();
297+
expect(keyringAccounts).toHaveLength(1);
298+
});
283299
});
284300

285301
describe('restoreKeyring', function () {

0 commit comments

Comments
 (0)