From: Chris Duncan Date: Fri, 6 Dec 2024 20:58:16 +0000 (-0800) Subject: Remove extra parent level test causing problems with awaiting actual test results. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=52c5a082bf2e8ce2bc443bcc876adf3cc9d0780a;p=libnemo.git Remove extra parent level test causing problems with awaiting actual test results. --- diff --git a/test/lock-unlock-wallet.mjs b/test/lock-unlock-wallet.mjs index af97840..5ce3a4e 100644 --- a/test/lock-unlock-wallet.mjs +++ b/test/lock-unlock-wallet.mjs @@ -7,242 +7,238 @@ import { assert, test } from '#GLOBALS.mjs' import { NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js' import { Bip44Wallet, Blake2bWallet } from '#dist/main.js' -test('locking and unlocking a Bip44Wallet', async () => { - test('should succeed with a password', async () => { - const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) - - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, '') - assert.equals(wallet.seed, '') - - const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - - assert.equals(unlockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should succeed with a random CryptoKey', 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 key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const lockResult = await wallet.lock(key) - - assert.ok(lockResult) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, '') - assert.equals(wallet.seed, '') - - const unlockResult = await wallet.unlock(key) - - assert.equals(unlockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should fail to unlock with different passwords', 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 lockResult = await wallet.lock(TREZOR_TEST_VECTORS.PASSWORD) - - await assert.rejects(wallet.unlock(NANO_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' }) - assert.equals(lockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should fail to unlock with different keys', 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 rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const lockResult = await wallet.lock(rightKey) - - await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' }) - assert.equals(lockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should fail to unlock with different valid inputs', async () => { - const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) - const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - - await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should fail with no input', 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) - - //@ts-expect-error - await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - - await wallet.lock('password') - - //@ts-expect-error - await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) - - test('should fail with invalid input', 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) - - //@ts-expect-error - await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - - await wallet.lock(NANO_TEST_VECTORS.PASSWORD) - - //@ts-expect-error - await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - }) +test('locking and unlocking a Bip44Wallet with a password', async () => { + const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) + + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, '') + assert.equals(wallet.seed, '') + + const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + assert.equals(unlockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('locking and unlocking a Bip44Wallet with a random CryptoKey', 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 key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const lockResult = await wallet.lock(key) + + assert.ok(lockResult) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, '') + assert.equals(wallet.seed, '') + + const unlockResult = await wallet.unlock(key) + + assert.equals(unlockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('fail to unlock a Bip44Wallet with different passwords', 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 lockResult = await wallet.lock(TREZOR_TEST_VECTORS.PASSWORD) + + await assert.rejects(wallet.unlock(NANO_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' }) + assert.equals(lockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('fail to unlock a Bip44Wallet with different keys', 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 rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const lockResult = await wallet.lock(rightKey) + + await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' }) + assert.equals(lockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('fail to unlock a Bip44Wallet with different valid inputs', async () => { + const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD) + const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + + await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('fail to unlock a Bip44Wallet with no input', 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) + + //@ts-expect-error + await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) + + await wallet.lock('password') + + //@ts-expect-error + await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('fail to unlock a Bip44Wallet with invalid input', 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) + + //@ts-expect-error + await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) + + await wallet.lock(NANO_TEST_VECTORS.PASSWORD) + + //@ts-expect-error + await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) +}) + +test('locking and unlocking a Blake2bWallet with a password', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0) + + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, '') + assert.equals(wallet.seed, '') + + const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + assert.equals(unlockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) + assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) +}) + +test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const lockResult = await wallet.lock(key) + + assert.equals(lockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, '') + assert.equals(wallet.seed, '') + + const unlockResult = await wallet.unlock(key) + + assert.equals(lockResult, true) + assert.equals(unlockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) +}) + +test('fail to unlock a Blake2bWallet with different passwords', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + + await assert.rejects(wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) +}) + +test('fail to unlock a Blake2bWallet with different keys', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + const lockResult = await wallet.lock(rightKey) + + await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' }) + assert.equals(lockResult, true) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) +}) + +test('fail to unlock a Blake2bWallet with different valid inputs', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) + + await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) +}) + +test('fail to unlock a Blake2bWallet with no input', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + //@ts-expect-error + await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) + + await wallet.lock(NANO_TEST_VECTORS.PASSWORD) + + //@ts-expect-error + await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) }) -test('locking and unlocking a Blake2bWallet', async () => { - test('should succeed with a password', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0) - - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, '') - assert.equals(wallet.seed, '') - - const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - - assert.equals(unlockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) - assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) - }) - - test('should succeed with a random CryptoKey', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const lockResult = await wallet.lock(key) - - assert.equals(lockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, '') - assert.equals(wallet.seed, '') - - const unlockResult = await wallet.unlock(key) - - assert.equals(lockResult, true) - assert.equals(unlockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) - - test('should fail to unlock with different passwords', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - - await assert.rejects(wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) - - test('should fail to unlock with different keys', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const wrongKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - const lockResult = await wallet.lock(rightKey) - - await assert.rejects(wallet.unlock(wrongKey), { message: 'Failed to unlock wallet' }) - assert.equals(lockResult, true) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) - - test('should fail to unlock with different valid inputs', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']) - - await assert.rejects(wallet.unlock(key), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) - - test('should fail with no input', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - - //@ts-expect-error - await assert.rejects(wallet.lock(), { message: 'Failed to lock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - - await wallet.lock(NANO_TEST_VECTORS.PASSWORD) - - //@ts-expect-error - await assert.rejects(wallet.unlock(), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) - - test('should fail with invalid input', async () => { - const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) - await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - - //@ts-expect-error - await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - - await wallet.lock(NANO_TEST_VECTORS.PASSWORD) - - //@ts-expect-error - await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' }) - assert.ok('mnemonic' in wallet) - assert.ok('seed' in wallet) - assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) - assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) - }) +test('fail to unlock a Blake2bWallet with invalid input', async () => { + const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1) + await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + //@ts-expect-error + await assert.rejects(wallet.lock(1), { message: 'Failed to lock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) + + await wallet.lock(NANO_TEST_VECTORS.PASSWORD) + + //@ts-expect-error + await assert.rejects(wallet.unlock(1), { message: 'Failed to unlock wallet' }) + assert.ok('mnemonic' in wallet) + assert.ok('seed' in wallet) + assert.notEqual(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) })