From: Chris Duncan Date: Tue, 31 Mar 2026 10:42:47 +0000 (-0700) Subject: Add types to test files where ambiguous. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=dc94d1c87f02beea3a79001c2e705b1d1371f869;p=libnemo.git Add types to test files where ambiguous. --- diff --git a/test/test.blake2b.mjs b/test/test.blake2b.mjs index dc72417..40ec544 100644 --- a/test/test.blake2b.mjs +++ b/test/test.blake2b.mjs @@ -83,6 +83,7 @@ await Promise.all([ ) } try { + /** @type {Uint8Array} */ const output = new Blake2b(test.outlen ?? 64, key, salt, personal).update(input).digest() const hex = [...output].map(b => b.toString(16).padStart(2, '0')).join('') assert.equal(hex, test.out) diff --git a/test/test.ledger.mjs b/test/test.ledger.mjs index 2942204..a4585db 100644 --- a/test/test.ledger.mjs +++ b/test/test.ledger.mjs @@ -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)