]> zoso.dev Git - libnemo.git/commitdiff
Test additional accounts when deriving from BLAKE2b wallet. Test more BLAKE2b wallet...
authorChris Duncan <chris@zoso.dev>
Sun, 10 Nov 2024 21:25:03 +0000 (13:25 -0800)
committerChris Duncan <chris@zoso.dev>
Sun, 10 Nov 2024 21:25:03 +0000 (13:25 -0800)
test/import-wallet.test.mjs

index 960c70f480cabbd98ed2b3d139d7aee61e229bf1..7fd35f084e0c6daefc40b4517f5c38bfaf50c32b 100644 (file)
@@ -140,36 +140,60 @@ describe('import wallet with test vectors test', () => {
        it('should successfully import a BLAKE2b wallet with Trezor test vectors', async () => {\r
                const wallet = await Blake2bWallet.fromMnemonic(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                await wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD)\r
-               const accounts = await wallet.accounts()\r
+               const accounts = await wallet.accounts(0, 1)\r
 \r
                assert.ok('mnemonic' in wallet)\r
                assert.ok('seed' in wallet)\r
-               assert.ok(accounts[0] instanceof Account)\r
                assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
                assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
-               assert.equal(accounts[0].privateKey, TREZOR_TEST_VECTORS.NANOS_CC_PRIVATE_1)\r
-               assert.equal(accounts[0].publicKey, TREZOR_TEST_VECTORS.NANOS_CC_PUBLIC_1)\r
-               assert.equal(accounts[0].address, TREZOR_TEST_VECTORS.NANOS_CC_ADDRESS_1)\r
+               assert.ok(accounts[0] instanceof Account)\r
+               assert.equal(accounts[0].index, 0)\r
+               assert.equal(accounts[0].privateKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_0)\r
+               assert.equal(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_0)\r
+               assert.equal(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_0)\r
+               assert.ok(accounts[1] instanceof Account)\r
+               assert.equal(accounts[1].index, 1)\r
+               assert.equal(accounts[1].privateKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_1)\r
+               assert.equal(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1)\r
+               assert.equal(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1)\r
        })\r
 \r
        it('should get identical BLAKE2b wallets when created with a seed versus with its derived mnemonic', 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 wallet = await Blake2bWallet.fromSeed(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_2)\r
+               await wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD)\r
                const walletAccounts = await wallet.accounts()\r
+               const walletAccount = walletAccounts[0]\r
 \r
                assert.ok('mnemonic' in wallet)\r
                assert.ok('seed' in wallet)\r
-               assert.ok(walletAccounts[0])\r
-               assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
+               assert.ok(walletAccount)\r
+               assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_2)\r
 \r
-               const imported = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_0)\r
-               await imported.unlock(NANO_TEST_VECTORS.PASSWORD)\r
+               const imported = await Blake2bWallet.fromMnemonic(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_2)\r
+               await imported.unlock(TREZOR_TEST_VECTORS.PASSWORD)\r
                const importedAccounts = await imported.accounts()\r
+               const importedAccount = importedAccounts[0]\r
 \r
                assert.equal(imported.mnemonic, wallet.mnemonic)\r
                assert.equal(imported.seed, wallet.seed)\r
-               assert.equal(importedAccounts[0].privateKey, walletAccounts[0].privateKey)\r
-               assert.equal(importedAccounts[0].publicKey, walletAccounts[0].publicKey)\r
+               assert.equal(importedAccount.privateKey, walletAccount.privateKey)\r
+               assert.equal(importedAccount.publicKey, walletAccount.publicKey)\r
+       })\r
+\r
+       it('should get identical BLAKE2b wallets when created with max entropy value', async () => {\r
+               const wallet = await Blake2bWallet.fromMnemonic(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_3)\r
+               await wallet.unlock(TREZOR_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.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_3)\r
+               assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_3)\r
+               assert.equal(accounts[0].index, 0)\r
+               assert.equal(accounts[0].privateKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PRIVATE_0)\r
+               assert.equal(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0)\r
+               assert.equal(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0)\r
        })\r
 })\r
 \r