From: Chris Duncan Date: Fri, 31 Jul 2026 16:58:00 +0000 (-0700) Subject: Revert moving test page so import maps work properly. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c3880b5857ff481aa25c0f7973284f14fa3072e9;p=nano-pow.git Revert moving test page so import maps work properly. --- diff --git a/README.md b/README.md index 8fdd7e4..9afbff7 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ every last bit of speed and performance out of it. A few basic tests are available in the source repository. -- `index.html` in the source repository contains a web interface to change +- `test/index.html` in the source repository contains a web interface to change execution options and compare results. - `test/script.sh` runs some basic benchmarks to check the CLI, and then it starts the `nano-pow` server and sends some validate and generate requests. diff --git a/index.html b/test/index.html similarity index 76% rename from index.html rename to test/index.html index bdffb28..ad6c728 100644 --- a/index.html +++ b/test/index.html @@ -15,9 +15,9 @@ SPDX-License-Identifier: GPL-3.0-or-later "nano-pow/utils": "https://unpkg.com/nano-pow@5.2.2/dist/utils/index.js" }, "scopes": { - "/": { - "nano-pow": "./dist/index.js", - "nano-pow/utils": "./dist/utils/index.js" + "/test/": { + "nano-pow": "../dist/index.js", + "nano-pow/utils": "../dist/utils/index.js" } } } @@ -48,7 +48,7 @@ SPDX-License-Identifier: GPL-3.0-or-later return gl?.drawingBufferHeight < gl?.drawingBufferWidth ? gl?.drawingBufferHeight : gl?.drawingBufferWidth })(new OffscreenCanvas(0, 0)) - function random () { + function random() { const bytes = crypto.getRandomValues(new Uint8Array(32)) return [...bytes].map(b => b.toString(16).padStart(2, '0')).join('') } @@ -58,7 +58,7 @@ SPDX-License-Identifier: GPL-3.0-or-later * @param {string} type * @param {number} effort */ - function average (times, type, effort) { + function average(times, type, effort) { const averages = stats(times) const title = type === 'WebGPU' ? `NanoPow (${type}) | Effort: ${effort} | Dispatch: ${(effort << 8) << 1} | Threads: ${64 * (effort << 8) << 1}` @@ -75,7 +75,7 @@ SPDX-License-Identifier: GPL-3.0-or-later * @param {string} difficulty * @param {number} effort */ - async function sequenceGenerateValidate (api, difficulty, effort) { + async function sequenceGenerateValidate(api, difficulty, effort) { let start = 0, end = 0, duration = 0, result = null, check = false const options = { api, difficulty, effort, debug: true } const hash = random() @@ -101,7 +101,7 @@ SPDX-License-Identifier: GPL-3.0-or-later * @param {string} name * @param {boolean} test */ - function check (name, test) { + function check(name, test) { if (typeof test !== 'boolean') { throw 'invalid test' } @@ -111,7 +111,7 @@ SPDX-License-Identifier: GPL-3.0-or-later /** * @param {string} api */ - async function selfCheck (api) { + async function selfCheck(api) { if (selfChecked[api]) return document.getElementById('status').textContent = `RUNNING SELF-CHECK: ${api.toUpperCase()}` logger.log(`%cNanoPow`, 'color:green', 'Checking validation against known values') @@ -123,67 +123,67 @@ SPDX-License-Identifier: GPL-3.0-or-later const expect = [] let result - // PASS - result = await NanoPow.work_validate('47c83266398728cf', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', options) - logger.log(result) - result = result.valid_all === '1' - logger.log(`work_validate() output for good nonce 1 is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + // PASS + result = await NanoPow.work_validate('47c83266398728cf', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', options) + logger.log(result) + result = result.valid_all === '1' + logger.log(`work_validate() output for good nonce 1 is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('4a8fb104eebbd336', '8797585D56B8AEA3A62899C31FC088F9BE849BA8298A88E94F6E3112D4E55D01', options) - logger.log(result) - result = result.valid_all === '1' - logger.log(`work_validate() output for good nonce 2 is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('4a8fb104eebbd336', '8797585D56B8AEA3A62899C31FC088F9BE849BA8298A88E94F6E3112D4E55D01', options) + logger.log(result) + result = result.valid_all === '1' + logger.log(`work_validate() output for good nonce 2 is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('c5d5d6f7c5d6ccd1', '281E89AC73B1082B464B9C3C1168384F846D39F6DF25105F8B4A22915E999117', options) - logger.log(result) - result = result.valid_all === '1' - logger.log(`work_validate() output for colliding nonce is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('c5d5d6f7c5d6ccd1', '281E89AC73B1082B464B9C3C1168384F846D39F6DF25105F8B4A22915E999117', options) + logger.log(result) + result = result.valid_all === '1' + logger.log(`work_validate() output for colliding nonce is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('6866c1ac3831a891', '7069D9CD1E85D6204301D254B0927F06ACC794C9EA5DF70EA5578458FB597090', { ...options, difficulty: 0xfffffe0000000000n }) - logger.log(result) - result = result.valid === '1' && result.valid_all === '0' && result.valid_receive === '1' - logger.log(`work_validate() output for good receive difficulty nonce is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('6866c1ac3831a891', '7069D9CD1E85D6204301D254B0927F06ACC794C9EA5DF70EA5578458FB597090', { ...options, difficulty: 0xfffffe0000000000n }) + logger.log(result) + result = result.valid === '1' && result.valid_all === '0' && result.valid_receive === '1' + logger.log(`work_validate() output for good receive difficulty nonce is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - // XFAIL - result = await NanoPow.work_validate('0000000000000000', '0000000000000000000000000000000000000000000000000000000000000000', options) - logger.log(result) - result = result.valid_all === '0' - logger.log(`work_validate() output for bad nonce 1 is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + // XFAIL + result = await NanoPow.work_validate('0000000000000000', '0000000000000000000000000000000000000000000000000000000000000000', options) + logger.log(result) + result = result.valid_all === '0' + logger.log(`work_validate() output for bad nonce 1 is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('c5d5d6f7c5d6ccd1', 'BA1E946BA3D778C2F30A83D44D2132CC6EEF010D8D06FF10A8ABD0100D8FB47E', options) - logger.log(result) - result = result.valid_all === '0' - logger.log(`work_validate() output for bad nonce 2 is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('c5d5d6f7c5d6ccd1', 'BA1E946BA3D778C2F30A83D44D2132CC6EEF010D8D06FF10A8ABD0100D8FB47E', options) + logger.log(result) + result = result.valid_all === '0' + logger.log(`work_validate() output for bad nonce 2 is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('ae238556213c3624', 'BF41D87DA3057FDC6050D2B00C06531F89F4AA6195D7C6C2EAAF15B6E703F8F6', { ...options, difficulty: 0xfffffff800000001n }) - logger.log(result) - result = result.error === 'Invalid difficulty fffffff800000001' - logger.log(`work_validate() output for bad difficulty beyond max is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('ae238556213c3624', 'BF41D87DA3057FDC6050D2B00C06531F89F4AA6195D7C6C2EAAF15B6E703F8F6', { ...options, difficulty: 0xfffffff800000001n }) + logger.log(result) + result = result.error === 'Invalid difficulty fffffff800000001' + logger.log(`work_validate() output for bad difficulty beyond max is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('29a9ae0236990e2e', '32721F4BD2AFB6F6A08D41CD0DF3C0D9C0B5294F68D0D12422F52B28F0800B5F', options) - logger.log(result) - result = result.valid_all === '0' - logger.log(`work_validate() output for slightly wrong nonce is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('29a9ae0236990e2e', '32721F4BD2AFB6F6A08D41CD0DF3C0D9C0B5294F68D0D12422F52B28F0800B5F', options) + logger.log(result) + result = result.valid_all === '0' + logger.log(`work_validate() output for slightly wrong nonce is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) - result = await NanoPow.work_validate('7d903b18d03f9820', '39C57C28F904DFE4012288FFF64CE80C0F42601023A9C82108E8F7B2D186C150', { ...options, difficulty: 0xfffffe0000000000n }) - logger.log(result) - result = result.valid === '0' && result.valid_all === '0' && result.valid_receive === '0' - logger.log(`work_validate() output for bad receive difficulty nonce is ${result === true ? 'correct' : 'incorrect'}`) - expect.push(result) + result = await NanoPow.work_validate('7d903b18d03f9820', '39C57C28F904DFE4012288FFF64CE80C0F42601023A9C82108E8F7B2D186C150', { ...options, difficulty: 0xfffffe0000000000n }) + logger.log(result) + result = result.valid === '0' && result.valid_all === '0' && result.valid_receive === '0' + logger.log(`work_validate() output for bad receive difficulty nonce is ${result === true ? 'correct' : 'incorrect'}`) + expect.push(result) const prefixes = [ 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', '0Xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - ' 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn ', + ' 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn ', ' ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn ', 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ] @@ -218,7 +218,7 @@ SPDX-License-Identifier: GPL-3.0-or-later * @param {number} size * @param {number} runs */ - async function test (api, difficulty, effort, size, runs) { + async function test(api, difficulty, effort, size, runs) { logger.isEnabled = true const type = api api = type.toLowerCase() @@ -260,7 +260,7 @@ SPDX-License-Identifier: GPL-3.0-or-later /** * @param {InputEvent} event */ - function startValidation (event) { + function startValidation(event) { const difficulty = document.getElementById('difficulty')?.value const work = document.getElementById('work')?.value const hash = document.getElementById('hash')?.value @@ -295,7 +295,7 @@ SPDX-License-Identifier: GPL-3.0-or-later /** * @param {InputEvent} event */ - function startTest (event) { + function startTest(event) { event.target.disabled = true const api = document.getElementById('api') const difficulty = document.getElementById('difficulty')