]> git.codecow.com Git - libnemo.git/commitdiff
Formatting.
authorChris Duncan <chris@zoso.dev>
Sat, 11 Oct 2025 08:47:23 +0000 (01:47 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 11 Oct 2025 08:47:23 +0000 (01:47 -0700)
test/GLOBALS.mjs
test/test.blake2b.mjs
test/test.calculate-pow.mjs
test/test.create-wallet.mjs
test/test.ledger.mjs
test/test.manage-rolodex.mjs
test/test.runner-check.mjs

index f8a284b853eaf7e805c15c2d54a0acacde0871fe..29c726638371daa547ba5147bd07348068da9a81 100644 (file)
@@ -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 { }
        }
 }
index dc72417904e4f6954f8629336ad0ba9480b44728..082ee04f8eed83126d8503efc57cf395008356b0 100644 (file)
@@ -12,7 +12,7 @@ await Promise.all([
 \r
                await test('check 512 reference test vectors', async () => {\r
                        for (let i = 0; i < BLAKE2B_TEST_VECTORS.REFERENCE.length; i++) {\r
-                               const test = BLAKE2B_TEST_VECTORS.REFERENCE[i]\r
+                               const test = BLAKE2B_TEST_VECTORS.REFERENCE[ i ]\r
                                if (test.in.length % 2 === 1) test.in = `0${test.in}`\r
                                const input = Uint8Array.from(test.in\r
                                        .split(/(.{2})/)\r
@@ -32,7 +32,7 @@ await Promise.all([
                                }\r
                                try {\r
                                        const output = new Blake2b(64, key).update(input).digest()\r
-                                       const hex = [...output].map(b => b.toString(16).padStart(2, '0')).join('')\r
+                                       const hex = [ ...output ].map(b => b.toString(16).padStart(2, '0')).join('')\r
                                        assert.equal(hex, test.out)\r
                                } catch (err) {\r
                                        console.error(`blake2b reference test vector ${i} failed`, { cause: err })\r
@@ -42,7 +42,7 @@ await Promise.all([
 \r
                await test('check 64 libsodium test vectors', async () => {\r
                        for (let i = 0; i < BLAKE2B_TEST_VECTORS.LIBSODIUM.length; i++) {\r
-                               const test = BLAKE2B_TEST_VECTORS.LIBSODIUM[i]\r
+                               const test = BLAKE2B_TEST_VECTORS.LIBSODIUM[ i ]\r
                                if (test.in.length % 2 === 1) test.in = `0${test.in}`\r
                                const input = Uint8Array.from(test.in\r
                                        .split(/(.{2})/)\r
@@ -84,7 +84,7 @@ await Promise.all([
                                }\r
                                try {\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
+                                       const hex = [ ...output ].map(b => b.toString(16).padStart(2, '0')).join('')\r
                                        assert.equal(hex, test.out)\r
                                } catch (err) {\r
                                        console.error(`blake2b libsodium test vector ${i} failed`, { cause: err })\r
index 233a1de6ca787ebe43d1bbe836a4a07d4e11a7b8..37cb3b2c29e2fc57314db290c031ce60c2e467c9 100644 (file)
@@ -24,12 +24,12 @@ await Promise.all([
                                .reverse()\r
                        if (work == null) throw new Error('Work invalid')\r
 \r
-                       const bytes = new Uint8Array([...work, ...block.previous])\r
+                       const bytes = new Uint8Array([ ...work, ...block.previous ])\r
                        assert.equal(bytes.byteLength, 40)\r
 \r
                        const hash = new Blake2b(8).update(bytes).digest()\r
 \r
-                       assert.ok(hash[4] > 0xf0)\r
+                       assert.ok(hash[ 4 ] > 0xf0)\r
                        assert.ok(hash.subarray(5).every(b => b === 0xff))\r
                })\r
        })\r
index a7209bc0535f09369bf9faca59ce22f2e88a707b..9373c4c30f0e27802a3c9310a122082cfe59f566 100644 (file)
@@ -61,7 +61,7 @@ await Promise.all([
                })\r
 \r
                await test('BIP-44 throw on invalid salt', async () => {\r
-                       const invalidArgs = [null, true, false, 0, 1, 2, { foo: 'bar' }]\r
+                       const invalidArgs = [ null, true, false, 0, 1, 2, { foo: 'bar' } ]\r
                        for (const arg of invalidArgs) {\r
                                //@ts-expect-error\r
                                await assert.rejects(Wallet.create('BIP-44', PASSWORD, arg))\r
index 0a64da4233b110a08892053de383f53fd13b18c5..2a34db2a23c5cdac14304cb11e1676b87afaf9ac 100644 (file)
@@ -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)
index 920a90c1011000680559e6e20808428e265efb4d..6544e4c45d08a3523de08b670c30ffecdef06f0e 100644 (file)
@@ -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'))
index 547a9efc7d6be66a08babe3976d5952ec8263d2d..2610610a5ca243e8c18585be699f843507de7a99 100644 (file)
@@ -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')