From 1c99e29d5b98326c12c71f13bebde8f4fd7bf9a8 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 15 Jan 2025 19:18:13 -0800 Subject: [PATCH] Add edge cases to validate check on testing web page. Add manual validation form. --- test.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test.html b/test.html index ac52795..112a0eb 100644 --- a/test.html +++ b/test.html @@ -73,6 +73,10 @@ SPDX-License-Identifier: GPL-3.0-or-later console.log(`validate() output for bad nonce is ${expectFalse === false ? 'correct' : 'incorrect'}`) const expectTrue = await NanoPow.validate('47c83266398728cf', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D') console.log(`validate() output for good nonce is ${expectTrue === true ? 'correct' : 'incorrect'}`) + const expectFalseForVariation = await NanoPow.validate('47c83266398728ce', '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D') + console.log(`validate() output for slightly wrong nonce is ${expectFalseForVariation === false ? 'correct' : 'incorrect'}`) + const expectTrueForCollision = await NanoPow.validate('c5d5d6f7c5d6ccd1', '281e89ac73b1082b464b9c3c1168384f846d39f6df25105f8b4a22915e999117') + console.log(`validate() output for colliding nonce is ${expectTrueForCollision === true ? 'correct' : 'incorrect'}`) const type = (NanoPow === NanoPowGpu) ? 'WebGPU' : (NanoPow === NanoPowGl) ? 'WebGL' : 'unknown API' try { @@ -111,6 +115,24 @@ SPDX-License-Identifier: GPL-3.0-or-later console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold') } + document.getElementById('validate').addEventListener('click', e => { + console.log(e) + const work = document.getElementById('work') + const hash = document.getElementById('hash') + const validated = document.getElementById('validated') + validated.innerText = '' + NanoPow.validate(work.value, hash.value) + .then(result => { + validated.innerText = result + ? 'Valid' + : 'INVALID' + }) + .catch(err => { + console.error(err) + validated.innerText = err.message + }) + }) + document.getElementById('go').addEventListener('click', e => { const size = document.getElementById('size') const effort = document.getElementById('effort') @@ -131,6 +153,13 @@ SPDX-License-Identifier: GPL-3.0-or-later

Times below are in milliseconds and summarized by various averaging methods.

Level of Effort depends on hardware and does not guarantee faster results.


+ + + + + + +
-- 2.34.1