From 517d92dbd4f0bc00f1b8ffebfc18b78f0958bcdd Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 19 Jul 2025 14:51:44 -0700 Subject: [PATCH] Use dev package to test IndexedDB calls in node. Configure workers to use worker threads in node. Update equality assertion to match node test runner calls. Use test runner test functions in node environment. --- esbuild-common.mjs | 1 + package-lock.json | 11 +++ package.json | 1 + src/lib/workers/bip44-ckd.ts | 11 ++- src/lib/workers/nano-nacl.ts | 31 ++++--- src/lib/workers/queue.ts | 21 +++-- src/lib/workers/safe.ts | 20 +++-- src/lib/workers/worker-interface.ts | 23 ++++-- test/GLOBALS.mjs | 107 ++++++++++++------------ test/test.blake2b.mjs | 4 +- test/test.blocks.mjs | 38 ++++----- test/test.calculate-pow.mjs | 8 +- test/test.derive-accounts.mjs | 64 +++++++-------- test/test.import-wallet.mjs | 122 ++++++++++++++-------------- test/test.ledger.mjs | 46 +++++------ test/test.lock-unlock.mjs | 70 ++++++++-------- test/test.manage-rolodex.mjs | 52 ++++++------ test/test.refresh-accounts.mjs | 24 +++--- test/test.tools.mjs | 32 ++++---- 19 files changed, 363 insertions(+), 323 deletions(-) diff --git a/esbuild-common.mjs b/esbuild-common.mjs index ced85d9..3966def 100644 --- a/esbuild-common.mjs +++ b/esbuild-common.mjs @@ -6,6 +6,7 @@ */ export const options = { bundle: true, + platform: 'browser', entryPoints: [ { in: './src/main.ts', out: 'main.min' }, { in: './src/types.d.ts', out: 'types.d' } diff --git a/package-lock.json b/package-lock.json index eb12a8c..341a9be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@types/w3c-web-usb": "^1.0.10", "@types/web-bluetooth": "^0.0.21", "esbuild": "^0.25.5", + "fake-indexeddb": "^6.0.1", "typescript": "^5.8.3" }, "funding": { @@ -1142,6 +1143,16 @@ "@types/yauzl": "^2.9.1" } }, + "node_modules/fake-indexeddb": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fake-indexeddb/-/fake-indexeddb-6.0.1.tgz", + "integrity": "sha512-He2AjQGHe46svIFq5+L2Nx/eHDTI1oKgoevBP+TthnjymXiKkeJQ3+ITeWey99Y5+2OaPFbI1qEsx/5RsGtWnQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", diff --git a/package.json b/package.json index 59d5519..9fb9b43 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@types/w3c-web-usb": "^1.0.10", "@types/web-bluetooth": "^0.0.21", "esbuild": "^0.25.5", + "fake-indexeddb": "^6.0.1", "typescript": "^5.8.3" }, "type": "module", diff --git a/src/lib/workers/bip44-ckd.ts b/src/lib/workers/bip44-ckd.ts index 2957ca1..2076cca 100644 --- a/src/lib/workers/bip44-ckd.ts +++ b/src/lib/workers/bip44-ckd.ts @@ -45,9 +45,9 @@ export class Bip44Ckd extends WorkerInterface { * Derives a private child key following the BIP-32 and BIP-44 derivation path * registered to the Nano block lattice. Only hardened child keys are defined. * - * @param {string} seed - Hexadecimal seed derived from mnemonic phrase + * @param {ArrayBuffer} seed - Hexadecimal seed derived from mnemonic phrase * @param {number} index - Account number between 0 and 2^31-1 - * @returns {Promise} Private child key for the account + * @returns {Promise} Private child key for the account */ static async nanoCKD (seed: ArrayBuffer, index: number): Promise { return await this.ckd(seed, this.BIP44_COIN_NANO, index) @@ -58,10 +58,10 @@ export class Bip44Ckd extends WorkerInterface { * BIP-44 derivation path. Purpose is always 44'. Coin defaults to Nano. Only * hardened child keys are defined. * - * @param {string} seed - Hexadecimal seed derived from mnemonic phrase + * @param {ArrayBuffer} seed - Hexadecimal seed derived from mnemonic phrase * @param {number} coin - Number registered to a specific coin in SLIP-044 * @param {number} index - Account number between 0 and 2^31-1 - * @returns {Promise} Private child key for the account + * @returns {Promise} Private child key for the account */ static async ckd (seed: ArrayBuffer, coin: number = this.BIP44_COIN_NANO, index: number): Promise { if (seed.byteLength < 16 || seed.byteLength > 64) { @@ -128,7 +128,10 @@ export class Bip44Ckd extends WorkerInterface { } } +let importWorkerThreads = '' +NODE: importWorkerThreads = `import { parentPort } from 'node:worker_threads'` export default ` + ${importWorkerThreads} const WorkerInterface = ${WorkerInterface} const Bip44Ckd = ${Bip44Ckd} ` diff --git a/src/lib/workers/nano-nacl.ts b/src/lib/workers/nano-nacl.ts index efe6a7b..d6b1ed1 100644 --- a/src/lib/workers/nano-nacl.ts +++ b/src/lib/workers/nano-nacl.ts @@ -32,19 +32,23 @@ export class NanoNaCl extends WorkerInterface { const privateKey = new Uint8Array(data.privateKey) const publicKey = new Uint8Array(data.publicKey) const signature = new Uint8Array(data.signature) - switch (method) { - case 'convert': { - return bytes.toHex(await this.convert(privateKey)) - } - case 'detached': { - return bytes.toHex(await this.detached(msg, privateKey)) - } - case 'verify': { - return await this.verify(msg, signature, publicKey) - } - default: { - throw new TypeError(`unknown NanoNaCl method ${method}`) + try { + switch (method) { + case 'convert': { + return bytes.toHex(await this.convert(privateKey)) + } + case 'detached': { + return bytes.toHex(await this.detached(msg, privateKey)) + } + case 'verify': { + return await this.verify(msg, signature, publicKey) + } + default: { + throw new TypeError(`unknown NanoNaCl method ${method}`) + } } + } catch (err) { + throw new Error(`NanoNaCl worker failed on ${method ?? 'unknown method'}`, { cause: err }) } } @@ -589,7 +593,10 @@ export class NanoNaCl extends WorkerInterface { } } +let importWorkerThreads = '' +NODE: importWorkerThreads = `import { parentPort } from 'node:worker_threads'` export default ` + ${importWorkerThreads} ${Convert} const Blake2b = ${Blake2b} const WorkerInterface = ${WorkerInterface} diff --git a/src/lib/workers/queue.ts b/src/lib/workers/queue.ts index 29770d0..5a49dac 100644 --- a/src/lib/workers/queue.ts +++ b/src/lib/workers/queue.ts @@ -26,7 +26,7 @@ export class Queue { #isIdle: boolean #queue: Task[] = [] #url: string - #worker: Worker + #worker: Worker | NodeWorker /** * Creates a Web Worker from a stringified script. @@ -42,21 +42,23 @@ export class Queue { BROWSER: this.#worker.addEventListener('message', message => { this.#report(message.data) }) - //@ts-expect-error - NODE: this.#worker = new NodeWorker(worker, { type: 'module', eval: true }) - //@ts-expect-error - NODE: this.#worker.addListener('message', message => { - this.#report(message.data) + NODE: this.#worker = new NodeWorker(worker, { + eval: true, + stderr: false, + stdout: false + }) + NODE: this.#worker.on('message', message => { + this.#report(message) }) Queue.#instances.push(this) } async assign (headers: Headers | null, data?: Data): Promise { - return await this.#assign(task => this.#queue.push(task), headers, data) + return this.#assign(task => this.#queue.push(task), headers, data) } async prioritize (headers: Headers | null, data?: Data): Promise { - return await this.#assign(task => this.#queue.unshift(task), headers, data) + return this.#assign(task => this.#queue.unshift(task), headers, data) } terminate (): void { @@ -90,7 +92,8 @@ export class Queue { buffers.push(data[d]) } } - this.#worker.postMessage({ headers, data }, buffers) + BROWSER: this.#worker.postMessage({ headers, data }, buffers) + NODE: this.#worker.postMessage({ data: { headers, data } }, buffers) } catch (err) { reject(err) } diff --git a/src/lib/workers/safe.ts b/src/lib/workers/safe.ts index 13bf0f6..824599e 100644 --- a/src/lib/workers/safe.ts +++ b/src/lib/workers/safe.ts @@ -22,10 +22,10 @@ export class Safe extends WorkerInterface { this.listen() } - static async work (headers: Headers, data: Data): Promise { + static async work (headers: Headers, data: Data): Promise { const { method, name, store } = headers - const { password } = data - delete data.password + const password = data?.password + if (data != null) delete data.password this.#storage = await this.#open(this.DB_NAME) let result try { @@ -43,12 +43,12 @@ export class Safe extends WorkerInterface { break } default: { - result = `unknown Safe method ${method}` + throw new Error(`unknown Safe method ${method}`) } } } catch (err) { console.log(err) - result = false + throw new Error('Safe error', { cause: err }) } return result } @@ -103,7 +103,7 @@ export class Safe extends WorkerInterface { /** * Retrieves data from the Safe and decrypts it with a password byte array. */ - static async get (name: string | string[] | unknown, store: string | unknown, password: ArrayBuffer | unknown): Promise { + static async get (name: string | string[] | unknown, store: string | unknown, password: ArrayBuffer | unknown): Promise { const names = Array.isArray(name) ? name : [name] if (names.some(v => typeof v !== 'string')) { throw new Error('Invalid fields') @@ -132,7 +132,7 @@ export class Safe extends WorkerInterface { return results } catch (err) { console.log(err) - return null + throw new Error('Failed to get records', { cause: err }) } finally { bytes.erase(password) } @@ -230,7 +230,13 @@ export class Safe extends WorkerInterface { } } +let importWorkerThreads = '' +let importFakeIndexedDb = '' +NODE: importWorkerThreads = `import { parentPort } from 'node:worker_threads'` +NODE: importFakeIndexedDb = `import 'fake-indexeddb/auto'` export default ` + ${importWorkerThreads} + ${importFakeIndexedDb} ${Convert} const PBKDF2_ITERATIONS = ${PBKDF2_ITERATIONS} const Entropy = ${Entropy} diff --git a/src/lib/workers/worker-interface.ts b/src/lib/workers/worker-interface.ts index 13e722d..9b801e6 100644 --- a/src/lib/workers/worker-interface.ts +++ b/src/lib/workers/worker-interface.ts @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2025 Chris Duncan // SPDX-License-Identifier: GPL-3.0-or-later +import { parentPort } from 'node:worker_threads' import { Data, Headers } from '#types' /** @@ -21,6 +22,9 @@ import { Data, Headers } from '#types' */ export abstract class WorkerInterface { static parentPort: any + static { + NODE: this.parentPort = parentPort + } /** * Processes data through a worker. * @@ -33,7 +37,6 @@ export abstract class WorkerInterface { * @returns Promise for processed data */ static async work (headers: Headers | null, data?: Data): Promise { - NODE: this.parentPort = (await import('node:worker_threads')).parentPort return new Promise(async (resolve, reject): Promise => { try { let x, y = new ArrayBuffer(0) @@ -59,13 +62,21 @@ export abstract class WorkerInterface { */ static report (results: Headers): void { const buffers = [] - for (const d of Object.keys(results)) { - if (results[d] instanceof ArrayBuffer) { - buffers.push(results[d]) + try { + if (typeof results === 'object') { + for (const d of Object.keys(results)) { + if (results[d] instanceof ArrayBuffer) { + buffers.push(results[d]) + } + } } + } catch (err) { + console.error(err) + throw new Error('Failed to report results', { cause: err }) } //@ts-expect-error - postMessage(results, buffers) + BROWSER: postMessage(results, buffers) + NODE: parentPort?.postMessage(results, buffers) } /** @@ -79,7 +90,7 @@ export abstract class WorkerInterface { * ``` */ static listen (): void { - const listener = (message: MessageEvent): void => { + const listener = async (message: MessageEvent): Promise => { const { name, headers, data } = message.data if (name === 'STOP') { close() diff --git a/test/GLOBALS.mjs b/test/GLOBALS.mjs index 10dfd1d..3823222 100644 --- a/test/GLOBALS.mjs +++ b/test/GLOBALS.mjs @@ -6,24 +6,14 @@ import { process } from '../env.mjs' const queue = new Queue() -if (globalThis.sessionStorage == null) { - let _sessionStorage = {} - Object.defineProperty(globalThis, 'sessionStorage', { - value: { - length: Object.entries(_sessionStorage).length, - setItem: (key, value) => _sessionStorage[key] = value, - getItem: (key) => _sessionStorage[key], - removeItem: (key) => delete _sessionStorage[key], - clear: () => _sessionStorage = {} - }, - configurable: true, - enumerable: true - }) -} export { process } - export const isNode = process.versions?.node != null +let NodeTestSuite, NodeTestTest +if (isNode) { + ({ suite: NodeTestSuite, test: NodeTestTest } = await import('node:test')) +} + export const failures = [] export const passes = [] function fail (err) { @@ -114,45 +104,49 @@ export function stats (times) { } } -export function suite (name, opts, fn) { - if (fn === undefined) fn = opts - return queue.add(async () => { - if (opts?.skip) { - console.group(`%cSKIP `, 'color:CornflowerBlue', name) +export const suite = NodeTestSuite != null + ? NodeTestSuite + : (name, opts, fn) => { + if (fn === undefined) fn = opts + return queue.add(async () => { + if (opts?.skip) { + console.group(`%cSKIP `, 'color:CornflowerBlue', name) + console.groupEnd() + return + } + if (fn?.constructor?.name === 'AsyncFunction') fn = fn() + if (typeof fn === 'function') fn = new Promise(resolve => resolve(fn())) + name === 'TEST RUNNER CHECK' + ? console.groupCollapsed(`%c${name}`, 'font-weight:bold') + : console.group(`%c${name}`, 'font-weight:bold') + await fn console.groupEnd() - return - } - if (fn?.constructor?.name === 'AsyncFunction') fn = fn() - if (typeof fn === 'function') fn = new Promise(resolve => resolve(fn())) - opts?.collapse - ? console.groupCollapsed(`%c${name}`, 'font-weight:bold') - : console.group(`%c${name}`, 'font-weight:bold') - await fn - console.groupEnd() - }) -} + }) + } -export async function test (name, opts, fn) { - if (opts?.skip) return console.log(`%cSKIP `, 'color:CornflowerBlue', name) - if (fn === undefined) fn = opts - if (fn instanceof Promise) { - try { - await fn - pass(name) - } catch (err) { - fail(new Error(name, { cause: err })) - } - } else if (typeof fn === 'function') { - try { - await fn() - pass(name) - } catch (err) { - fail(new Error(name, { cause: err })) +export const test = NodeTestTest != null + ? NodeTestTest + : async (name, opts, fn) => { + if (opts?.skip) return console.log(`%cSKIP `, 'color:CornflowerBlue', name) + if (fn === undefined) fn = opts + if (fn instanceof Promise) { + try { + await fn + pass(name) + } catch (err) { + fail(new Error(name, { cause: err })) + } + } else if (typeof fn === 'function') { + try { + await fn() + pass(name) + } catch (err) { + fail(new Error(name, { cause: err })) + } + } else { + fail(new Error(name, { cause: `test cannot execute on ${typeof fn} ${fn}` })) } - } else { - fail(new Error(name, { cause: `test cannot execute on ${typeof fn} ${fn}` })) } -} export const assert = { ok: (bool) => { @@ -170,9 +164,9 @@ export const assert = { } return a != null }, - equals: (a, b) => { + equal: (a, b) => { if (a == null || b == null) { - throw new Error(`assert.equals() will not compare null or undefined`) + throw new Error(`assert.equal() will not compare null or undefined`) } if (a !== b) { throw new Error(`${a} not equal to ${b}`) @@ -241,17 +235,19 @@ export const assert = { } } -await suite('TEST RUNNER CHECK', { collapse: true }, async () => { +await suite('TEST RUNNER CHECK', async () => { await new Promise(r => setTimeout(r, 0)) console.assert(failures.length === 0) console.assert(passes.length === 0) - await test('promise should pass', new Promise(resolve => { resolve('') })) + //@ts-expect-error + await test('promise should pass', new Promise(resolve => resolve(null))) console.assert(failures.some(call => /.*promise should pass.*/.test(call[0])) === false, `good promise errored`) console.assert(passes.some(call => /.*promise should pass.*/.test(call)) === true, `good promise not logged`) - await test('promise should fail', new Promise((resolve, reject) => { reject('FAILURE EXPECTED HERE') })) + //@ts-expect-error + await test('promise should fail', new Promise((resolve, reject) => reject('FAILURE EXPECTED HERE'))) console.assert(failures.some(call => /.*promise should fail.*/.test(call)) === true, `bad promise not errored`) console.assert(passes.some(call => /.*promise should fail.*/.test(call)) === false, 'bad promise logged') @@ -267,6 +263,7 @@ await suite('TEST RUNNER CHECK', { collapse: true }, async () => { console.assert(failures.some(call => /.*function should pass.*/.test(call)) === false, 'good function errored') console.assert(passes.some(call => /.*function should pass.*/.test(call)) === true, 'good function not logged') + //@ts-expect-error await test('function should fail', 'FAILURE EXPECTED HERE') console.assert(failures.some(call => /.*function should fail.*/.test(call)) === true, 'bad function not errored') console.assert(passes.some(call => /.*function should fail.*/.test(call)) === false, 'bad function logged') diff --git a/test/test.blake2b.mjs b/test/test.blake2b.mjs index 4ce4d9b..220610d 100644 --- a/test/test.blake2b.mjs +++ b/test/test.blake2b.mjs @@ -31,7 +31,7 @@ await suite('BLAKE2b test vectors', async () => { } try { const output = new Blake2b(64, key).update(input).digest('hex') - assert.equals(output, test.out) + assert.equal(output, test.out) } catch (err) { console.error(`blake2b reference test vector ${i} failed`, { cause: err }) } @@ -82,7 +82,7 @@ await suite('BLAKE2b test vectors', async () => { } try { const output = new Blake2b(test.outlen ?? 64, key, salt, personal).update(input).digest('hex') - assert.equals(output, test.out) + assert.equal(output, test.out) } catch (err) { console.error(`blake2b libsodium test vector ${i} failed`, { cause: err }) } diff --git a/test/test.blocks.mjs b/test/test.blocks.mjs index 157400e..53fc076 100644 --- a/test/test.blocks.mjs +++ b/test/test.blocks.mjs @@ -32,7 +32,7 @@ await suite('Block format', async () => { '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D' ) assert.notEqual(block.balance, 0) - assert.equals(block.balance, BigInt(0)) + assert.equal(block.balance, BigInt(0)) }) await test('subtract balance from SendBlock correctly', async () => { @@ -44,7 +44,7 @@ await suite('Block format', async () => { NANO_TEST_VECTORS.ADDRESS_2, '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D' ) - assert.equals(block.balance, 1000000000000000000000000000000n) + assert.equal(block.balance, 1000000000000000000000000000000n) }) await test('add balance from ReceiveBlock correctly', async () => { @@ -56,7 +56,7 @@ await suite('Block format', async () => { NANO_TEST_VECTORS.ADDRESS_2, '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D' ) - assert.equals(block.balance, 3000000000000000000000000000000n) + assert.equal(block.balance, 3000000000000000000000000000000n) }) }) @@ -73,8 +73,8 @@ await suite('Block signing using official test vectors', async () => { NANO_TEST_VECTORS.OPEN_BLOCK.work ) await block.sign(NANO_TEST_VECTORS.OPEN_BLOCK.key) - assert.equals(block.hash, NANO_TEST_VECTORS.OPEN_BLOCK.hash) - assert.equals(block.signature, NANO_TEST_VECTORS.OPEN_BLOCK.signature) + assert.equal(block.hash, NANO_TEST_VECTORS.OPEN_BLOCK.hash) + assert.equal(block.signature, NANO_TEST_VECTORS.OPEN_BLOCK.signature) }) await test('sign receive block', async () => { @@ -88,8 +88,8 @@ await suite('Block signing using official test vectors', async () => { NANO_TEST_VECTORS.RECEIVE_BLOCK.work ) await block.sign(NANO_TEST_VECTORS.RECEIVE_BLOCK.key) - assert.equals(block.hash, NANO_TEST_VECTORS.RECEIVE_BLOCK.hash) - assert.equals(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) + assert.equal(block.hash, NANO_TEST_VECTORS.RECEIVE_BLOCK.hash) + assert.equal(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) }) await test('sign receive block without work', async () => { @@ -102,9 +102,9 @@ await suite('Block signing using official test vectors', async () => { NANO_TEST_VECTORS.RECEIVE_BLOCK.previous ) await block.sign(NANO_TEST_VECTORS.RECEIVE_BLOCK.key) - assert.equals(block.hash, NANO_TEST_VECTORS.RECEIVE_BLOCK.hash) - assert.equals(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) - assert.equals(block.work, '') + assert.equal(block.hash, NANO_TEST_VECTORS.RECEIVE_BLOCK.hash) + assert.equal(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) + assert.equal(block.work, '') }) await test('sign send block', async () => { @@ -118,8 +118,8 @@ await suite('Block signing using official test vectors', async () => { NANO_TEST_VECTORS.SEND_BLOCK.work ) await block.sign(NANO_TEST_VECTORS.SEND_BLOCK.key) - assert.equals(block.hash, NANO_TEST_VECTORS.SEND_BLOCK.hash) - assert.equals(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) + assert.equal(block.hash, NANO_TEST_VECTORS.SEND_BLOCK.hash) + assert.equal(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) }) await test('sign send block without work', async () => { @@ -132,9 +132,9 @@ await suite('Block signing using official test vectors', async () => { NANO_TEST_VECTORS.SEND_BLOCK.previous ) await block.sign(NANO_TEST_VECTORS.SEND_BLOCK.key) - assert.equals(block.hash, NANO_TEST_VECTORS.SEND_BLOCK.hash) - assert.equals(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) - assert.equals(block.work, '') + assert.equal(block.hash, NANO_TEST_VECTORS.SEND_BLOCK.hash) + assert.equal(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) + assert.equal(block.work, '') }) await test('sign change rep block', async () => { @@ -147,8 +147,8 @@ await suite('Block signing using official test vectors', async () => { work, ) await block.sign('781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') // Did not find a private key at nano docs for this address - assert.equals(block.signature?.toUpperCase(), 'A3C3C66D6519CBC0A198E56855942DEACC6EF741021A1B11279269ADC587DE1DA53CD478B8A47553231104CF24D742E1BB852B0546B87038C19BAE20F9082B0D') - assert.equals(block.work, work) + assert.equal(block.signature?.toUpperCase(), 'A3C3C66D6519CBC0A198E56855942DEACC6EF741021A1B11279269ADC587DE1DA53CD478B8A47553231104CF24D742E1BB852B0546B87038C19BAE20F9082B0D') + assert.equal(block.work, work) }) await test('sign change rep block without work', async () => { @@ -159,7 +159,7 @@ await suite('Block signing using official test vectors', async () => { 'F3C1D7B6EE97DA09D4C00538CEA93CBA5F74D78FD3FBE71347D2DFE7E53DF327' ) await block.sign(NANO_TEST_VECTORS.PRIVATE_0) - assert.equals(block.signature?.toUpperCase(), '2BD2F905E74B5BEE3E2277CED1D1E3F7535E5286B6E22F7B08A814AA9E5C4E1FEA69B61D60B435ADC2CE756E6EE5F5BE7EC691FE87E024A0B22A3D980CA5B305') - assert.equals(block.work, '') + assert.equal(block.signature?.toUpperCase(), '2BD2F905E74B5BEE3E2277CED1D1E3F7535E5286B6E22F7B08A814AA9E5C4E1FEA69B61D60B435ADC2CE756E6EE5F5BE7EC691FE87E024A0B22A3D980CA5B305') + assert.equal(block.work, '') }) }) diff --git a/test/test.calculate-pow.mjs b/test/test.calculate-pow.mjs index a2d90ed..2844d50 100644 --- a/test/test.calculate-pow.mjs +++ b/test/test.calculate-pow.mjs @@ -20,8 +20,8 @@ await suite('Calculate proof-of-work', async () => { ) await block.pow() - assert.equals(block.previous.length, 64) - assert.equals(block.work?.length, 16) + assert.equal(block.previous.length, 64) + assert.equal(block.work?.length, 16) const work = block.work ?.match(/.{2}/g) @@ -34,7 +34,7 @@ await suite('Calculate proof-of-work', async () => { if (previous == null) throw new Error('Previous block hash invalid') const bytes = new Uint8Array([...work, ...previous]) - assert.equals(bytes.byteLength, 40) + assert.equal(bytes.byteLength, 40) const hash = new Blake2b(8) .update(bytes) @@ -42,6 +42,6 @@ await suite('Calculate proof-of-work', async () => { .slice(8, 16) assert.ok(parseInt(hash.slice(0, 2), 16) > 0xf0) - assert.equals(parseInt(hash.slice(2, 8), 16), 0xffffff) + assert.equal(parseInt(hash.slice(2, 8), 16), 0xffffff) }) }) diff --git a/test/test.derive-accounts.mjs b/test/test.derive-accounts.mjs index bcee3b3..e287265 100644 --- a/test/test.derive-accounts.mjs +++ b/test/test.derive-accounts.mjs @@ -15,14 +15,14 @@ await suite('Derive accounts from BIP-44 wallet', async () => { const account = await wallet.account() const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_0) - assert.equals(account.index, 0) + assert.equal(privateKey, NANO_TEST_VECTORS.PRIVATE_0) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(account.index, 0) const accounts = await wallet.accounts() assert.exists(accounts[0]) - assert.equals(account, accounts[0]) + assert.equal(account, accounts[0]) await wallet.destroy() }) @@ -34,15 +34,15 @@ await suite('Derive accounts from BIP-44 wallet', async () => { const privateKey1 = await accounts[1].export(wallet.seed, 'hex') const privateKey2 = await accounts[2].export(wallet.seed, 'hex') - assert.equals(accounts.length, 2) - assert.equals(privateKey1, NANO_TEST_VECTORS.PRIVATE_1) - assert.equals(accounts[1].publicKey, NANO_TEST_VECTORS.PUBLIC_1) - assert.equals(accounts[1].address, NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(accounts[1].index, 1) - assert.equals(privateKey2, NANO_TEST_VECTORS.PRIVATE_2) - assert.equals(accounts[2].publicKey, NANO_TEST_VECTORS.PUBLIC_2) - assert.equals(accounts[2].address, NANO_TEST_VECTORS.ADDRESS_2) - assert.equals(accounts[2].index, 2) + assert.equal(accounts.length, 2) + assert.equal(privateKey1, NANO_TEST_VECTORS.PRIVATE_1) + assert.equal(accounts[1].publicKey, NANO_TEST_VECTORS.PUBLIC_1) + assert.equal(accounts[1].address, NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(accounts[1].index, 1) + assert.equal(privateKey2, NANO_TEST_VECTORS.PRIVATE_2) + assert.equal(accounts[2].publicKey, NANO_TEST_VECTORS.PUBLIC_2) + assert.equal(accounts[2].address, NANO_TEST_VECTORS.ADDRESS_2) + assert.equal(accounts[2].index, 2) await wallet.destroy() }) @@ -52,11 +52,11 @@ await suite('Derive accounts from BIP-44 wallet', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0x70000000, 0x7000000f) - assert.equals(accounts.length, 0x10) + assert.equal(accounts.length, 0x10) for (let i = 0x70000000; i < 0x7000000f; i++) { const a = accounts[i] assert.exists(a) - assert.equals(a.index, i) + assert.equal(a.index, i) assert.exists(a.address) assert.exists(a.publicKey) const privateKey = await a.export(wallet.seed, 'hex') @@ -75,14 +75,14 @@ await suite('Derive accounts from BLAKE2b wallet', async () => { const account = await wallet.account(1) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1) - // assert.equals(account.publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_0) - // assert.equals(account.address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_0) - assert.equals(account.index, 1) + assert.equal(privateKey, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1) + // assert.equal(account.publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_0) + // assert.equal(account.address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_0) + assert.equal(account.index, 1) const accounts = await wallet.accounts(1) assert.exists(accounts[1]) - assert.equals(account, accounts[1]) + assert.equal(account, accounts[1]) await wallet.destroy() }) @@ -94,15 +94,15 @@ await suite('Derive accounts from BLAKE2b wallet', async () => { // const privateKey1 = await accounts[1].export(wallet.seed, 'hex') // const privateKey2 = await accounts[2].export(wallet.seed, 'hex') - assert.equals(accounts.length, 2) - // assert.equals(privateKey1, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1) - // assert.equals(accounts[1].publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_1) - // assert.equals(accounts[1].address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_1) - assert.equals(accounts[1].index, 1) - // assert.equals(privateKey2, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_2) - // assert.equals(accounts[2].publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_2) - // assert.equals(accounts[2].address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_2) - assert.equals(accounts[2].index, 2) + assert.equal(accounts.length, 2) + // assert.equal(privateKey1, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_1) + // assert.equal(accounts[1].publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_1) + // assert.equal(accounts[1].address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_1) + assert.equal(accounts[1].index, 1) + // assert.equal(privateKey2, NANO_TEST_VECTORS.BLAKE2B_PRIVATE_2) + // assert.equal(accounts[2].publicKey, NANO_TEST_VECTORS.BLAKE2B_PUBLIC_2) + // assert.equal(accounts[2].address, NANO_TEST_VECTORS.BLAKE2B_ADDRESS_2) + assert.equal(accounts[2].index, 2) await wallet.destroy() }) @@ -112,11 +112,11 @@ await suite('Derive accounts from BLAKE2b wallet', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.accounts(0x70000000, 0x7000000f) - assert.equals(accounts.length, 0x10) + assert.equal(accounts.length, 0x10) for (let i = 0x70000000; i < 0x7000000f; i++) { const a = accounts[i] assert.exists(a) - assert.equals(a.index, i) + assert.equal(a.index, i) assert.exists(a.address) assert.exists(a.publicKey) const privateKey = await a.export(wallet.seed, 'hex') diff --git a/test/test.import-wallet.mjs b/test/test.import-wallet.mjs index 230488f..80cb5b2 100644 --- a/test/test.import-wallet.mjs +++ b/test/test.import-wallet.mjs @@ -17,13 +17,13 @@ await suite('Import wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.ok(account instanceof Account) - assert.equals(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_0) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0) + assert.equal(privateKey, NANO_TEST_VECTORS.PRIVATE_0) await wallet.destroy() }) @@ -37,12 +37,12 @@ await suite('Import wallets', async () => { assert.ok('seed' in wallet) assert.ok(account instanceof Account) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_0) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_0) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0) + assert.equal(privateKey, NANO_TEST_VECTORS.PRIVATE_0) await wallet.destroy() }) @@ -52,13 +52,13 @@ await suite('Import wallets', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const account = await wallet.account() - assert.equals(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_0) - assert.equals(wallet.seed, CUSTOM_TEST_VECTORS.SEED_0) - assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_0) - assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0) + assert.equal(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_0) + assert.equal(wallet.seed, CUSTOM_TEST_VECTORS.SEED_0) + assert.equal(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_0) + assert.equal(account.address, CUSTOM_TEST_VECTORS.ADDRESS_0) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_0) + assert.equal(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_0) await wallet.destroy() }) @@ -68,13 +68,13 @@ await suite('Import wallets', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const account = await wallet.account() - assert.equals(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_1) - assert.equals(wallet.seed, CUSTOM_TEST_VECTORS.SEED_1) - assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_1) - assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1) + assert.equal(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_1) + assert.equal(wallet.seed, CUSTOM_TEST_VECTORS.SEED_1) + assert.equal(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_1) + assert.equal(account.address, CUSTOM_TEST_VECTORS.ADDRESS_1) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_1) + assert.equal(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_1) await wallet.destroy() }) @@ -84,13 +84,13 @@ await suite('Import wallets', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const account = await wallet.account() - assert.equals(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_2) - assert.equals(wallet.seed, CUSTOM_TEST_VECTORS.SEED_2) - assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_2) - assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2) + assert.equal(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_2) + assert.equal(wallet.seed, CUSTOM_TEST_VECTORS.SEED_2) + assert.equal(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_2) + assert.equal(account.address, CUSTOM_TEST_VECTORS.ADDRESS_2) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_2) + assert.equal(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_2) await wallet.destroy() }) @@ -100,13 +100,13 @@ await suite('Import wallets', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const account = await wallet.account() - assert.equals(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_3) - assert.equals(wallet.seed, CUSTOM_TEST_VECTORS.SEED_3) - assert.equals(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_3) - assert.equals(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3) + assert.equal(wallet.mnemonic, CUSTOM_TEST_VECTORS.MNEMONIC_3) + assert.equal(wallet.seed, CUSTOM_TEST_VECTORS.SEED_3) + assert.equal(account.publicKey, CUSTOM_TEST_VECTORS.PUBLIC_3) + assert.equal(account.address, CUSTOM_TEST_VECTORS.ADDRESS_3) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_3) + assert.equal(privateKey, CUSTOM_TEST_VECTORS.PRIVATE_3) await wallet.destroy() }) @@ -118,9 +118,9 @@ await suite('Import wallets', async () => { 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.SEED_0.toUpperCase()) - assert.equals(accounts.length, 4) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.SEED_0.toUpperCase()) + assert.equal(accounts.length, 4) for (let i = 0; i < accounts.length; i++) { assert.exists(accounts[i]) @@ -140,9 +140,9 @@ await suite('Import wallets', async () => { 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) - assert.equals(accounts.length, 4) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) + assert.equal(accounts.length, 4) for (let i = 0; i < accounts.length; i++) { assert.exists(accounts[i]) @@ -162,20 +162,20 @@ await suite('Import wallets', async () => { 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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) assert.ok(accounts[0] instanceof Account) - assert.equals(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_0) - assert.equals(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_0) + assert.equal(accounts[0].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_0) + assert.equal(accounts[0].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_0) const privateKey0 = await accounts[0].export(wallet.seed, 'hex') - assert.equals(privateKey0, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_0) + assert.equal(privateKey0, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_0) assert.ok(accounts[1] instanceof Account) - assert.equals(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1) - assert.equals(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1) + assert.equal(accounts[1].publicKey, TREZOR_TEST_VECTORS.BLAKE2B_1_PUBLIC_1) + assert.equal(accounts[1].address, TREZOR_TEST_VECTORS.BLAKE2B_1_ADDRESS_1) const privateKey1 = await accounts[1].export(wallet.seed, 'hex') - assert.equals(privateKey1, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_1) + assert.equal(privateKey1, TREZOR_TEST_VECTORS.BLAKE2B_1_PRIVATE_1) await wallet.destroy() }) @@ -189,17 +189,17 @@ await suite('Import wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.exists(walletAccount) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_2) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_2) const imported = await Blake2bWallet.fromMnemonic(TREZOR_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.MNEMONIC_2) await imported.unlock(TREZOR_TEST_VECTORS.PASSWORD) const importedAccount = await imported.account() const importedAccountPrivateKey = await importedAccount.export(imported.seed, 'hex') - assert.equals(imported.mnemonic, wallet.mnemonic) - assert.equals(imported.seed, wallet.seed) - assert.equals(importedAccount.publicKey, walletAccount.publicKey) - assert.equals(importedAccountPrivateKey, walletAccountPrivateKey) + assert.equal(imported.mnemonic, wallet.mnemonic) + assert.equal(imported.seed, wallet.seed) + assert.equal(importedAccount.publicKey, walletAccount.publicKey) + assert.equal(importedAccountPrivateKey, walletAccountPrivateKey) await wallet.destroy() }) @@ -212,13 +212,13 @@ await suite('Import wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.ok(account instanceof Account) - assert.equals(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_3) - assert.equals(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_3) - assert.equals(account.publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0) - assert.equals(account.address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_3) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_3) + assert.equal(account.publicKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PUBLIC_0) + assert.equal(account.address, TREZOR_TEST_VECTORS.BLAKE2B_3_ADDRESS_0) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PRIVATE_0) + assert.equal(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_3_PRIVATE_0) await wallet.destroy() }) @@ -250,15 +250,15 @@ await suite('Import wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(unlockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) await wallet.destroy() }) @@ -270,15 +270,15 @@ await suite('Import wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(unlockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) await wallet.destroy() }) diff --git a/test/test.ledger.mjs b/test/test.ledger.mjs index 6a1b4d0..28c2173 100644 --- a/test/test.ledger.mjs +++ b/test/test.ledger.mjs @@ -20,37 +20,37 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { await test('request permissions', async () => { wallet = await LedgerWallet.create() let status = wallet.status - assert.equals(status, 'DISCONNECTED') - assert.equals(status, wallet.status) + assert.equal(status, 'DISCONNECTED') + assert.equal(status, wallet.status) status = await click( 'Reset permissions, unlock device, quit Nano app, then click to continue', async () => wallet.connect() ) - assert.equals(status, 'BUSY') - assert.equals(status, wallet.status) + assert.equal(status, 'BUSY') + assert.equal(status, wallet.status) status = await click( 'Open Nano app on device, allow device to auto-lock, then click to continue', async () => wallet.connect() ) - assert.equals(status, 'LOCKED') - assert.equals(status, wallet.status) + assert.equal(status, 'LOCKED') + assert.equal(status, wallet.status) status = await click( 'Unlock device, verify Nano app is open, then click to continue', async () => wallet.connect() ) - assert.equals(status, 'CONNECTED') - assert.equals(status, wallet.status) + assert.equal(status, 'CONNECTED') + assert.equal(status, wallet.status) }) await test('get version', async () => { const { status, name, version } = await wallet.version() - assert.equals(status, 'OK') - assert.equals(name, 'Nano') - assert.equals(version, '1.2.6') + assert.equal(status, 'OK') + assert.equal(name, 'Nano') + assert.equal(version, '1.2.6') }) await test('get first account', async () => { @@ -61,20 +61,20 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { assert.exists(account.address) assert.exists(account.publicKey) assert.exists(account.privateKey) - assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') + assert.equal(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') }) await test('get second and third accounts', async () => { const accounts = await wallet.accounts(1, 2) assert.exists(accounts) - assert.equals(accounts.length, 2) + assert.equal(accounts.length, 2) for (const account of accounts) { assert.ok(account instanceof Account) assert.exists(account.address) assert.exists(account.publicKey) assert.exists(account.privateKey) - assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') + assert.equal(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') } }) @@ -89,7 +89,7 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { assert.ok(account.balance >= 0) assert.exists(account.publicKey) assert.exists(account.privateKey) - assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') + assert.equal(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000') } }) @@ -105,24 +105,24 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { assert.ok(/^[A-Fa-f0-9]{64}$/.test(openBlock.hash)) assert.nullish(openBlock.signature) - assert.equals(openBlock.account.publicKey, account.publicKey) + assert.equal(openBlock.account.publicKey, account.publicKey) const { status, hash, signature } = await wallet.sign(0, openBlock) - assert.equals(status, 'OK') + assert.equal(status, 'OK') assert.ok(/^[A-Fa-f0-9]{64}$/.test(hash)) assert.ok(/^[A-Fa-f0-9]{128}$/.test(signature)) await openBlock.sign(0) assert.ok(/^[A-Fa-f0-9]{128}$/.test(openBlock.signature)) - assert.equals(signature, openBlock.signature) + assert.equal(signature, openBlock.signature) }) await test('cache open block', async () => { const { status } = await wallet.updateCache(0, openBlock) - assert.equals(status, 'OK') + assert.equal(status, 'OK') }) await test('sign send block from wallet which requires cache to be up-to-date', async () => { @@ -137,11 +137,11 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash)) assert.nullish(sendBlock.signature) - assert.equals(sendBlock.account.publicKey, account.publicKey) + assert.equal(sendBlock.account.publicKey, account.publicKey) const { status, hash, signature } = await wallet.sign(0, sendBlock) - assert.equals(status, 'OK') + assert.equal(status, 'OK') assert.ok(/^[A-Fa-f0-9]{64}$/.test(hash)) assert.ok(/^[A-Fa-f0-9]{128}$/.test(signature)) sendBlock.signature = signature @@ -159,7 +159,7 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash)) assert.nullish(receiveBlock.signature) - assert.equals(receiveBlock.account.publicKey, account.publicKey) + assert.equal(receiveBlock.account.publicKey, account.publicKey) await receiveBlock.sign(0, sendBlock) @@ -171,7 +171,7 @@ await suite('Ledger hardware wallet', { skip: true || isNode }, async () => { const nonce = new TextEncoder().encode('0123456789abcdef') const { status, signature } = await click('Click to sign nonce', wallet.sign(0, nonce)) - assert.equals(status, 'OK') + assert.equal(status, 'OK') assert.OK(/^[A-Fa-f0-9]{128}$/.test(signature)) }) diff --git a/test/test.lock-unlock.mjs b/test/test.lock-unlock.mjs index 67d8e01..9a56aba 100644 --- a/test/test.lock-unlock.mjs +++ b/test/test.lock-unlock.mjs @@ -15,15 +15,15 @@ await suite('Lock and unlock wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(unlockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) await wallet.destroy() }) @@ -38,15 +38,15 @@ await suite('Lock and unlock wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(new Uint8Array(key)) - assert.equals(unlockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) await wallet.destroy() }) @@ -57,13 +57,13 @@ await suite('Lock and unlock wallets', async () => { const account = await wallet.account() const lockResult = await wallet.lock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(lockResult, true) + assert.equal(lockResult, true) const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(unlockResult, true) - assert.equals(privateKey, NANO_TEST_VECTORS.PRIVATE_0) + assert.equal(unlockResult, true) + assert.equal(privateKey, NANO_TEST_VECTORS.PRIVATE_0) await wallet.destroy() }) @@ -74,7 +74,7 @@ await suite('Lock and unlock wallets', async () => { 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.equal(lockResult, true) assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) @@ -91,7 +91,7 @@ await suite('Lock and unlock wallets', async () => { const lockResult = await wallet.lock(new Uint8Array(rightKey)) await assert.rejects(wallet.unlock(new Uint8Array(wrongKey)), { message: 'Failed to unlock wallet' }) - assert.equals(lockResult, true) + assert.equal(lockResult, true) assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) @@ -120,8 +120,8 @@ await suite('Lock and unlock wallets', async () => { 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) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) await wallet.lock('password') @@ -141,8 +141,8 @@ await suite('Lock and unlock wallets', async () => { 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) + assert.equal(wallet.mnemonic, NANO_TEST_VECTORS.MNEMONIC) + assert.equal(wallet.seed, NANO_TEST_VECTORS.BIP39_SEED) await wallet.lock(NANO_TEST_VECTORS.PASSWORD) @@ -161,15 +161,15 @@ await suite('Lock and unlock wallets', async () => { assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(unlockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_0) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_0) await wallet.destroy() }) @@ -180,20 +180,20 @@ await suite('Lock and unlock wallets', async () => { const key = globalThis.crypto.getRandomValues(new Uint8Array(64)) const lockResult = await wallet.lock(new Uint8Array(key)) - assert.equals(lockResult, true) + assert.equal(lockResult, true) assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) - assert.equals(wallet.seed, '') + assert.equal(wallet.seed, '') const unlockResult = await wallet.unlock(new Uint8Array(key)) - assert.equals(lockResult, true) - assert.equals(unlockResult, true) + assert.equal(lockResult, true) + assert.equal(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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) await wallet.destroy() }) @@ -204,13 +204,13 @@ await suite('Lock and unlock wallets', async () => { const account = await wallet.account() const lockResult = await wallet.lock(NANO_TEST_VECTORS.PASSWORD) - assert.equals(lockResult, true) + assert.equal(lockResult, true) const unlockResult = await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const privateKey = await account.export(wallet.seed, 'hex') - assert.equals(unlockResult, true) - assert.equals(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_PRIVATE_0) + assert.equal(unlockResult, true) + assert.equal(privateKey, TREZOR_TEST_VECTORS.BLAKE2B_PRIVATE_0) await wallet.destroy() }) @@ -235,7 +235,7 @@ await suite('Lock and unlock wallets', async () => { const lockResult = await wallet.lock(new Uint8Array(rightKey)) await assert.rejects(wallet.unlock(new Uint8Array(wrongKey)), { message: 'Failed to unlock wallet' }) - assert.equals(lockResult, true) + assert.equal(lockResult, true) assert.ok('mnemonic' in wallet) assert.ok('seed' in wallet) assert.nullish(wallet.mnemonic) @@ -264,8 +264,8 @@ await suite('Lock and unlock wallets', async () => { 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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) await wallet.lock(NANO_TEST_VECTORS.PASSWORD) @@ -285,8 +285,8 @@ await suite('Lock and unlock wallets', async () => { 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) + assert.equal(wallet.mnemonic, TREZOR_TEST_VECTORS.MNEMONIC_1) + assert.equal(wallet.seed, TREZOR_TEST_VECTORS.ENTROPY_1) await wallet.lock(NANO_TEST_VECTORS.PASSWORD) diff --git a/test/test.manage-rolodex.mjs b/test/test.manage-rolodex.mjs index 44a7085..c0b8a7b 100644 --- a/test/test.manage-rolodex.mjs +++ b/test/test.manage-rolodex.mjs @@ -11,23 +11,23 @@ await suite('Rolodex valid contact management', async () => { await test('should create a rolodex and add two contacts', async () => { const rolodex = new Rolodex() - assert.equals(rolodex.constructor, Rolodex) + assert.equal(rolodex.constructor, Rolodex) await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0) await rolodex.add('JaneSmith', NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(rolodex.getAllNames().length, 2) - assert.equals(rolodex.getAllNames()[0], 'JohnDoe') - assert.equals(rolodex.getAllNames()[1], 'JaneSmith') - assert.equals(rolodex.getAddresses('JohnDoe').length, 1) - assert.equals(rolodex.getAddresses('JohnDoe')[0], NANO_TEST_VECTORS.ADDRESS_0) - assert.equals(rolodex.getAddresses('JaneSmith').length, 1) - assert.equals(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(rolodex.getAllNames().length, 2) + assert.equal(rolodex.getAllNames()[0], 'JohnDoe') + assert.equal(rolodex.getAllNames()[1], 'JaneSmith') + assert.equal(rolodex.getAddresses('JohnDoe').length, 1) + assert.equal(rolodex.getAddresses('JohnDoe')[0], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(rolodex.getAddresses('JaneSmith').length, 1) + assert.equal(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_1) }) 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') + assert.equal(rolodex.getName(NANO_TEST_VECTORS.ADDRESS_0), 'JohnDoe') }) await test('should add three addresses to the same contact', async () => { @@ -35,40 +35,40 @@ await suite('Rolodex valid contact management', async () => { await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_1) await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_2) await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0) - assert.equals(rolodex.getAddresses('JohnDoe').length, 3) - assert.equals(rolodex.getAddresses('JohnDoe')[0], NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(rolodex.getAddresses('JohnDoe')[1], NANO_TEST_VECTORS.ADDRESS_2) - assert.equals(rolodex.getAddresses('JohnDoe')[2], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(rolodex.getAddresses('JohnDoe').length, 3) + assert.equal(rolodex.getAddresses('JohnDoe')[0], NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(rolodex.getAddresses('JohnDoe')[1], NANO_TEST_VECTORS.ADDRESS_2) + assert.equal(rolodex.getAddresses('JohnDoe')[2], NANO_TEST_VECTORS.ADDRESS_0) }) 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('JohnDoe').length, 0) - assert.equals(rolodex.getAddresses('JaneSmith').length, 1) - assert.equals(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(rolodex.getAddresses('JohnDoe').length, 0) + assert.equal(rolodex.getAddresses('JaneSmith').length, 1) + assert.equal(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_0) }) 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) + assert.equal(Array.isArray(rolodex.getAddresses('JaneSmith')), true) + assert.equal(rolodex.getAddresses('JaneSmith').length, 0) }) 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.equal(Array.isArray(rolodex.getAddresses(undefined)), true) //@ts-expect-error - assert.equals(rolodex.getAddresses(undefined).length, 0) + assert.equal(rolodex.getAddresses(undefined).length, 0) //@ts-expect-error - assert.equals(Array.isArray(rolodex.getAddresses(null)), true) + assert.equal(Array.isArray(rolodex.getAddresses(null)), true) //@ts-expect-error - assert.equals(rolodex.getAddresses(null).length, 0) - assert.equals(Array.isArray(rolodex.getAddresses('')), true) - assert.equals(rolodex.getAddresses('').length, 0) + assert.equal(rolodex.getAddresses(null).length, 0) + assert.equal(Array.isArray(rolodex.getAddresses('')), true) + assert.equal(rolodex.getAddresses('').length, 0) }) await test('should return null for an unknown address', async () => { @@ -131,7 +131,7 @@ await suite('Rolodex data signature verification', async () => { const rolodex = new Rolodex() await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0) const result = await rolodex.verify('JohnDoe', signature, data) - assert.equals(result, true) + assert.equal(result, true) }) await test('should reject incorrect contact for signature', async () => { @@ -140,6 +140,6 @@ await suite('Rolodex data signature verification', async () => { const rolodex = new Rolodex() await rolodex.add('JaneSmith', NANO_TEST_VECTORS.ADDRESS_1) const result = await rolodex.verify('JaneSmith', signature, data) - assert.equals(result, false) + assert.equal(result, false) }) }) diff --git a/test/test.refresh-accounts.mjs b/test/test.refresh-accounts.mjs index 79cd170..5d07051 100644 --- a/test/test.refresh-accounts.mjs +++ b/test/test.refresh-accounts.mjs @@ -19,17 +19,17 @@ await suite('Refreshing account info', { skip: true }, async () => { assert.exists(account.balance) assert.notEqual(account.balance, '') - assert.equals(typeof account.balance, 'bigint') + assert.equal(typeof account.balance, 'bigint') assert.ok(account.balance >= 0) assert.exists(account.frontier) - assert.equals(typeof account.frontier, 'string') + assert.equal(typeof account.frontier, 'string') assert.notEqual(account.frontier, '') assert.ok(/^[A-Fa-f0-9]{64}$/.test(account.frontier)) assert.exists(account.representative) assert.notEqual(account.representative, '') - assert.equals(account.representative.constructor, Account) + assert.equal(account.representative.constructor, Account) assert.exists(account.representative?.address) assert.notEqual(account.representative?.address, '') @@ -78,8 +78,8 @@ await suite('Fetch next unopened account', { skip: true }, async () => { const account = await wallet.unopened(rpc) assert.exists(account) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) await wallet.destroy() }) @@ -90,8 +90,8 @@ await suite('Fetch next unopened account', { skip: true }, async () => { const account = await wallet.unopened(rpc, 1) assert.exists(account) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) await wallet.destroy() }) @@ -102,8 +102,8 @@ await suite('Fetch next unopened account', { skip: true }, async () => { const account = await wallet.unopened(rpc, 100) assert.exists(account) - assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1) - assert.equals(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) + assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1) await wallet.destroy() }) @@ -144,9 +144,9 @@ await suite('Refreshing wallet accounts', { skip: true }, async () => { const account = accounts[0] assert.ok(account instanceof Account) - assert.equals(typeof account.balance, 'bigint') + assert.equal(typeof account.balance, 'bigint') assert.exists(account.frontier) - assert.equals(typeof account.frontier, 'string') + assert.equal(typeof account.frontier, 'string') await wallet.destroy() }) @@ -156,7 +156,7 @@ await suite('Refreshing wallet accounts', { skip: true }, async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const accounts = await wallet.refresh(rpc, 0, 2) - assert.equals(accounts.length, 1) + assert.equal(accounts.length, 1) assert.ok(accounts[0] instanceof Account) await wallet.destroy() diff --git a/test/test.tools.mjs b/test/test.tools.mjs index 1a6adea..903a5ec 100644 --- a/test/test.tools.mjs +++ b/test/test.tools.mjs @@ -19,42 +19,42 @@ await suite('unit conversion tests', async () => { await test('should convert nano to raw', async () => { const result = await Tools.convert('1', 'NANO', 'RAW') - assert.equals(result, '1000000000000000000000000000000') + assert.equal(result, '1000000000000000000000000000000') }) await test('should convert raw to nano', async () => { const result = await Tools.convert('1000000000000000000000000000000', 'RAW', 'NANO') - assert.equals(result, '1') + assert.equal(result, '1') }) await test('should convert 1 raw to 10^-29 nano', async () => { const result = await Tools.convert('1', 'RAW', 'NANO') - assert.equals(result, '.000000000000000000000000000001') + assert.equal(result, '.000000000000000000000000000001') }) await test('should ignore leading and trailing zeros', async () => { const result = await Tools.convert('0011002200.0033004400', 'nano', 'nano') - assert.equals(result, '11002200.00330044') + assert.equal(result, '11002200.00330044') }) await test('should convert raw to nyano', async () => { const result = await Tools.convert(RAW_MAX, 'RAW', 'NYANO') - assert.equals(result, '340282366920938.463463374607431768211455') + assert.equal(result, '340282366920938.463463374607431768211455') }) await test('should convert case-insensitive nyano to raw', async () => { const result = await Tools.convert('0.000000000000000123456789', 'nYaNo', 'rAw') - assert.equals(result, '123456789') + assert.equal(result, '123456789') }) await test('should convert nano to pico', async () => { const result = await Tools.convert('123.456', 'nano', 'pico') - assert.equals(result, '123456') + assert.equal(result, '123456') }) await test('should convert knano to pico', async () => { const result = await Tools.convert('123.456', 'nano', 'pico') - assert.equals(result, '123456') + assert.equal(result, '123456') }) await test('should throw if amount exceeds raw max', async () => { @@ -82,23 +82,23 @@ await suite('signature tests', async () => { await test('should sign data with a single parameter', async () => { const result = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, 'miro@metsanheimo.fi') - assert.equals(result, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C') + assert.equal(result, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C') }) await test('should sign data with multiple parameters', async () => { const result = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, 'miro@metsanheimo.fi', 'somePassword') - assert.equals(result, 'BB534F9B469AF451B1941FFEF8EE461FC5D284B5D393140900C6E13A65EF08D0AE2BC77131EE182922F66C250C7237A83878160457D5C39A70E55F7FCE925804') + assert.equal(result, 'BB534F9B469AF451B1941FFEF8EE461FC5D284B5D393140900C6E13A65EF08D0AE2BC77131EE182922F66C250C7237A83878160457D5C39A70E55F7FCE925804') }) await test('should verify a signature using the public key', async () => { const result = await Tools.verify(NANO_TEST_VECTORS.PUBLIC_0, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C', 'miro@metsanheimo.fi') - assert.equals(result, true) + assert.equal(result, true) const result2 = await Tools.verify(NANO_TEST_VECTORS.PUBLIC_0, 'FECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C', 'mir@metsanheimo.fi') - assert.equals(result2, false) + assert.equal(result2, false) const result3 = await Tools.verify(NANO_TEST_VECTORS.PUBLIC_0, 'AECB9B084065ADC969904B55A0099C63746B68DF41FECB713244D387EED83A80B9D4907278C5EBC0998A5FC8BA597FBAAABBFCE0ABD2CA2212ACFE788637040C', 'miro@metsanheimo.fi') - assert.equals(result3, false) + assert.equal(result3, false) }) await test('should verify a block using the public key', async () => { @@ -116,7 +116,7 @@ await suite('signature tests', async () => { ) await sendBlock.sign(privateKey) const valid = await sendBlock.verify(account.publicKey) - assert.equals(valid, true) + assert.equal(valid, true) await wallet.destroy() }) @@ -138,7 +138,7 @@ await suite('signature tests', async () => { sendBlock.account = Account.import('nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p') const valid = await sendBlock.verify(account.publicKey) - assert.equals(valid, false) + assert.equal(valid, false) await wallet.destroy() }) @@ -153,7 +153,7 @@ await suite('signature tests', async () => { await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const results = await Tools.sweep(rpc, wallet, NANO_TEST_VECTORS.ADDRESS_1) assert.ok(results) - assert.equals(results.length, 1) + assert.equal(results.length, 1) await wallet.destroy() }) -- 2.47.3