import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
-test('BIP-44 ckd performance test', async () => {
+await test('BIP-44 ckd performance test', async () => {
const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
assert.equals(accounts.length, 0x8000)
})
-test('BLAKE2b ckd performance test', async () => {
+await test('BLAKE2b ckd performance test', async () => {
const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
-test('creating BIP-44 wallets performance test', async () => {
+await test('creating BIP-44 wallets performance test', async () => {
const wallets = []
for (let i = 0x80; i > 0; i--) {
wallets.push(await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD))
assert.equals(wallets.length, 0x80)
})
-test('creating BLAKE2b wallets performance test', async () => {
+await test('creating BLAKE2b wallets performance test', async () => {
const wallets = []
for (let i = 0x80; i > 0; i--) {
wallets.push(await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD))
import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '#dist/main.js'\r
\r
-test('BIP-44 wallet with random entropy', async () => {\r
+await test('BIP-44 wallet with random entropy', async () => {\r
const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
})\r
\r
-test('BLAKE2b wallet with random entropy', async () => {\r
+await test('BLAKE2b wallet with random entropy', async () => {\r
const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
})\r
\r
-test('BIP-44 replace invalid salt with empty string', async () => {\r
+await test('BIP-44 replace invalid salt with empty string', async () => {\r
const invalidArgs = [null, true, false, 0, 1, 2, { "foo": "bar" }]\r
for (const arg of invalidArgs) {\r
//@ts-expect-error\r
}\r
})\r
\r
-test('fail when using new', () => {\r
+await test('fail when using new', () => {\r
//@ts-expect-error\r
assert.throws(() => new Bip44Wallet())\r
//@ts-expect-error\r
assert.throws(() => new LedgerWallet())\r
})\r
\r
-test('fail without a password', async () => {\r
+await test('fail without a password', async () => {\r
//@ts-expect-error\r
await assert.rejects(Bip44Wallet.create())\r
//@ts-expect-error\r
import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '#dist/main.js'\r
\r
-test('should derive the first account from the given BIP-44 seed', async () => {\r
+await test('should derive the first account from the given BIP-44 seed', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
-test('should derive low indexed accounts from the given BIP-44 seed', async () => {\r
+await test('should derive low indexed accounts from the given BIP-44 seed', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(1, 2)\r
assert.equals(accounts[1].address, NANO_TEST_VECTORS.ADDRESS_2)\r
})\r
\r
-test('should derive high indexed accounts from the given seed', async () => {\r
+await test('should derive high indexed accounts from the given seed', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0x70000000, 0x700000ff)\r
}\r
})\r
\r
-test('should derive accounts for a BLAKE2b wallet', async () => {\r
+await test('should derive accounts for a BLAKE2b wallet', async () => {\r
const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const lowAccounts = await wallet.accounts(0, 2)\r
import { BIP32_TEST_VECTORS, CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Account, Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
\r
-test('import a wallet with the official Nano test vectors mnemonic', async () => {\r
+await test('import a wallet with the official Nano test vectors mnemonic', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
-test('import a wallet with the checksum starting with a zero', async () => {\r
+await test('import a wallet with the checksum starting with a zero', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, 'food define cancel major spoon trash cigar basic aim bless wolf win ability seek paddle bench seed century group they mercy address monkey cake')\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
assert.equals(wallet.seed, 'F665F804E5907985455D1E5A7AD344843A2ED4179A7E06EEF263DE925FF6F4C0991B0A9344FCEE939FE0F1B1841B8C9B20FEACF6B954B74B2D26A01906B758E2')\r
})\r
\r
-test('import a wallet with a 12-word phrase', async () => {\r
+await test('import a wallet with a 12-word phrase', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_0)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
-test('import a wallet with a 15-word phrase', async () => {\r
+await test('import a wallet with a 15-word phrase', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1)\r
})\r
\r
-test('import a wallet with a 18-word phrase', async () => {\r
+await test('import a wallet with a 18-word phrase', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_2)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2)\r
})\r
\r
-test('import a wallet with a 21-word phrase', async () => {\r
+await test('import a wallet with a 21-word phrase', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, CUSTOM_TEST_VECTORS.ENTROPY_3)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3)\r
})\r
\r
-test('import a wallet with the official Nano test vectors seed', async () => {\r
+await test('import a wallet with the official Nano test vectors seed', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, NANO_TEST_VECTORS.ADDRESS_0)\r
})\r
\r
-test('import a BIP-44 wallet with the zero seed', async () => {\r
+await test('import a BIP-44 wallet with the zero seed', async () => {\r
const wallet = await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0, TREZOR_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0, 3)\r
}\r
})\r
\r
-test('import a BLAKE2b wallet with the zero seed', async () => {\r
+await test('import a BLAKE2b wallet with the zero seed', 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 accounts = await wallet.accounts(0, 3)\r
}\r
})\r
\r
-test('import a BLAKE2b wallet with Trezor test vectors', async () => {\r
+await test('import a BLAKE2b wallet with Trezor test vectors', async () => {\r
const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts(0, 1)\r
assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1)\r
})\r
\r
-test('get identical BLAKE2b wallets when created with a seed versus with its derived mnemonic', async () => {\r
+await test('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_2)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const walletAccounts = await wallet.accounts()\r
assert.equals(importedAccount.publicKey, walletAccount.publicKey)\r
})\r
\r
-test('get identical BLAKE2b wallets when created with max entropy value', async () => {\r
+await test('get identical BLAKE2b wallets when created with max entropy value', async () => {\r
const wallet = await Blake2bWallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_3)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0)\r
})\r
\r
-test('reject when given invalid entropy', async () => {\r
+await test('reject when given invalid entropy', async () => {\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C797'))\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C79701'))\r
await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0.replaceAll(/./g, 'x')))\r
})\r
\r
-test('reject when given a seed with an invalid length', async () => {\r
+await test('reject when given a seed with an invalid length', async () => {\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED + 'f'),\r
`Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length + 1}-character string.`)\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED.slice(0, -1)),\r
`Expected a ${NANO_TEST_VECTORS.BIP39_SEED.length}-character seed, but received ${NANO_TEST_VECTORS.BIP39_SEED.length - 1}-character string.`)\r
})\r
\r
-test('reject when given a seed containing non-hex characters', async () => {\r
+await test('reject when given a seed containing non-hex characters', async () => {\r
await assert.rejects(Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.SEED_0.replace(/./, 'g')),\r
'Seed contains invalid hexadecimal characters.')\r
await assert.rejects(Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1.replace(/./, 'g')),\r
})\r
\r
\r
-test('retrieve a Bip44Wallet from storage using an ID', async () => {\r
+await test('retrieve a Bip44Wallet from storage using an ID', async () => {\r
const id = (await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)).id\r
const wallet = await Bip44Wallet.restore(id)\r
\r
assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('retrieve a Blake2bWallet from storage using an ID', async () => {\r
+await test('retrieve a Blake2bWallet from storage using an ID', async () => {\r
const id = (await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)).id\r
const wallet = await Blake2bWallet.restore(id)\r
\r
import { NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
\r
-test('locking and unlocking a Bip44Wallet with a password', async () => {\r
+await test('locking and unlocking a Bip44Wallet with a password', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.ok('mnemonic' in wallet)\r
assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('locking and unlocking a Bip44Wallet with a random CryptoKey', async () => {\r
+await test('locking and unlocking a Bip44Wallet with a random CryptoKey', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('fail to unlock a Bip44Wallet with different passwords', async () => {\r
+await test('fail to unlock a Bip44Wallet with different passwords', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const lockResult = await wallet.lock(TREZOR_TEST_VECTORS.PASSWORD)\r
assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('fail to unlock a Bip44Wallet with different keys', async () => {\r
+await test('fail to unlock a Bip44Wallet with different keys', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('fail to unlock a Bip44Wallet with different valid inputs', async () => {\r
+await test('fail to unlock a Bip44Wallet with different valid inputs', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
\r
assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('fail to unlock a Bip44Wallet with no input', async () => {\r
+await test('fail to unlock a Bip44Wallet with no input', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('fail to unlock a Bip44Wallet with invalid input', async () => {\r
+await test('fail to unlock a Bip44Wallet with invalid input', async () => {\r
const wallet = await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.notEqual(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED)\r
})\r
\r
-test('locking and unlocking a Blake2bWallet with a password', async () => {\r
+await test('locking and unlocking a Blake2bWallet with a password', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0)\r
\r
assert.ok('mnemonic' in wallet)\r
assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0)\r
})\r
\r
-test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => {\r
+await test('locking and unlocking a Blake2bWallet with a random CryptoKey', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('fail to unlock a Blake2bWallet with different passwords', async () => {\r
+await test('fail to unlock a Blake2bWallet with different passwords', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
\r
await assert.rejects(wallet.unlock(TREZOR_TEST_VECTORS.PASSWORD), { message: 'Failed to unlock wallet' })\r
assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('fail to unlock a Blake2bWallet with different keys', async () => {\r
+await test('fail to unlock a Blake2bWallet with different keys', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const rightKey = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('fail to unlock a Blake2bWallet with different valid inputs', async () => {\r
+await test('fail to unlock a Blake2bWallet with different valid inputs', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
const key = await globalThis.crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])\r
\r
assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('fail to unlock a Blake2bWallet with no input', async () => {\r
+await test('fail to unlock a Blake2bWallet with no input', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
assert.notEqual(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1)\r
})\r
\r
-test('fail to unlock a Blake2bWallet with invalid input', async () => {\r
+await test('fail to unlock a Blake2bWallet with invalid input', async () => {\r
const wallet = await Blake2bWallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_1)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
\r
console.log('> rolodex valid contact management <')
-test('should create a rolodex and add two contacts', async () => {
+await test('should create a rolodex and add two contacts', async () => {
const rolodex = new Rolodex()
assert.equals(rolodex.constructor, Rolodex)
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
assert.equals(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_1)
})
-test('should get a name from an address', async () => {
+await test('should get a name from an address', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
assert.equals(rolodex.getName(NANO_TEST_VECTORS.ADDRESS_0), 'JohnDoe')
})
-test('should add three addresses to the same contact', async () => {
+await test('should add three addresses to the same contact', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_1)
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_2)
assert.equals(rolodex.getAddresses('JohnDoe')[2], NANO_TEST_VECTORS.ADDRESS_0)
})
-test('should update the name on an existing entry', async () => {
+await test('should update the name on an existing entry', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
await rolodex.add('JaneSmith', NANO_TEST_VECTORS.ADDRESS_0)
assert.equals(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_0)
})
-test('should return empty address array for an unknown contact', async () => {
+await test('should return empty address array for an unknown contact', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
assert.equals(Array.isArray(rolodex.getAddresses('JaneSmith')), true)
assert.equals(rolodex.getAddresses('JaneSmith').length, 0)
})
-test('should return empty address array for blank contact names', () => {
+await test('should return empty address array for blank contact names', () => {
const rolodex = new Rolodex()
//@ts-expect-error
assert.equals(Array.isArray(rolodex.getAddresses(undefined)), true)
assert.equals(rolodex.getAddresses('').length, 0)
})
-test('should return null for an unknown address', async () => {
+await test('should return null for an unknown address', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
assert.ok(rolodex.getName(NANO_TEST_VECTORS.ADDRESS_1) === null)
assert.ok(rolodex.getName(NANO_TEST_VECTORS.ADDRESS_1) !== undefined)
})
-test('should return null for a blank address', async () => {
+await test('should return null for a blank address', async () => {
const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
//@ts-expect-error
console.log('> rolodex exceptions <')
-test('should throw if adding no data', async () => {
+await test('should throw if adding no data', async () => {
const rolodex = new Rolodex()
//@ts-expect-error
await assert.rejects(rolodex.add())
})
-test('should throw if passed no address', async () => {
+await test('should throw if passed no address', async () => {
const rolodex = new Rolodex()
//@ts-expect-error
await assert.rejects(rolodex.add('JohnDoe'))
await assert.rejects(rolodex.add('JohnDoe', ''))
})
-test('should throw if name is blank', async () => {
+await test('should throw if name is blank', async () => {
const rolodex = new Rolodex()
//@ts-expect-error
await assert.rejects(rolodex.add(undefined, NANO_TEST_VECTORS.ADDRESS_0))
console.log('> rolodex data signature verification <')
-test('should verify valid data and signature', async () => {
+await test('should verify valid data and signature', async () => {
const data = 'Test data'
const signature = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, data)
const rolodex = new Rolodex()
assert.equals(result, true)
})
-test('should reject incorrect contact for signature', async () => {
+await test('should reject incorrect contact for signature', async () => {
const data = 'Test data'
const signature = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, data)
const rolodex = new Rolodex()
console.log('refreshing account info')
-test('fetch balance, frontier, and representative', async () => {
+await test('fetch balance, frontier, and representative', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.accounts()
assert.notEqual(account.representative?.address, '')
})
-test('throw when refreshing unopened account', async () => {
+await test('throw when refreshing unopened account', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.accounts(0x7fffffff)
{ message: 'Account not found' })
})
-test('throw when referencing invalid account index', async () => {
+await test('throw when referencing invalid account index', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.rejects(wallet.accounts(0x80000000),
{ message: 'Invalid child key index 0x80000000' })
})
-test('throw with invalid node', async () => {
+await test('throw with invalid node', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const invalidNode = new Rpc('http://invalid.com')
console.log('finding next unopened account')
-test('return correct account from test vector', async () => {
+await test('return correct account from test vector', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc)
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
})
-test('return successfully for small batch size', async () => {
+await test('return successfully for small batch size', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc, 1)
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
})
-test('return successfully for large batch size', async () => {
+await test('return successfully for large batch size', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc, 100)
assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
})
-test('should throw on invalid node URL', async () => {
+await test('should throw on invalid node URL', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
await assert.rejects(wallet.getNextNewAccount('foo'))
})
-test('should throw on invalid batch size', async () => {
+await test('should throw on invalid batch size', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
\r
console.log('> valid blocks <')\r
\r
-test('should not allow negative balances', async () => {\r
+await test('should not allow negative balances', async () => {\r
assert.throws(() => {\r
const block = new SendBlock(\r
NANO_TEST_VECTORS.ADDRESS_0,\r
}, { message: 'Negative balance' })\r
})\r
\r
-test('should allow zero balances', async () => {\r
+await test('should allow zero balances', async () => {\r
const block = new SendBlock(\r
NANO_TEST_VECTORS.ADDRESS_0,\r
'9007199254740991',\r
assert.equals(block.balance, BigInt(0))\r
})\r
\r
-test('should subtract balance from SendBlock correctly', async () => {\r
+await test('should subtract balance from SendBlock correctly', async () => {\r
const block = new SendBlock(\r
NANO_TEST_VECTORS.ADDRESS_0,\r
'3000000000000000000000000000000',\r
assert.equals(block.balance, 1000000000000000000000000000000n)\r
})\r
\r
-test('should add balance from ReceiveBlock correctly', async () => {\r
+await test('should add balance from ReceiveBlock correctly', async () => {\r
const block = new ReceiveBlock(\r
NANO_TEST_VECTORS.ADDRESS_0,\r
'2000000000000000000000000000000',\r
\r
console.log('> block signing tests using official test vectors <')\r
\r
-test('should create a valid signature for an open block', async () => {\r
+await test('should create a valid signature for an open block', async () => {\r
const block = new ReceiveBlock(\r
NANO_TEST_VECTORS.OPEN_BLOCK.account,\r
'0',\r
assert.equals(block.signature, NANO_TEST_VECTORS.OPEN_BLOCK.signature)\r
})\r
\r
-test('should create a valid signature for a receive block', async () => {\r
+await test('should create a valid signature for a receive block', async () => {\r
const block = new ReceiveBlock(\r
NANO_TEST_VECTORS.RECEIVE_BLOCK.account,\r
NANO_TEST_VECTORS.RECEIVE_BLOCK.balance,\r
assert.equals(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature)\r
})\r
\r
-test('should create a valid signature for a receive block without work', async () => {\r
+await test('should create a valid signature for a receive block without work', async () => {\r
const block = new ReceiveBlock(\r
NANO_TEST_VECTORS.RECEIVE_BLOCK.account,\r
NANO_TEST_VECTORS.RECEIVE_BLOCK.balance,\r
assert.equals(block.work, '')\r
})\r
\r
-test('should create a valid signature for a send block', async () => {\r
+await test('should create a valid signature for a send block', async () => {\r
const block = new SendBlock(\r
NANO_TEST_VECTORS.SEND_BLOCK.account,\r
NANO_TEST_VECTORS.SEND_BLOCK.balance,\r
assert.equals(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature)\r
})\r
\r
-test('should create a valid signature for a send block without work', async () => {\r
+await test('should create a valid signature for a send block without work', async () => {\r
const block = new SendBlock(\r
NANO_TEST_VECTORS.SEND_BLOCK.account,\r
NANO_TEST_VECTORS.SEND_BLOCK.balance,\r
assert.equals(block.work, '')\r
})\r
\r
-test('should create a valid signature for a change rep block', async () => {\r
+await test('should create a valid signature for a change rep block', async () => {\r
const work = '0000000000000000'\r
const block = new ChangeBlock(\r
'nano_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',\r
assert.equals(block.work, work)\r
})\r
\r
-test('should create a valid signature for a change rep block without work', async () => {\r
+await test('should create a valid signature for a change rep block without work', async () => {\r
const block = new ChangeBlock(\r
NANO_TEST_VECTORS.ADDRESS_0,\r
'0',\r
\r
console.log('> unit conversion tests <')\r
\r
-test('should convert nano to raw', async () => {\r
+await test('should convert nano to raw', async () => {\r
const result = await Tools.convert('1', 'NANO', 'RAW')\r
assert.equals(result, '1000000000000000000000000000000')\r
})\r
\r
-test('should convert raw to nano', async () => {\r
+await test('should convert raw to nano', async () => {\r
const result = await Tools.convert('1000000000000000000000000000000', 'RAW', 'NANO')\r
assert.equals(result, '1')\r
})\r
\r
-test('should convert 1 raw to 10^-29 nano', async () => {\r
+await test('should convert 1 raw to 10^-29 nano', async () => {\r
const result = await Tools.convert('1', 'RAW', 'NANO')\r
assert.equals(result, '.000000000000000000000000000001')\r
})\r
\r
-test('should ignore leading and trailing zeros', async () => {\r
+await test('should ignore leading and trailing zeros', async () => {\r
const result = await Tools.convert('0011002200.0033004400', 'nano', 'nano')\r
assert.equals(result, '11002200.00330044')\r
})\r
\r
-test('should convert raw to nyano', async () => {\r
+await test('should convert raw to nyano', async () => {\r
const result = await Tools.convert(RAW_MAX, 'RAW', 'NYANO')\r
assert.equals(result, '340282366920938.463463374607431768211455')\r
})\r
\r
-test('should convert case-insensitive nyano to raw', async () => {\r
+await test('should convert case-insensitive nyano to raw', async () => {\r
const result = await Tools.convert('0.000000000000000123456789', 'nYaNo', 'rAw')\r
assert.equals(result, '123456789')\r
})\r
\r
-test('should convert nano to pico', async () => {\r
+await test('should convert nano to pico', async () => {\r
const result = await Tools.convert('123.456', 'nano', 'pico')\r
assert.equals(result, '123456')\r
})\r
\r
-test('should convert knano to pico', async () => {\r
+await test('should convert knano to pico', async () => {\r
const result = await Tools.convert('123.456', 'nano', 'pico')\r
assert.equals(result, '123456')\r
})\r
\r
-test('should throw if amount exceeds raw max', async () => {\r
+await test('should throw if amount exceeds raw max', async () => {\r
await assert.rejects(Tools.convert(RAW_MAX, 'NANO', 'RAW'),\r
{ message: 'Amount exceeds Nano limits' })\r
})\r
\r
-test('should throw if amount exceeds raw min', async () => {\r
+await test('should throw if amount exceeds raw min', async () => {\r
await assert.rejects(Tools.convert('0.1', 'RAW', 'NANO'),\r
{ message: 'Amount must be at least 1 raw' })\r
})\r
\r
-test('should throw if amount is blank', async () => {\r
+await test('should throw if amount is blank', async () => {\r
await assert.rejects(Tools.convert('', 'RAW', 'NANO'),\r
{ message: 'Invalid amount' })\r
})\r
\r
-test('should throw if amount has non-digit characters', async () => {\r
+await test('should throw if amount has non-digit characters', async () => {\r
await assert.rejects(Tools.convert('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 'RAW', 'NANO'),\r
{ message: 'Invalid amount' })\r
})\r
\r
console.log('> signature tests <')\r
\r
-test('should sign data with a single parameter', async () => {\r
+await test('should sign data with a single parameter', async () => {\r
const result = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, 'miro@metsanheimo.fi')\r
assert.equals(result, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C')\r
})\r
\r
-test('should sign data with multiple parameters', async () => {\r
+await test('should sign data with multiple parameters', async () => {\r
const result = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, 'miro@metsanheimo.fi', 'somePassword')\r
assert.equals(result, 'BB534F9B469AF451B1941FFEF8EE461FC5D284B5D393140900C6E13A65EF08D0AE2BC77131EE182922F66C250C7237A83878160457D5C39A70E55F7FCE925804')\r
})\r
\r
-test('should verify a signature using the public key', async () => {\r
+await test('should verify a signature using the public key', async () => {\r
const result = await Tools.verify(NANO_TEST_VECTORS.PUBLIC_0, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C', 'miro@metsanheimo.fi')\r
assert.equals(result, true)\r
\r
assert.equals(result3, false)\r
})\r
\r
-test('should verify a block using the public key', async () => {\r
+await test('should verify a block using the public key', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(valid, true)\r
})\r
\r
-test('should reject a block using the wrong public key', async () => {\r
+await test('should reject a block using the wrong public key', async () => {\r
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
assert.equals(valid, false)\r
})\r
\r
-test('sweeper throws without required parameters', async () => {\r
+await test('sweeper throws without required parameters', async () => {\r
//@ts-expect-error\r
await assert.rejects(Tools.sweep(),\r
'Missing required sweep arguments')\r