From 7c600df8874660dda253887d57906e312d6601a9 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 26 Apr 2026 06:34:07 -0700 Subject: [PATCH] Add some Exodus wallet tests. --- test/test.derive-accounts.mjs | 83 +++++++++++++++++++++++++++++++++-- test/test.lock-unlock.mjs | 2 +- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/test/test.derive-accounts.mjs b/test/test.derive-accounts.mjs index 7b7a062..3a40b28 100644 --- a/test/test.derive-accounts.mjs +++ b/test/test.derive-accounts.mjs @@ -5,7 +5,7 @@ import { Wallet } from 'libnemo' import { assert, suite, test } from './GLOBALS.mjs' -import { NANO_TEST_VECTORS } from './VECTORS.mjs' +import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs' await Promise.all([ suite('Derive accounts from BIP-44 wallet', async () => { @@ -45,7 +45,7 @@ await Promise.all([ await assert.resolves(wallet.destroy()) }) - await test('derive high indexed accounts from the given seed', async () => { + await test('derive high indexed accounts from the given BIP-44 seed', async () => { const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0x70000000, 0x7000000f) @@ -99,7 +99,7 @@ await Promise.all([ await assert.resolves(wallet.destroy()) }) - await test('derive low indexed accounts from the given BLAKE2B seed', async () => { + await test('derive low indexed accounts from the given BLAKE2b seed', async () => { const wallet = await Wallet.load('BLAKE2b', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(2, 3) @@ -119,7 +119,7 @@ await Promise.all([ await assert.resolves(wallet.destroy()) }) - await test('derive high indexed accounts from the given seed', async () => { + await test('derive high indexed accounts from the given BLAKE2b seed', async () => { const wallet = await Wallet.load('BLAKE2b', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0x70000000, 0x7000000f) @@ -148,6 +148,81 @@ await Promise.all([ assert.exists(accounts.get(1)) assert.equal(account, accounts.get(1)) + await assert.resolves(wallet.destroy()) + await assert.resolves(restored.destroy()) + }) + }), + + suite('Derive accounts from Exodus wallet', async () => { + const { PASSWORD } = NANO_TEST_VECTORS + const { ADDRESS_0, ADDRESS_1, BIP39_SEED_0, BIP39_SEED_1, PUBLIC_0, PUBLIC_1 } = CUSTOM_TEST_VECTORS.EXODUS + + await test('derive the first account from the given Exodus seed', async () => { + const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0) + await wallet.unlock(PASSWORD) + const account = await wallet.account() + + assert.equal(account.publicKey, PUBLIC_0) + assert.equal(account.address, ADDRESS_0) + + const accounts = await wallet.accounts() + assert.exists(accounts.get(0)) + assert.equal(account, accounts.get(0)) + + await assert.resolves(wallet.destroy()) + }) + + await test('derive low indexed accounts from the given Exodus seed', async () => { + const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_1) + await wallet.unlock(PASSWORD) + const accounts = await wallet.accounts(1, 2) + + assert.equal(accounts.size, 2) + + const account1 = accounts.get(1) + assert.exists(account1) + assert.notEqual(account1.publicKey, PUBLIC_1) + assert.notEqual(account1.address, ADDRESS_1) + + const account2 = accounts.get(2) + assert.exists(account2) + assert.notEqual(account2.publicKey, PUBLIC_1) + assert.notEqual(account2.address, ADDRESS_1) + assert.notEqual(account2.publicKey, account1.publicKey) + assert.notEqual(account2.address, account1.address) + + await assert.resolves(wallet.destroy()) + }) + + await test('derive high indexed accounts from the given Exodus seed', async () => { + const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + const accounts = await wallet.accounts(0x70000000, 0x7000000f) + + assert.equal(accounts.size, 0x10) + for (let i = 0x70000000; i < 0x7000000f; i++) { + const a = accounts.get(i) + assert.exists(a) + assert.exists(a.address) + assert.exists(a.publicKey) + } + + await assert.resolves(wallet.destroy()) + }) + + await test('derive from restored Exodus wallet', async () => { + const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0) + const restored = await Wallet.restore(wallet.id) + await restored.unlock(PASSWORD) + const account = await restored.account() + + assert.equal(account.publicKey, PUBLIC_0) + assert.equal(account.address, ADDRESS_0) + + const accounts = await restored.accounts() + assert.exists(accounts.get(0)) + assert.equal(account, accounts.get(0)) + await assert.resolves(wallet.destroy()) await assert.resolves(restored.destroy()) }) diff --git a/test/test.lock-unlock.mjs b/test/test.lock-unlock.mjs index 873d956..11b63c8 100644 --- a/test/test.lock-unlock.mjs +++ b/test/test.lock-unlock.mjs @@ -131,7 +131,7 @@ await Promise.all([ await assert.resolves(wallet.destroy()) }) - await test('wallet automatic lock resets after user activity', { skip: false }, async () => { + await test('wallet automatic lock resets after user activity', { skip: true }, async () => { console.log('Starting autolock test...') const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) assert.equal(wallet.isLocked, true) -- 2.47.3