From: Chris Duncan Date: Thu, 3 Jul 2025 21:13:11 +0000 (-0700) Subject: Await wallet destruction in tests. X-Git-Tag: v0.10.5~136^2~2 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=918e07cb9688c09927cec35f3f3998aaec0c2a3d;p=libnemo.git Await wallet destruction in tests. --- diff --git a/test/perf.account.js b/test/perf.account.js index 394bed3..e33296a 100644 --- a/test/perf.account.js +++ b/test/perf.account.js @@ -19,7 +19,7 @@ await suite('Account performance', async () => { console.log(`Total: ${end - start} ms`) console.log(`Average: ${(end - start) / COUNT} ms`) assert.equals(accounts.length, COUNT) - wallet.destroy() + await wallet.destroy() }) await test(`Time to create ${COUNT} BLAKE2b accounts`, async () => { @@ -31,7 +31,7 @@ await suite('Account performance', async () => { console.log(`Total: ${end - start} ms`) console.log(`Average: ${(end - start) / COUNT} ms`) assert.equals(accounts.length, COUNT) - wallet.destroy() + await wallet.destroy() }) await test(`Time to create 1 BIP-44 account ${COUNT} times`, async () => { @@ -44,7 +44,7 @@ await suite('Account performance', async () => { const end = performance.now() times.push(end - start) } - wallet.destroy() + await wallet.destroy() console.log(stats(times)) }) @@ -58,7 +58,7 @@ await suite('Account performance', async () => { const end = performance.now() times.push(end - start) } - wallet.destroy() + await wallet.destroy() console.log(stats(times)) }) }) diff --git a/test/perf.wallet.js b/test/perf.wallet.js index d9ae14e..e1dd75c 100644 --- a/test/perf.wallet.js +++ b/test/perf.wallet.js @@ -17,7 +17,7 @@ await suite(`Wallet performance`, async () => { const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD) const end = performance.now() times.push(end - start) - wallet.destroy() + await wallet.destroy() } console.log(stats(times)) }) @@ -29,7 +29,7 @@ await suite(`Wallet performance`, async () => { const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD) const end = performance.now() times.push(end - start) - wallet.destroy() + await wallet.destroy() } console.log(stats(times)) }) diff --git a/test/test.create-wallet.mjs b/test/test.create-wallet.mjs index c457ea6..c535359 100644 --- a/test/test.create-wallet.mjs +++ b/test/test.create-wallet.mjs @@ -20,7 +20,7 @@ await suite('Create wallets', async () => { assert.ok('seed' in wallet) assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed)) - wallet.destroy() + await wallet.destroy() }) await test('BLAKE2b wallet with random entropy', async () => { @@ -34,7 +34,7 @@ await suite('Create wallets', async () => { assert.ok('seed' in wallet) assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed)) - wallet.destroy() + await wallet.destroy() }) await test('BIP-44 replace invalid salt with empty string', async () => { @@ -61,6 +61,6 @@ await suite('Create wallets', async () => { await test('connect to ledger', { skip: true }, async () => { const wallet = await LedgerWallet.create() assert.ok(wallet) - wallet.destroy() + await wallet.destroy() }) }) diff --git a/test/test.derive-accounts.mjs b/test/test.derive-accounts.mjs index fe11022..d6f48c9 100644 --- a/test/test.derive-accounts.mjs +++ b/test/test.derive-accounts.mjs @@ -21,7 +21,7 @@ await suite('Account derivation', async () => { const accounts = await wallet.accounts() assert.equals(account, accounts[0]) - wallet.destroy() + await wallet.destroy() }) await test('should derive low indexed accounts from the given BIP-44 seed', async () => { @@ -37,7 +37,7 @@ await suite('Account derivation', async () => { assert.equals(accounts[2].publicKey, NANO_TEST_VECTORS.PUBLIC_2) assert.equals(accounts[2].address, NANO_TEST_VECTORS.ADDRESS_2) - wallet.destroy() + await wallet.destroy() }) await test('should derive high indexed accounts from the given seed', async () => { @@ -56,7 +56,7 @@ await suite('Account derivation', async () => { assert.equals(a.index, i) } - wallet.destroy() + await wallet.destroy() }) await test('should derive accounts for a BLAKE2b wallet', async () => { @@ -84,7 +84,7 @@ await suite('Account derivation', async () => { assert.exists(a.index) } - wallet.destroy() + await wallet.destroy() }) await test('fetch the first account from a Ledger device', { skip: true }, async () => { @@ -95,6 +95,6 @@ await suite('Account derivation', async () => { assert.exists(accounts[0].publicKey) assert.exists(accounts[0].address) - wallet.destroy() + await wallet.destroy() }) }) diff --git a/test/test.import-wallet.mjs b/test/test.import-wallet.mjs index 72008c7..f0be098 100644 --- a/test/test.import-wallet.mjs +++ b/test/test.import-wallet.mjs @@ -23,7 +23,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0) assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0) - wallet.destroy() + await wallet.destroy() }) await test('nano.org BIP-44 test vector seed with no mnemonic', async () => { @@ -40,7 +40,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0) assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0) - wallet.destroy() + await wallet.destroy() }) await test('Trezor-derived BIP-44 entropy for 12-word mnemonic', async () => { @@ -55,7 +55,7 @@ await suite('Import wallets', async () => { assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_0) assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0) - wallet.destroy() + await wallet.destroy() }) await test('Trezor-derived BIP-44 entropy for 15-word mnemonic', async () => { @@ -70,7 +70,7 @@ await suite('Import wallets', async () => { assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_1) assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1) - wallet.destroy() + await wallet.destroy() }) await test('Trezor-derived BIP-44 entropy for 18-word mnemonic', async () => { @@ -85,7 +85,7 @@ await suite('Import wallets', async () => { assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_2) assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2) - wallet.destroy() + await wallet.destroy() }) await test('Trezor-derived BIP-44 entropy for 21-word mnemonic', async () => { @@ -100,7 +100,7 @@ await suite('Import wallets', async () => { assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_3) assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3) - wallet.destroy() + await wallet.destroy() }) await test('BIP-44 zero-string entropy', async () => { @@ -121,7 +121,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[i].index, i) } - wallet.destroy() + await wallet.destroy() }) await test('BLAKE2b zero-string seed', async () => { @@ -143,7 +143,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[i].index, i) } - wallet.destroy() + await wallet.destroy() }) await test('Trezor-derived BLAKE2b test vectors verified with third-party libraries', async () => { @@ -166,7 +166,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1) assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1) - wallet.destroy() + await wallet.destroy() }) await test('BLAKE2b seed creates identical wallet as its derived mnemonic', async () => { @@ -190,7 +190,7 @@ await suite('Import wallets', async () => { assert.equals(importedAccount.privateKey, walletAccount.privateKey) assert.equals(importedAccount.publicKey, walletAccount.publicKey) - wallet.destroy() + await wallet.destroy() }) await test('BLAKE2b mnemonic for maximum seed value', async () => { @@ -208,7 +208,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0) assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0) - wallet.destroy() + await wallet.destroy() }) await test('Reject invalid entropy', async () => { @@ -251,7 +251,7 @@ await suite('Retrieve wallets from session storage using a wallet-generated ID', assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('Blake2bWallet', async () => { @@ -271,6 +271,6 @@ await suite('Retrieve wallets from session storage using a wallet-generated ID', assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) - wallet.destroy() + await wallet.destroy() }) }) diff --git a/test/test.lock-unlock-wallet.mjs b/test/test.lock-unlock-wallet.mjs index 193639a..71b372c 100644 --- a/test/test.lock-unlock-wallet.mjs +++ b/test/test.lock-unlock-wallet.mjs @@ -25,7 +25,7 @@ await suite('Lock and unlock wallets', async () => { assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('locking and unlocking a Bip44Wallet with a random CryptoKey', async () => { @@ -48,7 +48,7 @@ await suite('Lock and unlock wallets', async () => { assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Bip44Wallet with different passwords', async () => { @@ -63,7 +63,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Bip44Wallet with different keys', async () => { @@ -80,7 +80,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Bip44Wallet with different valid inputs', async () => { @@ -93,7 +93,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Bip44Wallet with no input', async () => { @@ -114,7 +114,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Bip44Wallet with invalid input', async () => { @@ -135,7 +135,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - wallet.destroy() + await wallet.destroy() }) await test('locking and unlocking a Blake2bWallet with a password', async () => { @@ -154,7 +154,7 @@ await suite('Lock and unlock wallets', async () => { assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) - wallet.destroy() + await wallet.destroy() }) await test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => { @@ -178,7 +178,7 @@ await suite('Lock and unlock wallets', async () => { assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Blake2bWallet with different passwords', async () => { @@ -190,7 +190,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Blake2bWallet with different keys', async () => { @@ -207,7 +207,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Blake2bWallet with different valid inputs', async () => { @@ -220,7 +220,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Blake2bWallet with no input', async () => { @@ -241,7 +241,7 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) await test('fail to unlock a Blake2bWallet with invalid input', async () => { @@ -262,6 +262,6 @@ await suite('Lock and unlock wallets', async () => { assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - wallet.destroy() + await wallet.destroy() }) }) diff --git a/test/test.refresh-accounts.mjs b/test/test.refresh-accounts.mjs index b58f9f9..adbcb59 100644 --- a/test/test.refresh-accounts.mjs +++ b/test/test.refresh-accounts.mjs @@ -44,7 +44,7 @@ await suite('refreshing account info', { skip: true }, async () => { assert.notEqual(account.representative?.address, null) assert.notEqual(account.representative?.address, '') - wallet.destroy() + await wallet.destroy() }) await test('throw when refreshing unopened account', async () => { @@ -55,7 +55,7 @@ await suite('refreshing account info', { skip: true }, async () => { await assert.rejects(account.refresh(rpc), { message: 'Account not found' }) - wallet.destroy() + await wallet.destroy() }) await test('throw when referencing invalid account index', async () => { @@ -74,7 +74,7 @@ await suite('refreshing account info', { skip: true }, async () => { await assert.rejects(account.refresh(invalidNode), { message: 'Account not found' }) - wallet.destroy() + await wallet.destroy() }) }) @@ -88,7 +88,7 @@ await suite('Fetch next unopened account', { skip: true }, async () => { assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) - wallet.destroy() + await wallet.destroy() }) await test('return successfully for small batch size', async () => { @@ -99,7 +99,7 @@ await suite('Fetch next unopened account', { skip: true }, async () => { assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) - wallet.destroy() + await wallet.destroy() }) await test('return successfully for large batch size', async () => { @@ -110,7 +110,7 @@ await suite('Fetch next unopened account', { skip: true }, async () => { assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) - wallet.destroy() + await wallet.destroy() }) await test('should throw on invalid node URL', async () => { @@ -123,7 +123,7 @@ await suite('Fetch next unopened account', { skip: true }, async () => { await assert.rejects(wallet.getNextNewAccount('')) await assert.rejects(wallet.getNextNewAccount('foo')) - wallet.destroy() + await wallet.destroy() }) await test('should throw on invalid batch size', async () => { @@ -139,7 +139,7 @@ await suite('Fetch next unopened account', { skip: true }, async () => { //@ts-expect-error await assert.rejects(wallet.getNextNewAccount(rpc, { 'foo': 'bar' })) - wallet.destroy() + await wallet.destroy() }) }) @@ -156,7 +156,7 @@ await suite('Refreshing wallet accounts', { skip: true }, async () => { assert.notEqual(account.frontier, null) assert.equals(typeof account.frontier, 'string') - wallet.destroy() + await wallet.destroy() }) await test('should get balance, frontier, and representative for multiple accounts', async () => { @@ -166,7 +166,7 @@ await suite('Refreshing wallet accounts', { skip: true }, async () => { assert.equals(accounts.length, 1) assert.ok(accounts[0] instanceof Account) - wallet.destroy() + await wallet.destroy() }) await test('should handle failure gracefully', async () => { @@ -174,6 +174,6 @@ await suite('Refreshing wallet accounts', { skip: true }, async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) await assert.doesNotReject(wallet.refresh(rpc, 0, 20)) - wallet.destroy() + await wallet.destroy() }) }) diff --git a/test/test.tools.mjs b/test/test.tools.mjs index b63f585..2cf933d 100644 --- a/test/test.tools.mjs +++ b/test/test.tools.mjs @@ -118,7 +118,7 @@ await suite('signature tests', async () => { const valid = await sendBlock.verify(account.publicKey) assert.equals(valid, true) - wallet.destroy() + await wallet.destroy() }) await test('should reject a block using the wrong public key', async () => { @@ -140,7 +140,7 @@ await suite('signature tests', async () => { const valid = await sendBlock.verify(account.publicKey) assert.equals(valid, false) - wallet.destroy() + await wallet.destroy() }) await test('sweeper throws without required parameters', async () => { @@ -155,6 +155,6 @@ await suite('signature tests', async () => { assert.ok(results) assert.equals(results.length, 1) - wallet.destroy() + await wallet.destroy() }) })