]> zoso.dev Git - libnemo.git/commitdiff
Move performance tests into separate folder and add npm script to execute them.
authorChris Duncan <chris@zoso.dev>
Wed, 20 Nov 2024 21:35:43 +0000 (13:35 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 20 Nov 2024 21:35:43 +0000 (13:35 -0800)
package.json
perf/account.mjs [new file with mode: 0644]
perf/wallet.mjs [new file with mode: 0644]
test/performance.test.mjs [deleted file]

index 4c4e215ac4371edaa7bd202c3941a6dee06511e0..1d6f1e55a5500be6322ff3f42672846b3c2752c2 100644 (file)
@@ -45,7 +45,8 @@
                "build": "rm -rf dist && tsc && esbuild main.min=dist/main.js global.min=dist/global.js --outdir=dist --target=es2022 --format=esm --platform=browser --bundle --minify --sourcemap",
                "test": "npm run build -- --platform=node && node --test --test-force-exit --env-file .env",
                "test:coverage": "npm run test -- --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"
+               "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",
+               "test:performance": "npm run test perf/*"
        },
        "imports": {
                "#*": "./*"
diff --git a/perf/account.mjs b/perf/account.mjs
new file mode 100644 (file)
index 0000000..3b27cc8
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+'use strict'
+
+import '#test/GLOBALS.mjs'
+import { test } from 'node:test'
+import { strict as assert } from 'assert'
+import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
+
+console.log('child key derivation performance test')
+
+test('BIP-44 ckd', async () => {
+       const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)
+       await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
+
+       const accounts = await wallet.accounts(0, 0x7fff)
+
+       assert.equal(accounts.length, 0x8000)
+})
+
+test('BLAKE2b ckd', async () => {
+       const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)
+       await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
+
+       const accounts = await wallet.accounts(0, 0x7fff)
+
+       assert.equal(accounts.length, 0x8000)
+})
diff --git a/perf/wallet.mjs b/perf/wallet.mjs
new file mode 100644 (file)
index 0000000..bc90281
--- /dev/null
@@ -0,0 +1,28 @@
+// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+'use strict'
+
+import '#test/GLOBALS.mjs'
+import { test } from 'node:test'
+import { strict as assert } from 'assert'
+import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
+
+console.log('wallet performance test')
+
+test('creating BIP-44 wallets', async () => {
+       const wallets = []
+       for (let i = 0x80; i > 0; i--) {
+               wallets.push(await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD))
+       }
+       assert.equal(wallets.length, 0x80)
+})
+
+test('creating BLAKE2b wallets', async () => {
+       const wallets = []
+       for (let i = 0x80; i > 0; i--) {
+               wallets.push(await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD))
+       }
+       assert.equal(wallets.length, 0x80)
+})
diff --git a/test/performance.test.mjs b/test/performance.test.mjs
deleted file mode 100644 (file)
index d7bd28e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-'use strict'
-
-import './GLOBALS.mjs'
-import { describe, it } from 'node:test'
-import { strict as assert } from 'assert'
-import { NANO_TEST_VECTORS } from './TEST_VECTORS.js'
-import { Bip44Wallet, Blake2bWallet } from '../dist/main.js'
-
-const skip = true
-
-describe('wallet generation performance', { skip }, async () => {
-       it('performance test creating BIP-44 wallets', async () => {
-               const wallets = []
-               for (let i = 0x80; i > 0; i--) {
-                       wallets.push(await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD))
-               }
-               assert.equal(wallets.length, 0x80)
-       })
-
-       it('performance test creating BLAKE2b wallets', async () => {
-               const wallets = []
-               for (let i = 0x80; i > 0; i--) {
-                       wallets.push(await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD))
-               }
-               assert.equal(wallets.length, 0x80)
-       })
-})
-
-describe('child key derivation performance', { skip }, async () => {
-       it('performance test of BIP-44 ckd', async () => {
-               const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)
-               await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
-
-               const accounts = await wallet.accounts(0, 0x7fff)
-
-               assert.equal(accounts.length, 0x8000)
-       })
-
-       it('performance test of BLAKE2b ckd', async () => {
-               const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)
-               await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
-
-               const accounts = await wallet.accounts(0, 0x7fff)
-
-               assert.equal(accounts.length, 0x8000)
-       })
-})