From: Chris Duncan Date: Sat, 11 Oct 2025 08:47:23 +0000 (-0700) Subject: Formatting. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=b5360aa878cb29e709388afe6758e0324bce7ef2;p=libnemo.git Formatting. --- diff --git a/test/GLOBALS.mjs b/test/GLOBALS.mjs index f8a284b..29c7266 100644 --- a/test/GLOBALS.mjs +++ b/test/GLOBALS.mjs @@ -8,9 +8,9 @@ if (globalThis.sessionStorage == null) { Object.defineProperty(globalThis, 'sessionStorage', { value: { length: Object.entries(_sessionStorage).length, - setItem: (key, value) => _sessionStorage[key] = value, - getItem: (key) => _sessionStorage[key], - removeItem: (key) => delete _sessionStorage[key], + setItem: (key, value) => _sessionStorage[ key ] = value, + getItem: (key) => _sessionStorage[ key ], + removeItem: (key) => delete _sessionStorage[ key ], clear: () => _sessionStorage = {} }, configurable: true, @@ -113,7 +113,7 @@ export function stats (times) { times.sort((a, b) => a - b) for (let i = 0; i < count; i++) { - const time = times[i] + const time = times[ i ] total += time logarithms += Math.log(time) reciprocals += 1 / time @@ -123,7 +123,7 @@ export function stats (times) { if (i === Math.floor(count / 2) && count % 2 === 0) median = (median + time) / 2 } for (let i = truncatedStart; i < truncatedEnd; i++) { - const time = times[i] + const time = times[ i ] truncatedTotal += time truncatedLogarithms += Math.log(time) truncatedReciprocals += 1 / time @@ -270,7 +270,7 @@ export class assert { try { await fn throw new Error(msg ?? 'expected async function to reject') - } catch {} + } catch { } } else { throw new Error(msg ?? 'expected async function') } @@ -306,6 +306,6 @@ export class assert { try { fn() throw new Error(msg ?? `expected function to throw an exception`) - } catch {} + } catch { } } } diff --git a/test/test.blake2b.mjs b/test/test.blake2b.mjs index dc72417..082ee04 100644 --- a/test/test.blake2b.mjs +++ b/test/test.blake2b.mjs @@ -12,7 +12,7 @@ await Promise.all([ await test('check 512 reference test vectors', async () => { for (let i = 0; i < BLAKE2B_TEST_VECTORS.REFERENCE.length; i++) { - const test = BLAKE2B_TEST_VECTORS.REFERENCE[i] + const test = BLAKE2B_TEST_VECTORS.REFERENCE[ i ] if (test.in.length % 2 === 1) test.in = `0${test.in}` const input = Uint8Array.from(test.in .split(/(.{2})/) @@ -32,7 +32,7 @@ await Promise.all([ } try { const output = new Blake2b(64, key).update(input).digest() - const hex = [...output].map(b => b.toString(16).padStart(2, '0')).join('') + const hex = [ ...output ].map(b => b.toString(16).padStart(2, '0')).join('') assert.equal(hex, test.out) } catch (err) { console.error(`blake2b reference test vector ${i} failed`, { cause: err }) @@ -42,7 +42,7 @@ await Promise.all([ await test('check 64 libsodium test vectors', async () => { for (let i = 0; i < BLAKE2B_TEST_VECTORS.LIBSODIUM.length; i++) { - const test = BLAKE2B_TEST_VECTORS.LIBSODIUM[i] + const test = BLAKE2B_TEST_VECTORS.LIBSODIUM[ i ] if (test.in.length % 2 === 1) test.in = `0${test.in}` const input = Uint8Array.from(test.in .split(/(.{2})/) @@ -84,7 +84,7 @@ await Promise.all([ } try { 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('') + const hex = [ ...output ].map(b => b.toString(16).padStart(2, '0')).join('') assert.equal(hex, test.out) } catch (err) { console.error(`blake2b libsodium test vector ${i} failed`, { cause: err }) diff --git a/test/test.calculate-pow.mjs b/test/test.calculate-pow.mjs index 233a1de..37cb3b2 100644 --- a/test/test.calculate-pow.mjs +++ b/test/test.calculate-pow.mjs @@ -24,12 +24,12 @@ await Promise.all([ .reverse() if (work == null) throw new Error('Work invalid') - const bytes = new Uint8Array([...work, ...block.previous]) + const bytes = new Uint8Array([ ...work, ...block.previous ]) assert.equal(bytes.byteLength, 40) const hash = new Blake2b(8).update(bytes).digest() - assert.ok(hash[4] > 0xf0) + assert.ok(hash[ 4 ] > 0xf0) assert.ok(hash.subarray(5).every(b => b === 0xff)) }) }) diff --git a/test/test.create-wallet.mjs b/test/test.create-wallet.mjs index a7209bc..9373c4c 100644 --- a/test/test.create-wallet.mjs +++ b/test/test.create-wallet.mjs @@ -61,7 +61,7 @@ await Promise.all([ }) await test('BIP-44 throw on invalid salt', async () => { - const invalidArgs = [null, true, false, 0, 1, 2, { foo: 'bar' }] + const invalidArgs = [ null, true, false, 0, 1, 2, { foo: 'bar' } ] for (const arg of invalidArgs) { //@ts-expect-error await assert.rejects(Wallet.create('BIP-44', PASSWORD, arg)) diff --git a/test/test.ledger.mjs b/test/test.ledger.mjs index 0a64da4..2a34db2 100644 --- a/test/test.ledger.mjs +++ b/test/test.ledger.mjs @@ -133,7 +133,7 @@ await Promise.all([ await assert.resolves(async () => { await click( 'Unlock device again, then click to continue', - async () => {} + async () => { } ) }) assert.equal(wallet.isLocked, false) @@ -205,7 +205,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) @@ -217,7 +217,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) diff --git a/test/test.manage-rolodex.mjs b/test/test.manage-rolodex.mjs index 920a90c..6544e4c 100644 --- a/test/test.manage-rolodex.mjs +++ b/test/test.manage-rolodex.mjs @@ -24,18 +24,18 @@ await Promise.all([ let names = await Rolodex.getAllNames() assert.ok(Array.isArray(names)) assert.equal(names.length, 2) - assert.equal(names[0], 'JaneSmith') - assert.equal(names[1], 'JohnDoe') + assert.equal(names[ 0 ], 'JaneSmith') + assert.equal(names[ 1 ], 'JohnDoe') const addressesJohnDoe = await Rolodex.getAddresses('JohnDoe') const addressesJaneSmith = await Rolodex.getAddresses('JaneSmith') assert.ok(Array.isArray(addressesJohnDoe)) assert.equal(addressesJohnDoe.length, 1) - assert.equal(addressesJohnDoe[0], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(addressesJohnDoe[ 0 ], NANO_TEST_VECTORS.ADDRESS_0) assert.ok(Array.isArray(addressesJaneSmith)) assert.equal(addressesJaneSmith.length, 1) - assert.equal(addressesJaneSmith[0], NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(addressesJaneSmith[ 0 ], NANO_TEST_VECTORS.ADDRESS_1) const deleteJohnDoe = await Rolodex.deleteName('JohnDoe') const deleteJaneSmith = await Rolodex.deleteName('JaneSmith') @@ -64,16 +64,16 @@ await Promise.all([ let addresses = await Rolodex.getAddresses('JohnDoe') assert.ok(Array.isArray(addresses)) assert.equal(addresses.length, 3) - assert.equal(addresses[0], NANO_TEST_VECTORS.ADDRESS_0) - assert.equal(addresses[1], NANO_TEST_VECTORS.ADDRESS_2) - assert.equal(addresses[2], NANO_TEST_VECTORS.ADDRESS_1) + assert.equal(addresses[ 0 ], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(addresses[ 1 ], NANO_TEST_VECTORS.ADDRESS_2) + assert.equal(addresses[ 2 ], NANO_TEST_VECTORS.ADDRESS_1) await assert.resolves(Rolodex.deleteAddress(NANO_TEST_VECTORS.ADDRESS_1)) addresses = await Rolodex.getAddresses('JohnDoe') assert.ok(Array.isArray(addresses)) assert.equal(addresses.length, 2) - assert.equal(addresses[0], NANO_TEST_VECTORS.ADDRESS_0) - assert.equal(addresses[1], NANO_TEST_VECTORS.ADDRESS_2) + assert.equal(addresses[ 0 ], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(addresses[ 1 ], NANO_TEST_VECTORS.ADDRESS_2) await assert.resolves(Rolodex.deleteName('JohnDoe')) addresses = await Rolodex.getAddresses('JohnDoe') @@ -98,7 +98,7 @@ await Promise.all([ assert.equal(addressesJohnDoe.length, 0) assert.ok(Array.isArray(addressesJaneSmith)) assert.equal(addressesJaneSmith.length, 1) - assert.equal(addressesJaneSmith[0], NANO_TEST_VECTORS.ADDRESS_0) + assert.equal(addressesJaneSmith[ 0 ], NANO_TEST_VECTORS.ADDRESS_0) await assert.resolves(Rolodex.deleteName('JohnDoe')) await assert.resolves(Rolodex.deleteName('JaneSmith')) diff --git a/test/test.runner-check.mjs b/test/test.runner-check.mjs index 547a9ef..2610610 100644 --- a/test/test.runner-check.mjs +++ b/test/test.runner-check.mjs @@ -12,7 +12,7 @@ if (!isNode) { //@ts-expect-error await test('promise should pass', new Promise(resolve => resolve(null))) - console.assert(failures.some(call => /.*promise should pass.*/.test(call[0])) === false, `good promise errored`) + console.assert(failures.some(call => /.*promise should pass.*/.test(call[ 0 ])) === false, `good promise errored`) console.assert(passes.some(call => /.*promise should pass.*/.test(call)) === true, `good promise not logged`) //@ts-expect-error @@ -20,7 +20,7 @@ if (!isNode) { console.assert(failures.some(call => /.*promise should fail.*/.test(call)) === true, `bad promise not errored`) console.assert(passes.some(call => /.*promise should fail.*/.test(call)) === false, 'bad promise logged') - await test('async should pass', async () => {}) + await test('async should pass', async () => { }) console.assert(failures.some(call => /.*async should pass.*/.test(call)) === false, 'good async errored') console.assert(passes.some(call => /.*async should pass.*/.test(call)) === true, 'good async not logged') @@ -28,7 +28,7 @@ if (!isNode) { console.assert(failures.some(call => /.*async should fail.*/.test(call)) === true, 'bad async not errored') console.assert(passes.some(call => /.*async should fail.*/.test(call)) === false, 'bad async logged') - await test('function should pass', () => {}) + await test('function should pass', () => { }) console.assert(failures.some(call => /.*function should pass.*/.test(call)) === false, 'good function errored') console.assert(passes.some(call => /.*function should pass.*/.test(call)) === true, 'good function not logged')