]> zoso.dev Git - nano-pow.git/commitdiff
Validate test run after computing work instead of during timer.
authorChris Duncan <chris@zoso.dev>
Thu, 16 Jan 2025 19:14:16 +0000 (11:14 -0800)
committerChris Duncan <chris@zoso.dev>
Thu, 16 Jan 2025 19:14:16 +0000 (11:14 -0800)
test.html

index bc26e0ae90b7515353906f2ca05b778bfcdf702f..587e0041cb5b524706d578ff4e0737924372040f 100644 (file)
--- a/test.html
+++ b/test.html
@@ -93,16 +93,15 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        for (let i = 0; i < size; i++) {
                                const hash = random()
                                let work = null
-                               let isValid = null
                                const start = performance.now()
                                try {
                                        work = await NanoPow.search(hash, { effort, debug })
-                                       isValid = (await NanoPow.validate(work, hash)) ? 'VALID' : 'INVALID'
                                } catch (err) {
                                        document.getElementById('output').innerHTML += `Error: ${err.message}<br/>`
                                        console.error(err)
                                }
                                const end = performance.now()
+                               const isValid = (await NanoPow.validate(work, hash)) ? 'VALID' : 'INVALID'
                                times.push(end - start)
                                const msg = `${isValid} [${work}] ${hash} (${end - start} ms)`
                                // console.log(msg)