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 {
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')
<p>Times below are in milliseconds and summarized by various averaging methods.</p>
<p>Level of Effort depends on hardware and does not guarantee faster results.</p>
<hr />
+ <label for="work">Work</label>
+ <input id="work" type="text" />
+ <label for="hash">Hash</label>
+ <input id="hash" type="text" />
+ <button id="validate">Validate</button>
+ <span id="validated"></span>
+ <hr />
<label for="size">Test Size</label>
<input id="size" type="number" value="64" />
<label for="effort">Effort (1-16)</label>