]> git.codecow.com Git - libnemo.git/commitdiff
Await wallet destruction in tests.
authorChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 21:13:11 +0000 (14:13 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 21:13:11 +0000 (14:13 -0700)
test/perf.account.js
test/perf.wallet.js
test/test.create-wallet.mjs
test/test.derive-accounts.mjs
test/test.import-wallet.mjs
test/test.lock-unlock-wallet.mjs
test/test.refresh-accounts.mjs
test/test.tools.mjs

index 394bed3c8a8d1c705354c77bbba180af57014efc..e33296a3c778f155b3a29fd13c63c6291307f84f 100644 (file)
@@ -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))
        })
 })
index d9ae14ec5ece7ef8fc35d898448e112e20245c55..e1dd75c30c381b12d237c194014076cfd5351232 100644 (file)
@@ -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))
        })
index c457ea6eb5dc01f09c5e176ae6354fc0434bba69..c535359ea9f0a2163758b421d1b606c80a2c03d2 100644 (file)
@@ -20,7 +20,7 @@ await suite('Create wallets', async () => {
                assert.ok('seed' in wallet)\r
                assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BLAKE2b wallet with random entropy', async () => {\r
@@ -34,7 +34,7 @@ await suite('Create wallets', async () => {
                assert.ok('seed' in wallet)\r
                assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BIP-44 replace invalid salt with empty string', async () => {\r
@@ -61,6 +61,6 @@ await suite('Create wallets', async () => {
        await test('connect to ledger', { skip: true }, async () => {\r
                const wallet = await LedgerWallet.create()\r
                assert.ok(wallet)\r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 })\r
index fe1102208ca4f641e2741414e54c7f5e031ca19a..d6f48c9c096adcbe3ee70c76655a19701c76f1fc 100644 (file)
@@ -21,7 +21,7 @@ await suite('Account derivation', async () => {
                const accounts = await wallet.accounts()\r
                assert.equals(account, accounts[0])\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('should derive low indexed accounts from the given BIP-44 seed', async () => {\r
@@ -37,7 +37,7 @@ await suite('Account derivation', async () => {
                assert.equals(accounts[2].publicKey, NANO_TEST_VECTORS.PUBLIC_2)\r
                assert.equals(accounts[2].address, NANO_TEST_VECTORS.ADDRESS_2)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('should derive high indexed accounts from the given seed', async () => {\r
@@ -56,7 +56,7 @@ await suite('Account derivation', async () => {
                        assert.equals(a.index, i)\r
                }\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('should derive accounts for a BLAKE2b wallet', async () => {\r
@@ -84,7 +84,7 @@ await suite('Account derivation', async () => {
                        assert.exists(a.index)\r
                }\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fetch the first account from a Ledger device', { skip: true }, async () => {\r
@@ -95,6 +95,6 @@ await suite('Account derivation', async () => {
                assert.exists(accounts[0].publicKey)\r
                assert.exists(accounts[0].address)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 })\r
index 72008c76b36c48a0312d915aba81d4d06e9a0375..f0be098b269ea36bfd075342964a1545c3ca473d 100644 (file)
@@ -23,7 +23,7 @@ await suite('Import wallets', async () => {
                assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
                assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('nano.org BIP-44 test vector seed with no mnemonic', async () => {\r
@@ -40,7 +40,7 @@ await suite('Import wallets', async () => {
                assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
                assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Trezor-derived BIP-44 entropy for 12-word mnemonic', async () => {\r
@@ -55,7 +55,7 @@ await suite('Import wallets', async () => {
                assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_0)\r
                assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Trezor-derived BIP-44 entropy for 15-word mnemonic', async () => {\r
@@ -70,7 +70,7 @@ await suite('Import wallets', async () => {
                assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_1)\r
                assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Trezor-derived BIP-44 entropy for 18-word mnemonic', async () => {\r
@@ -85,7 +85,7 @@ await suite('Import wallets', async () => {
                assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_2)\r
                assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Trezor-derived BIP-44 entropy for 21-word mnemonic', async () => {\r
@@ -100,7 +100,7 @@ await suite('Import wallets', async () => {
                assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_3)\r
                assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BIP-44 zero-string entropy', async () => {\r
@@ -121,7 +121,7 @@ await suite('Import wallets', async () => {
                        assert.equals(accounts[i].index, i)\r
                }\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BLAKE2b zero-string seed', async () => {\r
@@ -143,7 +143,7 @@ await suite('Import wallets', async () => {
                        assert.equals(accounts[i].index, i)\r
                }\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Trezor-derived BLAKE2b test vectors verified with third-party libraries', async () => {\r
@@ -166,7 +166,7 @@ await suite('Import wallets', async () => {
                assert.equals(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1)\r
                assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BLAKE2b seed creates identical wallet as its derived mnemonic', async () => {\r
@@ -190,7 +190,7 @@ await suite('Import wallets', async () => {
                assert.equals(importedAccount.privateKey, walletAccount.privateKey)\r
                assert.equals(importedAccount.publicKey, walletAccount.publicKey)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('BLAKE2b mnemonic for maximum seed value', async () => {\r
@@ -208,7 +208,7 @@ await suite('Import wallets', async () => {
                assert.equals(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0)\r
                assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Reject invalid entropy', async () => {\r
@@ -251,7 +251,7 @@ await suite('Retrieve wallets from session storage using a wallet-generated ID',
                assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('Blake2bWallet', async () => {\r
@@ -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)\r
                assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 })\r
index 193639a1efc7e80baa7d3849a38f0bbebb291f29..71b372c30e228538f9f9953c3eb162e272bac27d 100644 (file)
@@ -25,7 +25,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('locking and unlocking a Bip44Wallet with a random CryptoKey', async () => {\r
@@ -48,7 +48,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Bip44Wallet with different passwords', async () => {\r
@@ -63,7 +63,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Bip44Wallet with different keys', async () => {\r
@@ -80,7 +80,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Bip44Wallet with different valid inputs', async () => {\r
@@ -93,7 +93,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Bip44Wallet with no input', async () => {\r
@@ -114,7 +114,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Bip44Wallet with invalid input', async () => {\r
@@ -135,7 +135,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC)\r
                assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('locking and unlocking a Blake2bWallet with a password', async () => {\r
@@ -154,7 +154,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
                assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => {\r
@@ -178,7 +178,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Blake2bWallet with different passwords', async () => {\r
@@ -190,7 +190,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Blake2bWallet with different keys', async () => {\r
@@ -207,7 +207,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Blake2bWallet with different valid inputs', async () => {\r
@@ -220,7 +220,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Blake2bWallet with no input', async () => {\r
@@ -241,7 +241,7 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('fail to unlock a Blake2bWallet with invalid input', async () => {\r
@@ -262,6 +262,6 @@ await suite('Lock and unlock wallets', async () => {
                assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 })\r
index b58f9f938f8573135d342af55aacd92f698ee48f..adbcb59738989b87b9028ff6b57e9e77b8d7ec72 100644 (file)
@@ -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()
        })
 })
index b63f5858e9c015844fe61cc1727a0fbf097b43ba..2cf933dad70aa8b317c6132419aafa813cbf897a 100644 (file)
@@ -118,7 +118,7 @@ await suite('signature tests', async () => {
                const valid = await sendBlock.verify(account.publicKey)\r
                assert.equals(valid, true)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('should reject a block using the wrong public key', async () => {\r
@@ -140,7 +140,7 @@ await suite('signature tests', async () => {
                const valid = await sendBlock.verify(account.publicKey)\r
                assert.equals(valid, false)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 \r
        await test('sweeper throws without required parameters', async () => {\r
@@ -155,6 +155,6 @@ await suite('signature tests', async () => {
                assert.ok(results)\r
                assert.equals(results.length, 1)\r
 \r
-               wallet.destroy()\r
+               await wallet.destroy()\r
        })\r
 })\r