notEqual: (a, b) => {
return a !== b
},
- rejects: (fn, msg) => {
+ rejects: async (fn, msg) => {
try {
if (!(fn instanceof Promise)) throw new Error(msg ?? 'expected async function')
fn.then(() => { throw new Error(msg ?? 'expected async function to reject') })
return true
}
},
- resolves: (fn, msg) => {
+ resolves: async (fn, msg) => {
try {
if (!(fn instanceof Promise)) throw new Error('expected async function')
fn.then(() => { return true })
},
throws: (fn, msg) => {
try {
- const r = fn()
- if (r instanceof Promise) throw new Error('expected synchronous function')
+ if (fn instanceof Promise) throw new Error('expected synchronous function')
+ fn()
throw new Error(msg ?? `expected function to throw an exception`)
} catch (err) {
return true
const invalidArgs = [null, true, false, 0, 1, 2, { "foo": "bar" }]\r
for (const arg of invalidArgs) {\r
//@ts-expect-error\r
- assert.resolves(Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD, arg))\r
+ await assert.resolves(Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD, arg))\r
}\r
})\r
\r
\r
test('fail without a password', async () => {\r
//@ts-expect-error\r
- assert.rejects(Bip44Wallet.create())\r
+ await assert.rejects(Bip44Wallet.create())\r
//@ts-expect-error\r
- assert.rejects(Blake2bWallet.create())\r
+ await assert.rejects(Blake2bWallet.create())\r
})\r
\r
skip('connect to ledger', async () => {\r
\r
test('invalid wallet', async () => {\r
test('throw when given invalid entropy', async () => {\r
- assert.rejects(async () => await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C797'))\r
- assert.rejects(async () => await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C79701'))\r
- assert.rejects(async () => await Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0.replaceAll(/./g, 'x')))\r
+ await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C797'))\r
+ await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, '6CAF5A42BB8074314AAE20295975ECE663BE7AAD945A73613D193B0CC41C79701'))\r
+ await assert.rejects(Bip44Wallet.fromEntropy(NANO_TEST_VECTORS.PASSWORD, TREZOR_TEST_VECTORS.ENTROPY_0.replaceAll(/./g, 'x')))\r
})\r
\r
test('should throw when given a seed with an invalid length', async () => {\r