]> git.codecow.com Git - nano25519.git/commitdiff
Migrate build tests to their own file.
authorChris Duncan <chris@zoso.dev>
Tue, 1 Sep 2026 06:11:12 +0000 (23:11 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 1 Sep 2026 06:11:12 +0000 (23:11 -0700)
src/assembly/index.ts
src/assembly/tests.ts [new file with mode: 0644]
src/assembly/utils.ts

index 278d5a17c77b3e498d31f4a08f64e0f6844f0a26..83fc5f7640b6395998d58a9728247362ce4dc2f1 100644 (file)
@@ -5,6 +5,7 @@ import { crypto_derive } from './crypto_derive'
 import { crypto_sign } from './crypto_sign'
 import { crypto_verify_decodepubkey, crypto_verify_relaxed, crypto_verify_strict } from './crypto_verify'
 import { errors } from './errors'
+import './tests'
 
 export const BLOCKHASH_BYTELENGTH: i32 = 32
 export const KEY_BYTELENGTH: i32 = 32
diff --git a/src/assembly/tests.ts b/src/assembly/tests.ts
new file mode 100644 (file)
index 0000000..fef7ee7
--- /dev/null
@@ -0,0 +1,21 @@
+//! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
+//! SPDX-License-Identifier: GPL-3.0-or-later
+
+import { equalbytes } from './utils'
+
+/**
+ * Tests run on initialization to ensure build is correct.
+ */
+const testbytesA = new StaticArray<u8>(32).fill(0)
+const testbytesB = new StaticArray<u8>(32).fill(0)
+
+/** equalbytes */
+for (let i = 0; i < 32; i++) {
+       for (let j: u8 = 0; j < 8; j++) {
+               testbytesA[i] = 1 << j
+               if (equalbytes(testbytesA, testbytesB, 32)) {
+                       throw new Error('equalbytes failed build test')
+               }
+               testbytesA[i] = 0
+       }
+}
index 91140a0cb14b094d9995c503034fecb9640deda2..16ff44f93388586a3ddf91b8c053970a661ee832 100644 (file)
@@ -76,16 +76,3 @@ export function sodium_is_zero (n: StaticArray<u8>, nlen: i32): u8 {
        d &= 255
        return u8(((d - 1) >> 8) & 1)
 }
-
-/** Unit tests on initialization */
-const testbytesA = new StaticArray<u8>(32).fill(0)
-const testbytesB = new StaticArray<u8>(32).fill(0)
-for (let i = 0; i < 32; i++) {
-       for (let j: u8 = 0; j < 8; j++) {
-               testbytesA[i] = 1 << j
-               if (equalbytes(testbytesA, testbytesB, 32)) {
-                       throw new Error('equalbytes failed unit test')
-               }
-               testbytesA[i] = 0
-       }
-}