]> zoso.dev Git - libnemo.git/commitdiff
Overhaul project structure by separating NanoPow code from its worker interface,...
authorChris Duncan <chris@zoso.dev>
Wed, 8 Jan 2025 15:10:08 +0000 (07:10 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 8 Jan 2025 15:10:08 +0000 (07:10 -0800)
28 files changed:
package.json
src/lib/block.ts
src/lib/nano-pow/classes/gl.ts [moved from src/lib/nano-pow/nanopow-gl.ts with 83% similarity]
src/lib/nano-pow/classes/gpu.ts [moved from src/lib/nano-pow/nanopow-gpu.ts with 85% similarity]
src/lib/nano-pow/index.ts [new file with mode: 0644]
src/lib/workers.ts
src/lib/workers/bip44-ckd.ts
src/lib/workers/nano-nacl.ts
src/lib/workers/nano-pow.ts [new file with mode: 0644]
src/main.ts
test/GLOBALS.mjs [moved from GLOBALS.mjs with 100% similarity]
test/VECTORS.js [moved from test/TEST_VECTORS.js with 100% similarity]
test/main.mjs [deleted file]
test/perf.account.js [moved from perf/account.perf.js with 95% similarity]
test/perf.block.js [moved from perf/block.perf.js with 96% similarity]
test/perf.main.mjs [moved from perf/main.mjs with 67% similarity]
test/perf.wallet.js [moved from perf/wallet.perf.js with 91% similarity]
test/test.calculate-pow.mjs [moved from test/calculate-pow.test.mjs with 88% similarity]
test/test.create-wallet.mjs [moved from test/create-wallet.test.mjs with 91% similarity]
test/test.derive-accounts.mjs [moved from test/derive-accounts.test.mjs with 93% similarity]
test/test.import-wallet.mjs [moved from test/import-wallet.test.mjs with 97% similarity]
test/test.lock-unlock-wallet.mjs [moved from test/lock-unlock-wallet.mjs with 96% similarity]
test/test.main.mjs [new file with mode: 0644]
test/test.manage-rolodex.mjs [moved from test/manage-rolodex.mjs with 98% similarity]
test/test.refresh-accounts.mjs [moved from test/refresh-accounts.test.mjs with 98% similarity]
test/test.sign-blocks.mjs [moved from test/sign-blocks.test.mjs with 95% similarity]
test/test.tools.mjs [moved from test/tools.test.mjs with 95% similarity]
tsconfig.json

index f15a05b3a7ec1fe82480431a9a7a8172d16fa479..cfa32f87cc8750115ddfe80fdbd263c8741fd67e 100644 (file)
        },
        "scripts": {
                "build": "rm -rf dist && tsc && esbuild main.min=dist/main.js global.min=dist/global.js --outdir=dist --target=esnext --format=esm --platform=browser --bundle --sourcemap",
-               "test": "npm run build && esbuild test.min=test/main.mjs --outdir=dist --target=esnext --format=esm --platform=browser --bundle --sourcemap",
+               "test": "npm run build && esbuild test.min=test/test.main.mjs --outdir=dist --target=esnext --format=esm --platform=browser --bundle --sourcemap",
                "test:node": "npm run build -- --platform=node && node --test --test-force-exit --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",
-               "test:performance": "npm run build && esbuild perf.min=perf/main.mjs --outdir=dist --target=esnext --format=esm --platform=browser --bundle --sourcemap"
+               "test:performance": "npm run build && esbuild perf.min=test/perf.main.mjs --outdir=dist --target=esnext --format=esm --platform=browser --bundle --sourcemap"
        },
        "imports": {
-               "#*": "./*"
+               "#~/*": "./src/lib/*",
+               "#dist/*": "./dist/*",
+               "#test/*": "./test/*",
+               "#nano-pow/*": "./src/lib/nano-pow/*"
        },
        "optionalDependencies": {
                "@ledgerhq/hw-transport-web-ble": "^6.29.4",
index 971c80fbfa9dbfa6365a9ed2dc66f6723646f60b..7d669d51534d8f697b6e8faa9d60a6150df4e7c9 100644 (file)
@@ -8,7 +8,7 @@ import { dec, hex } from './convert.js'
 import { NanoNaCl } from './workers/nano-nacl.js'
 import { Pool } from './pool.js'
 import { Rpc } from './rpc.js'
-import { PowGl, NanoPowGpu } from './workers.js'
+import { NanoPow } from './workers.js'
 
 /**
 * Represents a block as defined by the Nano cryptocurrency protocol. The Block
@@ -16,7 +16,7 @@ import { PowGl, NanoPowGpu } from './workers.js'
 * of three derived classes: SendBlock, ReceiveBlock, ChangeBlock.
 */
 abstract class Block {
-       static #pool: Pool = new Pool(NanoPowGpu)
+       static #pool: Pool = new Pool(NanoPow)
        account: Account
        type: string = 'state'
        abstract subtype: 'send' | 'receive' | 'change'
similarity index 83%
rename from src/lib/nano-pow/nanopow-gl.ts
rename to src/lib/nano-pow/classes/gl.ts
index a99aa730f8e7eb8a09c503499e601178b2bbd581..055dc14c7f21e6ca63397e58ffd142034f1fb8cb 100644 (file)
@@ -2,31 +2,32 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 // Based on nano-webgl-pow by Ben Green (numtel) <ben@latenightsketches.com>
 // https://github.com/numtel/nano-webgl-pow
-import { WorkerInterface } from '../pool.js'
-import { NanoPowGlFragmentShader, NanoPowGlVertexShader } from './shaders'
-
-export class PowGl extends WorkerInterface {
-       static {
-               PowGl.listen()
-       }
-       /**
-       * Calculates proof-of-work as described by the Nano cryptocurrency protocol.
-       *
-       * @param {any[]} data - Array of hashes and minimum thresholds
-       * @returns Promise for proof-of-work attached to original array objects
-       */
-       static async work (data: any[]): Promise<any[]> {
-               return new Promise(async (resolve, reject): Promise<void> => {
-                       for (const d of data) {
-                               try {
-                                       d.work = await this.search(d.hash, d.threshold)
-                               } catch (err) {
-                                       reject(err)
-                               }
-                       }
-                       resolve(data)
-               })
-       }
+// import { WorkerInterface } from '#~/pool.js'
+import { NanoPowGlFragmentShader, NanoPowGlVertexShader } from '#nano-pow/shaders/index.js'
+
+// export class NanoPowGl extends WorkerInterface {
+//     static {
+//             NanoPowGl.listen()
+//     }
+//     /**
+//     * Calculates proof-of-work as described by the Nano cryptocurrency protocol.
+//     *
+//     * @param {any[]} data - Array of hashes and minimum thresholds
+//     * @returns Promise for proof-of-work attached to original array objects
+//     */
+//     static async work (data: any[]): Promise<any[]> {
+//             return new Promise(async (resolve, reject): Promise<void> => {
+//                     for (const d of data) {
+//                             try {
+//                                     d.work = await this.search(d.hash, d.threshold)
+//                             } catch (err) {
+//                                     reject(err)
+//                             }
+//                     }
+//                     resolve(data)
+//             })
+//     }
+export class NanoPowGl {
 
        /** Used to set canvas size. Must be a multiple of 256. */
        static #WORKLOAD: number = 256 * Math.max(1, Math.floor(navigator.hardwareConcurrency))
@@ -130,7 +131,7 @@ export class PowGl extends WorkerInterface {
        * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
        */
        static async search (hash: string, threshold: number = 0xfffffff8): Promise<string> {
-               if (PowGl.#gl == null) throw new Error('WebGL 2 is required')
+               if (NanoPowGl.#gl == null) throw new Error('WebGL 2 is required')
                if (!/^[A-F-a-f0-9]{64}$/.test(hash)) throw new Error(`invalid_hash ${hash}`)
                if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`)
                if (this.#gl == null) throw new Error('WebGL 2 is required')
@@ -142,10 +143,10 @@ export class PowGl extends WorkerInterface {
                        uboView.setUint32(i * 2, parseInt(uint32, 16))
                }
                uboView.setUint32(128, threshold, true)
-               uboView.setFloat32(132, PowGl.#WORKLOAD - 1, true)
-               PowGl.#gl.bindBuffer(PowGl.#gl.UNIFORM_BUFFER, PowGl.#uboBuffer)
-               PowGl.#gl.bufferSubData(PowGl.#gl.UNIFORM_BUFFER, 0, uboView)
-               PowGl.#gl.bindBuffer(PowGl.#gl.UNIFORM_BUFFER, null)
+               uboView.setFloat32(132, NanoPowGl.#WORKLOAD - 1, true)
+               NanoPowGl.#gl.bindBuffer(NanoPowGl.#gl.UNIFORM_BUFFER, NanoPowGl.#uboBuffer)
+               NanoPowGl.#gl.bufferSubData(NanoPowGl.#gl.UNIFORM_BUFFER, 0, uboView)
+               NanoPowGl.#gl.bindBuffer(NanoPowGl.#gl.UNIFORM_BUFFER, null)
 
                // Start drawing to calculate one nonce per pixel
                let nonce = null
@@ -185,7 +186,7 @@ export class PowGl extends WorkerInterface {
                return new Promise((resolve, reject): void => {
                        try {
                                requestAnimationFrame(async (): Promise<void> => {
-                                       const result = await PowGl.checkQueryResult()
+                                       const result = await NanoPowGl.checkQueryResult()
                                        resolve(result)
                                })
                        } catch (err) {
@@ -221,9 +222,15 @@ export class PowGl extends WorkerInterface {
        }
 }
 
+// export default `
+//     const NanoPowGlFragmentShader = ${NanoPowGlFragmentShader}
+//     const NanoPowGlVertexShader = ${NanoPowGlVertexShader}
+//     // const WorkerInterface = ${WorkerInterface}
+//     const PowGl = ${NanoPowGl}
+// `
+
 export default `
-       const NanoPowGlFragmentShader = ${NanoPowGlFragmentShader}
-       const NanoPowGlVertexShader = ${NanoPowGlVertexShader}
-       const WorkerInterface = ${WorkerInterface}
-       const PowGl = ${PowGl}
+       const NanoPowGlFragmentShader = \`${NanoPowGlFragmentShader}\`
+       const NanoPowGlVertexShader = \`${NanoPowGlVertexShader}\`
+       const PowGl = ${NanoPowGl}
 `
similarity index 85%
rename from src/lib/nano-pow/nanopow-gpu.ts
rename to src/lib/nano-pow/classes/gpu.ts
index 81ef6a1d1432c376fa2bc40837787653367d01ed..b22500781c773e97ac2d165e98d98a8ceda3d641 100644 (file)
@@ -2,35 +2,37 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 // BLAKE2b hashing implementation derived from nano-webgl-pow by Ben Green <ben@latenightsketches.com> (https://github.com/numtel/nano-webgl-pow)
 /// <reference types="@webgpu/types" />
-import { WorkerInterface } from '../pool.js'
-import { NanoPowGpuComputeShader } from './shaders'
+// import { WorkerInterface } from '#~/pool.js'
+import { NanoPowGpuComputeShader } from '#nano-pow/shaders/index.js'
 
 /**
 * Nano proof-of-work using WebGPU.
 */
-export class NanoPowGpu extends WorkerInterface {
-       static {
-               NanoPowGpu.listen()
-       }
-
-       /**
-       * Calculates proof-of-work as described by the Nano cryptocurrency protocol.
-       *
-       * @param {any[]} data - Array of hashes and minimum thresholds
-       * @returns Promise for proof-of-work attached to original array objects
-       */
-       static async work (data: any[]): Promise<any[]> {
-               return new Promise(async (resolve, reject): Promise<void> => {
-                       for (const d of data) {
-                               try {
-                                       d.work = await this.search(d.hash, d.threshold)
-                               } catch (err) {
-                                       reject(err)
-                               }
-                       }
-                       resolve(data)
-               })
-       }
+// export class NanoPowGpu extends WorkerInterface {
+//     static {
+//             NanoPowGpu.listen()
+//     }
+
+//     /**
+//     * Calculates proof-of-work as described by the Nano cryptocurrency protocol.
+//     *
+//     * @param {any[]} data - Array of hashes and minimum thresholds
+//     * @returns Promise for proof-of-work attached to original array objects
+//     */
+//     static async work (data: any[]): Promise<any[]> {
+//             return new Promise(async (resolve, reject): Promise<void> => {
+//                     for (const d of data) {
+//                             try {
+//                                     d.work = await this.search(d.hash, d.threshold)
+//                             } catch (err) {
+//                                     reject(err)
+//                             }
+//                     }
+//                     resolve(data)
+//             })
+//     }
+// */
+export class NanoPowGpu {
 
        // Initialize WebGPU
        static #device: GPUDevice | null = null
@@ -210,8 +212,13 @@ export class NanoPowGpu extends WorkerInterface {
        }
 }
 
+// export default `
+//     const NanoPowGpuComputeShader = \`${NanoPowGpuComputeShader}\`
+//     const WorkerInterface = ${WorkerInterface}
+//     const NanoPowGpu = ${NanoPowGpu}
+// `
+
 export default `
        const NanoPowGpuComputeShader = \`${NanoPowGpuComputeShader}\`
-       const WorkerInterface = ${WorkerInterface}
        const NanoPowGpu = ${NanoPowGpu}
 `
diff --git a/src/lib/nano-pow/index.ts b/src/lib/nano-pow/index.ts
new file mode 100644 (file)
index 0000000..bc02f2d
--- /dev/null
@@ -0,0 +1,4 @@
+import { NanoPowGl } from "./classes/gl"
+import { NanoPowGpu } from "./classes/gpu"
+
+export { NanoPowGl, NanoPowGpu }
index 71ac9ab1f5df7d27265531ba2182384fa322fd4c..f91e41e242b1f52cc897a282db36fb3161e4eff5 100644 (file)
@@ -1,8 +1,7 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // SPDX-License-Identifier: GPL-3.0-or-later
-import { default as Bip44Ckd } from './workers/bip44-ckd.js'
-import { default as NanoNaCl } from './workers/nano-nacl.js'
-import { default as PowGl } from './nano-pow/nanopow-gl.js'
-import { default as NanoPowGpu } from './nano-pow/nanopow-gpu.js'
-
-export { Bip44Ckd, NanoNaCl, PowGl, NanoPowGpu }
+import { default as Bip44Ckd } from '#~/workers/bip44-ckd.js'
+import { default as NanoNaCl } from '#~/workers/nano-nacl.js'
+import { default as NanoPow } from '#~/workers/nano-pow.js'
+console.log(NanoPow)
+export { Bip44Ckd, NanoNaCl, NanoPow }
index 7764399f3c641884fec676bd2a28081b82f1ad72..00c3bb254d6944ee756d860333d3cdd1775cdf51 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // SPDX-License-Identifier: GPL-3.0-or-later
-import { WorkerInterface } from '../pool.js'
+import { WorkerInterface } from '#~/pool.js'
 
 type ExtendedKey = {
        privateKey: DataView
index 3bbaf69a6e022e9b651151d79903a39afe96f026..04af38acc8107e0256b0104fc214c28129f81a99 100644 (file)
@@ -4,7 +4,7 @@
 'use strict'\r
 \r
 import { Blake2b } from '../blake2b.js'\r
-import { WorkerInterface } from '../pool.js'\r
+import { WorkerInterface } from '#~/pool.js'\r
 \r
 // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\r
 // Public domain.\r
diff --git a/src/lib/workers/nano-pow.ts b/src/lib/workers/nano-pow.ts
new file mode 100644 (file)
index 0000000..49235f4
--- /dev/null
@@ -0,0 +1,43 @@
+// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+import { WorkerInterface } from '#~/pool.js'
+import { NanoPowGpuComputeShader, NanoPowGlFragmentShader, NanoPowGlVertexShader } from '#nano-pow/shaders/index.js'
+import { NanoPowGl, NanoPowGpu } from '#nano-pow/index.js'
+
+/**
+* Nano proof-of-work using WebGPU.
+*/
+export class NanoPow extends WorkerInterface {
+       static {
+               NanoPow.listen()
+       }
+
+       /**
+       * Calculates proof-of-work as described by the Nano cryptocurrency protocol.
+       *
+       * @param {any[]} data - Array of hashes and minimum thresholds
+       * @returns Promise for proof-of-work attached to original array objects
+       */
+       static async work (data: any[]): Promise<any[]> {
+               return new Promise(async (resolve, reject): Promise<void> => {
+                       for (const d of data) {
+                               try {
+                                       d.work = await NanoPowGpu.search(d.hash, d.threshold)
+                               } catch (err) {
+                                       reject(err)
+                               }
+                       }
+                       resolve(data)
+               })
+       }
+}
+
+export default `
+       const NanoPowGpuComputeShader = \`${NanoPowGpuComputeShader}\`
+       const NanoPowGlFragmentShader = \`${NanoPowGlFragmentShader}\`
+       const NanoPowGlVertexShader = \`${NanoPowGlVertexShader}\`
+       const NanoPowGl = ${NanoPowGl}
+       const NanoPowGpu = ${NanoPowGpu}
+       const WorkerInterface = ${WorkerInterface}
+       const NanoPow = ${NanoPow}
+`
index 52b2a716107f3dc3a55b5521ae8923496968a9c9..163c934bfdd4a3fe823a0d46de8026004e351f1b 100644 (file)
@@ -4,12 +4,11 @@
 import { Account } from './lib/account.js'
 import { Blake2b } from './lib/blake2b.js'
 import { SendBlock, ReceiveBlock, ChangeBlock } from './lib/block.js'
-import { PowGl } from './lib/nano-pow/nanopow-gl.js'
-import { NanoPowGpu } from './lib/nano-pow/nanopow-gpu.js'
+import { NanoPowGl, NanoPowGpu } from '#nano-pow/index.js'
 import { Rpc } from './lib/rpc.js'
 import { Rolodex } from './lib/rolodex.js'
 import { Safe } from './lib/safe.js'
 import { Tools } from './lib/tools.js'
 import { Bip44Wallet, Blake2bWallet, LedgerWallet } from './lib/wallet.js'
 
-export { Account, Blake2b, SendBlock, ReceiveBlock, ChangeBlock, PowGl, NanoPowGpu, Rpc, Rolodex, Safe, Tools, Bip44Wallet, Blake2bWallet, LedgerWallet }
+export { Account, Blake2b, SendBlock, ReceiveBlock, ChangeBlock, NanoPowGl as PowGl, NanoPowGpu, Rpc, Rolodex, Safe, Tools, Bip44Wallet, Blake2bWallet, LedgerWallet }
similarity index 100%
rename from GLOBALS.mjs
rename to test/GLOBALS.mjs
similarity index 100%
rename from test/TEST_VECTORS.js
rename to test/VECTORS.js
diff --git a/test/main.mjs b/test/main.mjs
deleted file mode 100644 (file)
index 1737521..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-import './calculate-pow.test.mjs'
-import './create-wallet.test.mjs'
-import './derive-accounts.test.mjs'
-import './import-wallet.test.mjs'
-import './lock-unlock-wallet.mjs'
-import './manage-rolodex.mjs'
-import './refresh-accounts.test.mjs'
-import './sign-blocks.test.mjs'
-import './tools.test.mjs'
-
-console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
similarity index 95%
rename from perf/account.perf.js
rename to test/perf.account.js
index 0d7deef2f1f7c7f159a25e80d532abc2e9a966a9..a62076a1e2ca069040b01e2d1dc62ea50cb05c4a 100644 (file)
@@ -3,8 +3,8 @@
 
 'use strict'
 
-import { assert, average, skip, suite, test } from '#GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { assert, average, skip, suite, test } from '#test/GLOBALS.mjs'
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'
 import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
 
 await suite('Account performance', async () => {
similarity index 96%
rename from perf/block.perf.js
rename to test/perf.block.js
index b23686c2f607aed7e8aa9f696d8bf34abc29adda..79a41e2bb54a27da75963dc4cc22162fb2e06e9c 100644 (file)
@@ -3,8 +3,8 @@
 
 'use strict'
 
-import { assert, average, skip, suite, test } from '#GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { assert, average, skip, suite, test } from '#test/GLOBALS.mjs'
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'
 import { PowGl, NanoPowGpu, SendBlock } from '#dist/main.js'
 import 'nano-webgl-pow'
 
similarity index 67%
rename from perf/main.mjs
rename to test/perf.main.mjs
index a6b9de72db70aea7647ac8454b7bef9cb21f8ca8..8858e1d39d7b50d54d8c39f309928edc7dcb5007 100644 (file)
@@ -1,8 +1,8 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // SPDX-License-Identifier: GPL-3.0-or-later
 
-// import './wallet.perf.js'
-// import './account.perf.js'
-import './block.perf.js'
+// import './perf.wallet.js'
+// import './perf.account.js'
+import './perf.block.js'
 
 console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
similarity index 91%
rename from perf/wallet.perf.js
rename to test/perf.wallet.js
index 7ed3b14666d4015dd348293a5274c9824ec974ac..a6e98dda9dcf3dce8a00463b551826f843cd4aba 100644 (file)
@@ -3,8 +3,8 @@
 
 'use strict'
 
-import { assert, average, skip, suite, test } from '#GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { assert, average, skip, suite, test } from '#test/GLOBALS.mjs'
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'
 import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'
 
 await suite(`Wallet performance`, async () => {
similarity index 88%
rename from test/calculate-pow.test.mjs
rename to test/test.calculate-pow.mjs
index e33ff6c04d850a590e001307109e4b3b9867ebc1..f712e15cee9cbde41b2e18ebfe5d66d73d868a87 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, suite, test } from '#GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, suite, test } from '#test/GLOBALS.mjs'\r
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { SendBlock, Blake2b } from '#dist/main.js'\r
 \r
 await suite('Calculate proof-of-work', async () => {\r
similarity index 91%
rename from test/create-wallet.test.mjs
rename to test/test.create-wallet.mjs
index f0feaabd86e8f42f4205dd0cbf8e851c53c1e8f4..34b4ebf3726e8d18afcb0b85e601db6ed6c9bc32 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, skip, suite, test } from '#GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, skip, suite, test } from '#test/GLOBALS.mjs'\r
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '#dist/main.js'\r
 \r
 await suite('Create wallets', async () => {\r
similarity index 93%
rename from test/derive-accounts.test.mjs
rename to test/test.derive-accounts.mjs
index 562635ab1a9b9dab5c95b975f172ca2a1ae112c0..309c6c33c5ecf205f5edc67e82cb2f975653e66a 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, skip, suite, test } from '#GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, skip, suite, test } from '#test/GLOBALS.mjs'\r
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '#dist/main.js'\r
 \r
 await suite('Account derivation', async () => {\r
similarity index 97%
rename from test/import-wallet.test.mjs
rename to test/test.import-wallet.mjs
index 5f7a6a716458e195bf245b81951010d4a53032ab..a5502f8b060f1be37b17593662da998d4beb6885 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, suite, test } from '#GLOBALS.mjs'\r
-import { BIP32_TEST_VECTORS, CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, suite, test } from '#test/GLOBALS.mjs'\r
+import { BIP32_TEST_VECTORS, CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { Account, Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
 \r
 await suite('Import wallets', async () => {\r
similarity index 96%
rename from test/lock-unlock-wallet.mjs
rename to test/test.lock-unlock-wallet.mjs
index 5ec6ec28ebfa467bff96972d714560e380281e0f..4c7577c081fb5bddf62d16d9847b54ed7cdd93c7 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, suite, test } from '#GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, suite, test } from '#test/GLOBALS.mjs'\r
+import { NANO_TEST_VECTORS, TREZOR_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { Bip44Wallet, Blake2bWallet } from '#dist/main.js'\r
 \r
 await suite('Lock and unlock wallets', async () => {\r
diff --git a/test/test.main.mjs b/test/test.main.mjs
new file mode 100644 (file)
index 0000000..413e356
--- /dev/null
@@ -0,0 +1,14 @@
+// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import './test.calculate-pow.mjs'
+import './test.create-wallet.mjs'
+import './test.derive-accounts.mjs'
+import './test.import-wallet.mjs'
+import './test.lock-unlock-wallet.mjs'
+import './test.manage-rolodex.mjs'
+import './test.refresh-accounts.mjs'
+import './test.sign-blocks.mjs'
+import './test.tools.mjs'
+
+console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
similarity index 98%
rename from test/manage-rolodex.mjs
rename to test/test.manage-rolodex.mjs
index 29c5005dc96ae74f4b67e877aaa1de2cc3e3f252..2074b609babdc209746650dbd3cc0acae2e936c7 100644 (file)
@@ -3,8 +3,8 @@
 
 'use strict'
 
-import { assert, suite, test } from '#GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { assert, suite, test } from '#test/GLOBALS.mjs'
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'
 import { Rolodex, Tools } from '#dist/main.js'
 
 await suite('Rolodex valid contact management', async () => {
similarity index 98%
rename from test/refresh-accounts.test.mjs
rename to test/test.refresh-accounts.mjs
index 89efbd1f7031076aa7a7a8a8c1074b0e8545b5ec..70201981f96e96797aadf3222b47420a686726a2 100644 (file)
@@ -3,8 +3,8 @@
 
 'use strict'
 
-import { assert, skip, suite, test } from '#GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
+import { assert, skip, suite, test } from '#test/GLOBALS.mjs'
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'
 import { Account, Bip44Wallet, Rpc } from '#dist/main.js'
 
 let rpc
similarity index 95%
rename from test/sign-blocks.test.mjs
rename to test/test.sign-blocks.mjs
index f13abb6da21e7d765d7770a0ab213d53da3f4cd8..282108ef5cca5aa386bfd691c7279bd5fed7611a 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, suite, test } from '#GLOBALS.mjs'\r
-import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, suite, test } from '#test/GLOBALS.mjs'\r
+import { NANO_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { SendBlock, ReceiveBlock, ChangeBlock } from '#dist/main.js'\r
 \r
 await suite('Valid blocks', async () => {\r
similarity index 95%
rename from test/tools.test.mjs
rename to test/test.tools.mjs
index eabbb9f04252f06daba6dcae60e457cc1a0bdeab..899a70a7c5bf7d15ed5890b7e619f4fae2e13774 100644 (file)
@@ -3,8 +3,8 @@
 \r
 'use strict'\r
 \r
-import { assert, skip, suite, test } from '#GLOBALS.mjs'\r
-import { RAW_MAX, NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
+import { assert, skip, suite, test } from '#test/GLOBALS.mjs'\r
+import { RAW_MAX, NANO_TEST_VECTORS } from '#test/VECTORS.js'\r
 import { Bip44Wallet, Account, SendBlock, Rpc, Tools } from '#dist/main.js'\r
 \r
 let rpc\r
index 1dab65334384a660bafd8f5766c19531d494a5e0..82d452f670206f966d1ce285ef58851b8df30dde 100644 (file)
@@ -12,7 +12,8 @@
                "forceConsistentCasingInFileNames": true,
                "noErrorTruncation": true,
                "noFallthroughCasesInSwitch": true,
-               "strict": true
+               "strict": true,
+               "rootDir": "src"
        },
        "include": [
                "src/main.ts",