From d4c68e7505fbb6f25d3e68fa2d7ac0e504753266 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 2 Sep 2026 22:44:01 -0700 Subject: [PATCH] Fix unit test ranges. --- src/assembly/tests.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/assembly/tests.ts b/src/assembly/tests.ts index 2e56d66..cefee97 100644 --- a/src/assembly/tests.ts +++ b/src/assembly/tests.ts @@ -17,7 +17,7 @@ const zeros = new StaticArray(32).fill(0) const ones = new StaticArray(32).fill(255) const random = new StaticArray(32) for (let i = 0; i < 32; i++) { - random[i] = u8(Math.random() * 255) + random[i] = u8(Math.random() * 256) } const vectors = ['zeros', 'ones', 'random',] @@ -25,16 +25,16 @@ const expecteds = [zeros, ones, random,] const actual = new StaticArray(32) -for (let i = 0; i < vectors.length; i++) { - const vector = vectors[i] - const expected = expecteds[i] +for (let v = 0; v < vectors.length; v++) { + const vector = vectors[v] + const expected = expecteds[v] memory.copy(changetype(actual), changetype(expected), 32) + if (!equalbytes(actual, expected, 32)) { + throw new Error(`equalbytes build error: ${vector} failed instead of passing (expected [${expected}], actual [${actual}])`) + } for (let i = 0; i < 32; i++) { - if (!equalbytes(actual, expected, 32)) { - throw new Error(`equalbytes build error: ${vector} failed instead of passing (expected [${expected}], actual [${actual}])`) - } - for (let j: u8 = 1; j < 255; j++) { - actual[i] ^= j + for (let j = 1; j < 256; j++) { + actual[i] ^= u8(j) if (equalbytes(actual, expected, 32)) { throw new Error(`equalbytes build error: ${vector} passed instead of failing (expected [${expected}], actual [${actual}])`) } -- 2.52.0