From: Chris Duncan Date: Sun, 8 Dec 2024 07:29:07 +0000 (-0800) Subject: Skip account refresh tests for now. Remove test with undocumented data. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=eaea54071d41698082cd7d704d1a1f9bde8a15d3;p=libnemo.git Skip account refresh tests for now. Remove test with undocumented data. --- diff --git a/test/derive-accounts.test.mjs b/test/derive-accounts.test.mjs index dca775f..562635a 100644 --- a/test/derive-accounts.test.mjs +++ b/test/derive-accounts.test.mjs @@ -75,13 +75,13 @@ await suite('Account derivation', async () => { assert.exists(a.index) } }) -}) -await skip('fetch the first account from a Ledger device', async () => { - const wallet = await LedgerWallet.create() - const accounts = await wallet.accounts() + await skip('fetch the first account from a Ledger device', async () => { + const wallet = await LedgerWallet.create() + const accounts = await wallet.accounts() - assert.equals(accounts.length, 1) - assert.exists(accounts[0].publicKey) - assert.exists(accounts[0].address) + assert.equals(accounts.length, 1) + assert.exists(accounts[0].publicKey) + assert.exists(accounts[0].address) + }) }) diff --git a/test/import-wallet.test.mjs b/test/import-wallet.test.mjs index e8187c3..5f7a6a7 100644 --- a/test/import-wallet.test.mjs +++ b/test/import-wallet.test.mjs @@ -8,7 +8,7 @@ import { BIP32_TEST_VECTORS, CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS, TREZOR_TEST import { Account, Bip44Wallet, Blake2bWallet } from '#dist/main.js' await suite('Import wallets', async () => { - await test('import a wallet with the official Nano test vectors mnemonic', async () => { + await test('nano.org BIP-44 test vector mnemonic', async () => { const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -23,13 +23,22 @@ await suite('Import wallets', async () => { assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0) }) - await test('import a wallet with the checksum starting with a zero', async () => { - 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') + await test('nano.org BIP-44 test vector seed with no mnemonic', async () => { + const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(wallet.seed, 'F665F804E5907985455D1E5A7AD344843A2ED4179A7E06EEF263DE925FF6F4C0991B0A9344FCEE939FE0F1B1841B8C9B20FEACF6B954B74B2D26A01906B758E2') + const accounts = await wallet.accounts() + + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.ok(accounts[0] instanceof Account) + assert.equals(wallet.mnemonic, '') + assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) + assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0) + assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0) + assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0) }) - await test('import a wallet with a 12-word phrase', async () => { + await test('Trezor-derived BIP-44 entropy for 12-word mnemonic', async () => { const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_0) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -42,7 +51,7 @@ await suite('Import wallets', async () => { assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0) }) - await test('import a wallet with a 15-word phrase', async () => { + await test('Trezor-derived BIP-44 entropy for 15-word mnemonic', async () => { const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_1) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -55,7 +64,7 @@ await suite('Import wallets', async () => { assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1) }) - await test('import a wallet with a 18-word phrase', async () => { + await test('Trezor-derived BIP-44 entropy for 18-word mnemonic', async () => { const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_2) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -68,7 +77,7 @@ await suite('Import wallets', async () => { assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2) }) - await test('import a wallet with a 21-word phrase', async () => { + await test('Trezor-derived BIP-44 entropy for 21-word mnemonic', async () => { const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_3) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -81,22 +90,7 @@ await suite('Import wallets', async () => { assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3) }) - await test('import a wallet with the official Nano test vectors seed', 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.accounts() - - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.ok(accounts[0] instanceof Account) - assert.equals(wallet.mnemonic, '') - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - assert.equals(accounts[0].privateKey, NANO_TEST_VECTORS.PRIVATE_0) - assert.equals(accounts[0].publicKey, NANO_TEST_VECTORS.PUBLIC_0) - assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0) - }) - - await test('import a BIP-44 wallet with the zero seed', async () => { + await test('BIP-44 zero-string entropy', async () => { const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0, TREZOR_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0, 3) @@ -115,7 +109,7 @@ await suite('Import wallets', async () => { } }) - await test('import a BLAKE2b wallet with the zero seed', async () => { + await test('BLAKE2b zero-string seed', async () => { const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0, 3) @@ -135,7 +129,7 @@ await suite('Import wallets', async () => { } }) - await test('import a BLAKE2b wallet with Trezor test vectors', async () => { + await test('Trezor-derived BLAKE2b test vectors verified with third-party libraries', async () => { const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_1) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0, 1) @@ -156,7 +150,7 @@ await suite('Import wallets', async () => { assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1) }) - await test('get identical BLAKE2b wallets when created with a seed versus with its derived mnemonic', async () => { + await test('BLAKE2b seed creates identical wallet as its derived mnemonic', async () => { const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_2) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const walletAccounts = await wallet.accounts() @@ -178,7 +172,7 @@ await suite('Import wallets', async () => { assert.equals(importedAccount.publicKey, walletAccount.publicKey) }) - await test('get identical BLAKE2b wallets when created with max entropy value', async () => { + await test('BLAKE2b mnemonic for maximum seed value', async () => { const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_3) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts() @@ -194,28 +188,29 @@ await suite('Import wallets', async () => { assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0) }) - await test('reject when given invalid entropy', async () => { + await test('Reject invalid entropy', async () => { await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C797')) await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C79701')) await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0.replaceAll(/./g, 'x'))) }) - await test('reject when given a seed with an invalid length', async () => { + await test('Reject invalid length seed', async () => { await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED + 'f'), `Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length + 1}-character string.`) await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED.slice(0, -1)), `Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length - 1}-character string.`) }) - await test('reject when given a seed containing non-hex characters', async () => { + await test('Reject seed containing non-hex characters', async () => { await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.SEED_0.replace(/./, 'g')), 'Seed contains invalid hexadecimal characters.') await assert.rejects(Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1.replace(/./, 'g')), 'Seed contains invalid hexadecimal characters.') }) +}) - - await test('retrieve a Bip44Wallet from storage using an ID', async () => { +await suite('Retrieve wallets from session storage using a wallet-generated ID', async () => { + await test('Bip44Wallet', async () => { const id = (await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)).id const wallet = await Bip44Wallet.restore(id) @@ -233,7 +228,7 @@ await suite('Import wallets', async () => { assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) }) - await test('retrieve a Blake2bWallet from storage using an ID', async () => { + await test('Blake2bWallet', async () => { const id = (await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)).id const wallet = await Blake2bWallet.restore(id) diff --git a/test/main.mjs b/test/main.mjs index 6465627..4a78267 100644 --- a/test/main.mjs +++ b/test/main.mjs @@ -10,6 +10,4 @@ import './refresh-accounts.test.mjs' import './sign-blocks.test.mjs' import './tools.test.mjs' -document.addEventListener('load', () => { - console.log('> TESTING COMPLETE <') -}) +console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold') diff --git a/test/refresh-accounts.test.mjs b/test/refresh-accounts.test.mjs index ad40a39..89efbd1 100644 --- a/test/refresh-accounts.test.mjs +++ b/test/refresh-accounts.test.mjs @@ -15,7 +15,7 @@ if (process) { 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) @@ -71,7 +71,7 @@ await suite('refreshing account info', async () => { }) }) -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) @@ -129,8 +129,8 @@ await suite('finding next unopened account', async () => { }) }) -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) @@ -142,7 +142,7 @@ await suite('Refreshing wallet accounts', async () => { 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) @@ -150,7 +150,7 @@ await suite('Refreshing wallet accounts', async () => { 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))