]> git.codecow.com Git - libnemo.git/commitdiff
Fix tests and documentation around updated accounts range.
authorChris Duncan <chris@codecow.com>
Mon, 10 Aug 2026 06:13:08 +0000 (23:13 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 10 Aug 2026 06:13:08 +0000 (23:13 -0700)
README.md
src/lib/wallet/unopened.ts
test/test.derive-accounts.mjs
test/test.import-wallet.mjs
test/test.ledger.mjs

index 17baf08d13ba9f1ab3725389691b14a72b075ae5..0526e5ac3e734e451f8c0408f459f04b09a80d56 100644 (file)
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ try {
 
 const firstAccount = await wallet.account();
 const secondAccount = await wallet.account(1);
-const multipleAccounts = await wallet.accounts(2, 3);
+const multipleAccounts = await wallet.accounts(2, 4);
 const thirdAccount = multipleAccounts[2];
 const { address, publicKey } = firstAccount;
 
index 49beff1140693e2a82934aeafb8d8cc3331f04b3..812ab75cdd6bcd1afdfd6f0f7f8dee207c092fe2 100644 (file)
@@ -16,7 +16,7 @@ export async function _unopened (wallet: Wallet, rpc: unknown, batchSize: unknow
        if (typeof from !== 'number' || from < 0 || 0xffffffff < from) {
                throw new TypeError('Invalid starting account index', { cause: from })
        }
-       const to = (from + batchSize > 0xffffffff) ? 0xffffffff : from + batchSize
+       const to = (from + batchSize > 0x100000000) ? 0x100000000 : from + batchSize
        const accounts = await wallet.accounts(from, to)
        const addresses = []
        for (const account of accounts.values()) {
@@ -42,5 +42,5 @@ export async function _unopened (wallet: Wallet, rpc: unknown, batchSize: unknow
        if (to >= 0xffffffff) {
                throw new RangeError('Max index reached')
        }
-       return await _unopened(wallet, rpc, batchSize, to + 1)
+       return await _unopened(wallet, rpc, batchSize, to)
 }
index e2ddf08da974babeedeabdd4cc7fee0162551332..e2994718f51772e1891aaf1f4f3ccf26aa34a162 100644 (file)
@@ -41,7 +41,7 @@ await Promise.all([
                await test('derive low indexed accounts from the given BIP-44 seed', async () => {\r
                        const wallet = await Wallet.load('BIP-44', TEST_PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(1, 2)\r
+                       const accounts = await wallet.accounts(1, 3)\r
 \r
                        assert.equal(accounts.size, 2)\r
 \r
@@ -61,10 +61,10 @@ await Promise.all([
                await test('derive high indexed accounts from the given BIP-44 seed', async () => {\r
                        const wallet = await Wallet.load('BIP-44', TEST_PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
+                       const accounts = await wallet.accounts(0x70000000, 0x70000010)\r
 \r
                        assert.equal(accounts.size, 0x10)\r
-                       for (let i = 0x70000000; i < 0x7000000f; i++) {\r
+                       for (let i = 0x70000000; i < 0x70000010; i++) {\r
                                const a = accounts.get(i)\r
                                assert.exists(a)\r
                                assert.exists(a.address)\r
@@ -128,7 +128,7 @@ await Promise.all([
                await test('derive low indexed accounts from the given BLAKE2b seed', async () => {\r
                        const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(2, 3)\r
+                       const accounts = await wallet.accounts(2, 4)\r
 \r
                        assert.equal(accounts.size, 2)\r
 \r
@@ -148,10 +148,10 @@ await Promise.all([
                await test('derive high indexed accounts from the given BLAKE2b seed', async () => {\r
                        const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
+                       const accounts = await wallet.accounts(0x70000000, 0x70000010)\r
 \r
                        assert.equal(accounts.size, 0x10)\r
-                       for (let i = 0x70000000; i < 0x7000000f; i++) {\r
+                       for (let i = 0x70000000; i < 0x70000010; i++) {\r
                                const a = accounts.get(i)\r
                                assert.exists(a)\r
                                assert.exists(a.address)\r
@@ -213,7 +213,7 @@ await Promise.all([
                await test('derive low indexed accounts from the given Exodus seed', async () => {\r
                        const wallet = await Wallet.load('Exodus', TEST_PASSWORD, BIP39_SEED_1)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(1, 2)\r
+                       const accounts = await wallet.accounts(1, 3)\r
 \r
                        assert.equal(accounts.size, 2)\r
 \r
@@ -235,10 +235,10 @@ await Promise.all([
                await test('derive high indexed accounts from the given Exodus seed', async () => {\r
                        const wallet = await Wallet.load('Exodus', TEST_PASSWORD, BIP39_SEED_0)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
+                       const accounts = await wallet.accounts(0x70000000, 0x70000010)\r
 \r
                        assert.equal(accounts.size, 0x10)\r
-                       for (let i = 0x70000000; i < 0x7000000f; i++) {\r
+                       for (let i = 0x70000000; i < 0x70000010; i++) {\r
                                const a = accounts.get(i)\r
                                assert.exists(a)\r
                                assert.exists(a.address)\r
index 9eb538ddccd591ea8270a66c4c5c27d4464d4d8b..963a7e346d1ab2b3ae68c2d0c6c315bf7ac7ce6e 100644 (file)
@@ -95,7 +95,7 @@ await Promise.all([
                await test('BIP-44 zero-string entropy', async () => {\r
                        const wallet = await Wallet.load('BIP-44', TEST_PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_0, TREZOR_TEST_VECTORS.MNEMONIC_SALT)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0, 3)\r
+                       const accounts = await wallet.accounts(0, 4)\r
 \r
                        assert.ok('mnemonic' in wallet)\r
                        assert.ok('seed' in wallet)\r
@@ -116,7 +116,7 @@ await Promise.all([
                await test('BLAKE2b zero-string seed', async () => {\r
                        const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0, 3)\r
+                       const accounts = await wallet.accounts(0, 4)\r
 \r
                        assert.ok('mnemonic' in wallet)\r
                        assert.ok('seed' in wallet)\r
@@ -139,7 +139,7 @@ await Promise.all([
                await test('Trezor-derived BLAKE2b test vectors verified with third-party libraries', async () => {\r
                        const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                        await wallet.unlock(TEST_PASSWORD)\r
-                       const accounts = await wallet.accounts(0, 1)\r
+                       const accounts = await wallet.accounts(0, 2)\r
 \r
                        assert.ok(await wallet.verify(TREZOR_TEST_VECTORS.MNEMONIC_1))\r
                        assert.ok(await wallet.verify(TREZOR_TEST_VECTORS.ENTROPY_1))\r
index 945dab1d1269d18ed8b70146d3aec960dbf134a5..bb2ae71285146f1189e1bd9f351148e11346f3cc 100644 (file)
@@ -217,7 +217,7 @@ await Promise.all([
                })
 
                await test('get second and third accounts', async () => {
-                       const accounts = await wallet.accounts(1, 2)
+                       const accounts = await wallet.accounts(1, 3)
                        assert.exists(accounts)
                        assert.equal(accounts.size, 2)
                        for (const account of accounts.values()) {