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 () => {
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 () => {
const end = performance.now()
times.push(end - start)
}
- wallet.destroy()
+ await wallet.destroy()
console.log(stats(times))
})
const end = performance.now()
times.push(end - start)
}
- wallet.destroy()
+ await wallet.destroy()
console.log(stats(times))
})
})
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))
})
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))
})
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
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
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
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
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
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
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
assert.exists(accounts[0].publicKey)\r
assert.exists(accounts[0].address)\r
\r
- wallet.destroy()\r
+ await wallet.destroy()\r
})\r
})\r
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
assert.notEqual(account.representative?.address, null)
assert.notEqual(account.representative?.address, '')
- wallet.destroy()
+ await wallet.destroy()
})
await test('throw when refreshing unopened account', 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 () => {
await assert.rejects(account.refresh(invalidNode),
{ message: 'Account not found' })
- wallet.destroy()
+ await wallet.destroy()
})
})
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 () => {
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 () => {
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 () => {
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 () => {
//@ts-expect-error
await assert.rejects(wallet.getNextNewAccount(rpc, { 'foo': 'bar' }))
- wallet.destroy()
+ await wallet.destroy()
})
})
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 () => {
assert.equals(accounts.length, 1)
assert.ok(accounts[0] instanceof Account)
- wallet.destroy()
+ await wallet.destroy()
})
await test('should handle failure gracefully', async () => {
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.doesNotReject(wallet.refresh(rpc, 0, 20))
- wallet.destroy()
+ await wallet.destroy()
})
})
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
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
assert.ok(results)\r
assert.equals(results.length, 1)\r
\r
- wallet.destroy()\r
+ await wallet.destroy()\r
})\r
})\r