]> git.codecow.com Git - libnemo.git/commitdiff
Add types to test files where ambiguous.
authorChris Duncan <chris@zoso.dev>
Tue, 31 Mar 2026 10:42:47 +0000 (03:42 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 31 Mar 2026 10:42:47 +0000 (03:42 -0700)
test/test.blake2b.mjs
test/test.ledger.mjs

index dc72417904e4f6954f8629336ad0ba9480b44728..40ec54441f5b3817cd9a8bbb1ae668841d4ae581 100644 (file)
@@ -83,6 +83,7 @@ await Promise.all([
                                        )\r
                                }\r
                                try {\r
+                                       /** @type {Uint8Array<ArrayBuffer>} */\r
                                        const output = new Blake2b(test.outlen ?? 64, key, salt, personal).update(input).digest()\r
                                        const hex = [...output].map(b => b.toString(16).padStart(2, '0')).join('')\r
                                        assert.equal(hex, test.out)\r
index 294220464e19782547dc77dbd4a73cd6f6ca4962..a4585dbb30464bf6a7b9d12a762f2f1dca8b8ebf 100644 (file)
@@ -10,14 +10,14 @@ import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs'
 const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME)
 
 /**
-* HID interactions require user gestures, so to reduce clicks, the variables
-* shared among tests like wallet and account are declared at the top-level.
-*
-* Some of these tests depend on a specific Ledger wallet owned by the developer
-* and dedicated to testing. Project clones or forks will need to modify the test
-* vectors to use the mnemonics, seeds, private keys, public keys, and addresses
-* from their own Ledger hardware wallets.
-*/
+ * HID interactions require user gestures, so to reduce clicks, the variables
+ * shared among tests like wallet and account are declared at the top-level.
+ *
+ * Some of these tests depend on a specific Ledger wallet owned by the developer
+ * and dedicated to testing. Project clones or forks will need to modify the
+ * test vectors to use the mnemonics, seeds, private keys, public keys, and
+ * addresses from their own Ledger hardware wallets.
+ */
 await Promise.all([
        suite('Ledger unsupported', { skip: !(isNode || navigator?.usb == null) }, async () => {
 
@@ -31,7 +31,12 @@ await Promise.all([
 
                const { LEDGER_NANOS, LEDGER_NANOSP } = CUSTOM_TEST_VECTORS
                const { OPEN_BLOCK, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS
-               let wallet, account, openBlock, sendBlock, receiveBlock, restored
+               let /** @type {Wallet} */ wallet,
+                       /** @type {Account} */ account,
+                       /** @type {Block} */ openBlock,
+                       /** @type {Block} */ sendBlock,
+                       /** @type {Block} */ receiveBlock,
+                       restored
                try {
                        wallet = await Wallet.create('Ledger')
                } catch {
@@ -224,7 +229,7 @@ await Promise.all([
 
                        assert.exists(accounts)
                        assert.equal(accounts.size, 2)
-                       for (const [ index, account ] of accounts) {
+                       for (const [index, account] of accounts) {
                                assert.ok(account instanceof Account)
                                assert.exists(account.address)
                                assert.exists(account.publicKey)
@@ -236,7 +241,7 @@ await Promise.all([
                        const accounts = await wallet.refresh(rpc, 0, 2)
 
                        assert.exists(accounts)
-                       for (const [ index, account ] of accounts) {
+                       for (const [index, account] of accounts) {
                                assert.ok(account instanceof Account)
                                assert.exists(account.address)
                                assert.exists(account.publicKey)