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,
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
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
try {
await fn
throw new Error(msg ?? 'expected async function to reject')
- } catch {}
+ } catch { }
} else {
throw new Error(msg ?? 'expected async function')
}
try {
fn()
throw new Error(msg ?? `expected function to throw an exception`)
- } catch {}
+ } catch { }
}
}
\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
}\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
\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
}\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
.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
})\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
await assert.resolves(async () => {
await click(
'Unlock device again, then click to continue',
- async () => {}
+ async () => { }
)
})
assert.equal(wallet.isLocked, false)
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)
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)
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')
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')
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'))
//@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
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')
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')