From: Chris Duncan Date: Mon, 21 Jul 2025 20:41:31 +0000 (-0700) Subject: Update tests. X-Git-Tag: v0.10.5~55^2~37 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=b70bea0f84bfe7f101352000037759baf8d6fb8e;p=libnemo.git Update tests. --- diff --git a/index.html b/index.html index c9627e6..015377d 100644 --- a/index.html +++ b/index.html @@ -91,7 +91,7 @@ SPDX-License-Identifier: GPL-3.0-or-later } })() - + diff --git a/package.json b/package.json index 67d0309..e416cea 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "build:prod": "npm run clean && node esbuild-prod.mjs", "publish": "npm run build:prod", "test": "npm run build", - "test:node": "npm run build:node && node --test --test-force-exit --env-file .env", + "test:node": "npm run build:node && node --test --test-force-exit --no-experimental-strip-types --env-file .env", "test:coverage": "npm run test:node -- --experimental-test-coverage", "test:coverage:report": "npm run test:coverage -- --test-reporter=lcov --test-reporter-destination=coverage.info && genhtml coverage.info --output-directory test/coverage && rm coverage.info && xdg-open test/coverage/index.html" }, diff --git a/test/test.main.mjs b/test/main.test.mjs similarity index 100% rename from test/test.main.mjs rename to test/main.test.mjs diff --git a/test/perf.account.js b/test/perf.account.js index a0c5262..ea06717 100644 --- a/test/perf.account.js +++ b/test/perf.account.js @@ -14,53 +14,61 @@ await Promise.all([ await test(`Time to create ${COUNT} BIP-44 accounts`, async () => { const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + const start = performance.now() const accounts = await wallet.accounts(0, COUNT - 1) const end = performance.now() console.log(`Total: ${end - start} ms`) console.log(`Average: ${(end - start) / COUNT} ms`) assert.equal(accounts.length, COUNT) + await wallet.destroy() }) await test(`Time to create ${COUNT} BLAKE2b accounts`, async () => { const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + const start = performance.now() const accounts = await wallet.accounts(0, COUNT - 1) const end = performance.now() console.log(`Total: ${end - start} ms`) console.log(`Average: ${(end - start) / COUNT} ms`) assert.equal(accounts.length, COUNT) + await wallet.destroy() }) await test(`Time to create 1 BIP-44 account ${COUNT} times`, async () => { - const times = [] const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + const times = [] for (let i = 0; i < COUNT; i++) { const start = performance.now() - await wallet.accounts(i) + await wallet.account(i) const end = performance.now() times.push(end - start) } - await wallet.destroy() console.log(stats(times)) + + await wallet.destroy() }) - await test(`Average time to create 1 BLAKE2b account ${COUNT} times`, async () => { - const times = [] + await test(`Time to create 1 BLAKE2b account ${COUNT} times`, async () => { const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD) await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) + + const times = [] for (let i = 0; i < COUNT; i++) { const start = performance.now() - await wallet.accounts(i) + await wallet.account(i) const end = performance.now() times.push(end - start) } - await wallet.destroy() console.log(stats(times)) + + await wallet.destroy() }) }) ])