import { Account, Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
\r
await suite('Import wallets', async () => {\r
- await test('import a wallet with the official Nano test vectors mnemonic', async () => {\r
+ await test('nano.org BIP-44 test vector mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
- await test('import a wallet with the checksum starting with a zero', async () => {\r
- const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, 'food define cancel major spoon trash cigar basic aim bless wolf win ability seek paddle bench seed century group they mercy address monkey cake')\r
+ await test('nano.org BIP-44 test vector seed with no mnemonic', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- assert.equals(wallet.seed, 'F665F804E5907985455D1E5A7AD344843A2ED4179A7E06EEF263DE925FF6F4C0991B0A9344FCEE939FE0F1B1841B8C9B20FEACF6B954B74B2D26A01906B758E2')\r
+ const accounts = await wallet.accounts()\r
+\r
+ assert.ok('mnemonic' in wallet)\r
+ assert.ok('seed' in wallet)\r
+ assert.ok(accounts[0] instanceof Account)\r
+ assert.equals(wallet.mnemonic, '')\r
+ assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
+ assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
+ assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
+ assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
- await test('import a wallet with a 12-word phrase', async () => {\r
+ await test('Trezor-derived BIP-44 entropy for 12-word mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_0)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
- await test('import a wallet with a 15-word phrase', async () => {\r
+ await test('Trezor-derived BIP-44 entropy for 15-word mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1)\r
})\r
\r
- await test('import a wallet with a 18-word phrase', async () => {\r
+ await test('Trezor-derived BIP-44 entropy for 18-word mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_2)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2)\r
})\r
\r
- await test('import a wallet with a 21-word phrase', async () => {\r
+ await test('Trezor-derived BIP-44 entropy for 21-word mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_3)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3)\r
})\r
\r
- await test('import a wallet with the official Nano test vectors seed', async () => {\r
- const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
- await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
- const accounts = await wallet.accounts()\r
-\r
- assert.ok('mnemonic' in wallet)\r
- assert.ok('seed' in wallet)\r
- assert.ok(accounts[0] instanceof Account)\r
- assert.equals(wallet.mnemonic, '')\r
- assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
- assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0)\r
- assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0)\r
- assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
- })\r
-\r
- await test('import a BIP-44 wallet with the zero seed', async () => {\r
+ await test('BIP-44 zero-string entropy', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0, TREZOR_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0, 3)\r
}\r
})\r
\r
- await test('import a BLAKE2b wallet with the zero seed', async () => {\r
+ await test('BLAKE2b zero-string seed', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0, 3)\r
}\r
})\r
\r
- await test('import a BLAKE2b wallet with Trezor test vectors', async () => {\r
+ await test('Trezor-derived BLAKE2b test vectors verified with third-party libraries', async () => {\r
const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0, 1)\r
assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1)\r
})\r
\r
- await test('get identical BLAKE2b wallets when created with a seed versus with its derived mnemonic', async () => {\r
+ await test('BLAKE2b seed creates identical wallet as its derived mnemonic', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_2)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const walletAccounts = await wallet.accounts()\r
assert.equals(importedAccount.publicKey, walletAccount.publicKey)\r
})\r
\r
- await test('get identical BLAKE2b wallets when created with max entropy value', async () => {\r
+ await test('BLAKE2b mnemonic for maximum seed value', async () => {\r
const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_3)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0)\r
})\r
\r
- await test('reject when given invalid entropy', async () => {\r
+ await test('Reject invalid entropy', async () => {\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C797'))\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C79701'))\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0.replaceAll(/./g, 'x')))\r
})\r
\r
- await test('reject when given a seed with an invalid length', async () => {\r
+ await test('Reject invalid length seed', async () => {\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED + 'f'),\r
`Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length + 1}-character string.`)\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED.slice(0, -1)),\r
`Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length - 1}-character string.`)\r
})\r
\r
- await test('reject when given a seed containing non-hex characters', async () => {\r
+ await test('Reject seed containing non-hex characters', async () => {\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.SEED_0.replace(/./, 'g')),\r
'Seed contains invalid hexadecimal characters.')\r
await assert.rejects(Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1.replace(/./, 'g')),\r
'Seed contains invalid hexadecimal characters.')\r
})\r
+})\r
\r
-\r
- await test('retrieve a Bip44Wallet from storage using an ID', async () => {\r
+await suite('Retrieve wallets from session storage using a wallet-generated ID', async () => {\r
+ await test('Bip44Wallet', async () => {\r
const id = (await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)).id\r
const wallet = await Bip44Wallet.restore(id)\r
\r
assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
- await test('retrieve a Blake2bWallet from storage using an ID', async () => {\r
+ await test('Blake2bWallet', async () => {\r
const id = (await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)).id\r
const wallet = await Blake2bWallet.restore(id)\r
\r
rpc = new Rpc(process?.env?.NODE_URL ?? '', process?.env?.API_KEY_NAME)
}
-await suite('refreshing account info', async () => {
+await skip('refreshing account info', async () => {
await test('fetch balance, frontier, and representative', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
})
})
-await suite('finding next unopened account', async () => {
+await skip('Fetch next unopened account', async () => {
await test('return correct account from test vector', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
})
})
-await suite('Refreshing wallet accounts', async () => {
- skip('should get balance, frontier, and representative for one account', async () => {
+await skip('Refreshing wallet accounts', async () => {
+ await test('should get balance, frontier, and representative for one account', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc)
assert.equals(typeof account.frontier, 'string')
})
- skip('should get balance, frontier, and representative for multiple accounts', async () => {
+ await test('should get balance, frontier, and representative for multiple accounts', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc, 0, 2)
assert.ok(accounts[0] instanceof Account)
})
- skip('should handle failure gracefully', async () => {
+ await test('should handle failure gracefully', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.doesNotReject(wallet.refresh(rpc, 0, 20))