\r
import { Wallet } from 'libnemo'\r
import { assert, suite, test } from './GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS } from './VECTORS.mjs'\r
+import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs'\r
\r
await Promise.all([\r
suite('Derive accounts from BIP-44 wallet', async () => {\r
await assert.resolves(wallet.destroy())\r
})\r
\r
- await test('derive high indexed accounts from the given seed', async () => {\r
+ await test('derive high indexed accounts from the given BIP-44 seed', async () => {\r
const wallet = await Wallet.load('BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
await assert.resolves(wallet.destroy())\r
})\r
\r
- await test('derive low indexed accounts from the given BLAKE2B seed', async () => {\r
+ await test('derive low indexed accounts from the given BLAKE2b seed', async () => {\r
const wallet = await Wallet.load('BLAKE2b', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(2, 3)\r
await assert.resolves(wallet.destroy())\r
})\r
\r
- await test('derive high indexed accounts from the given seed', async () => {\r
+ await test('derive high indexed accounts from the given BLAKE2b seed', async () => {\r
const wallet = await Wallet.load('BLAKE2b', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
assert.exists(accounts.get(1))\r
assert.equal(account, accounts.get(1))\r
\r
+ await assert.resolves(wallet.destroy())\r
+ await assert.resolves(restored.destroy())\r
+ })\r
+ }),\r
+\r
+ suite('Derive accounts from Exodus wallet', async () => {\r
+ const { PASSWORD } = NANO_TEST_VECTORS\r
+ const { ADDRESS_0, ADDRESS_1, BIP39_SEED_0, BIP39_SEED_1, PUBLIC_0, PUBLIC_1 } = CUSTOM_TEST_VECTORS.EXODUS\r
+\r
+ await test('derive the first account from the given Exodus seed', async () => {\r
+ const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0)\r
+ await wallet.unlock(PASSWORD)\r
+ const account = await wallet.account()\r
+\r
+ assert.equal(account.publicKey, PUBLIC_0)\r
+ assert.equal(account.address, ADDRESS_0)\r
+\r
+ const accounts = await wallet.accounts()\r
+ assert.exists(accounts.get(0))\r
+ assert.equal(account, accounts.get(0))\r
+\r
+ await assert.resolves(wallet.destroy())\r
+ })\r
+\r
+ await test('derive low indexed accounts from the given Exodus seed', async () => {\r
+ const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_1)\r
+ await wallet.unlock(PASSWORD)\r
+ const accounts = await wallet.accounts(1, 2)\r
+\r
+ assert.equal(accounts.size, 2)\r
+\r
+ const account1 = accounts.get(1)\r
+ assert.exists(account1)\r
+ assert.notEqual(account1.publicKey, PUBLIC_1)\r
+ assert.notEqual(account1.address, ADDRESS_1)\r
+\r
+ const account2 = accounts.get(2)\r
+ assert.exists(account2)\r
+ assert.notEqual(account2.publicKey, PUBLIC_1)\r
+ assert.notEqual(account2.address, ADDRESS_1)\r
+ assert.notEqual(account2.publicKey, account1.publicKey)\r
+ assert.notEqual(account2.address, account1.address)\r
+\r
+ await assert.resolves(wallet.destroy())\r
+ })\r
+\r
+ await test('derive high indexed accounts from the given Exodus seed', async () => {\r
+ const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+ const accounts = await wallet.accounts(0x70000000, 0x7000000f)\r
+\r
+ assert.equal(accounts.size, 0x10)\r
+ for (let i = 0x70000000; i < 0x7000000f; i++) {\r
+ const a = accounts.get(i)\r
+ assert.exists(a)\r
+ assert.exists(a.address)\r
+ assert.exists(a.publicKey)\r
+ }\r
+\r
+ await assert.resolves(wallet.destroy())\r
+ })\r
+\r
+ await test('derive from restored Exodus wallet', async () => {\r
+ const wallet = await Wallet.load('Exodus', PASSWORD, BIP39_SEED_0)\r
+ const restored = await Wallet.restore(wallet.id)\r
+ await restored.unlock(PASSWORD)\r
+ const account = await restored.account()\r
+\r
+ assert.equal(account.publicKey, PUBLIC_0)\r
+ assert.equal(account.address, ADDRESS_0)\r
+\r
+ const accounts = await restored.accounts()\r
+ assert.exists(accounts.get(0))\r
+ assert.equal(account, accounts.get(0))\r
+\r
await assert.resolves(wallet.destroy())\r
await assert.resolves(restored.destroy())\r
})\r