From 17bca886df97daf934e3a6d8950178949fc6cf66 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 31 Aug 2024 13:13:26 -0700 Subject: [PATCH] Fix module imports. Replace arrow functions on 'describe' calls since they mess up 'this' and prevent test data setup. Set mocha 'slow' to zero in order to report all test durations. --- test/test.mjs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/test.mjs b/test/test.mjs index 1f03feb..19886f8 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -1,10 +1,11 @@ 'use strict' -const expect = require('chai').expect -const { wallet, block, tools, box } = require('../dist/index') +const { expect } = await import('chai') +const { wallet, block, tools, box } = await import('../dist/index.js') // WARNING: Do not send any funds to the test vectors below -describe('generate wallet test', () => { +describe('generate wallet test', function () { + this.slow(0) it('should generate wallet with random entropy', () => { const result = wallet.generate() @@ -57,7 +58,8 @@ describe('generate wallet test', () => { }) // Test vectors from https://docs.nano.org/integration-guides/key-management/ and elsewhere -describe('import wallet with test vectors test', () => { +describe('import wallet with test vectors test', function () { + this.slow(0) it('should successfully import a wallet with the official Nano test vectors mnemonic', () => { const result = wallet.fromMnemonic( @@ -138,7 +140,8 @@ describe('import wallet with test vectors test', () => { }) -describe('derive more accounts from the same seed test', () => { +describe('derive more accounts from the same seed test', function () { + this.slow(0) it('should derive accounts from the given seed', () => { const result = wallet.accounts( @@ -161,7 +164,8 @@ describe('derive more accounts from the same seed test', () => { }) // Test vectors from https://docs.nano.org/integration-guides/key-management/ -describe('block signing tests using official test vectors', () => { +describe('block signing tests using official test vectors', function () { + this.slow(0) it('should create a valid signature for a receive block', () => { const work = 'c5cf86de24b24419' @@ -245,7 +249,8 @@ describe('block signing tests using official test vectors', () => { }) -describe('unit conversion tests', () => { +describe('unit conversion tests', function () { + this.slow(0) it('should convert nano to raw', () => { const result = tools.convert('1', 'NANO', 'RAW') @@ -259,7 +264,8 @@ describe('unit conversion tests', () => { }) -describe('Signer tests', () => { +describe('Signer tests', function () { + this.slow(0) before(() => { this.testWallet = wallet.generate() @@ -329,7 +335,8 @@ describe('Signer tests', () => { }) -describe('Box tests', () => { +describe('Box tests', function () { + this.slow(0) before(() => { this.message = 'The quick brown fox jumps over the lazy dog 🔥' @@ -385,4 +392,4 @@ describe('Box tests', () => { expect(() => box.decrypt(encrypted, this.bob.accounts[0].address, aliceAccounts[0].privateKey)).to.throw() }) -}) \ No newline at end of file +}) -- 2.34.1