'use strict'
-import { assert, click, isNode, suite, test } from './GLOBALS.mjs'
+import { assert, click, isNode, process, suite, test } from './GLOBALS.mjs'
import { NANO_TEST_VECTORS } from './VECTORS.js'
-import { Account, LedgerWallet, ReceiveBlock, SendBlock } from '../dist/main.min.js'
+import { Account, LedgerWallet, ReceiveBlock, Rpc, SendBlock } from '../dist/main.min.js'
+
+const rpc = new Rpc(process.env.NODE_URL ?? '', process.env.API_KEY_NAME)
/**
* HID interactions require user gestures, so to reduce clicks, the variables
}
})
+ await test('refresh first three accounts (must already be opened to be refreshed)', async () => {
+ const accounts = await wallet.refresh(rpc, 0, 2)
+
+ assert.exists(accounts)
+ for (const account of accounts) {
+ assert.ok(account instanceof Account)
+ assert.exists(account.address)
+ assert.exists(account.balance)
+ assert.ok(account.balance >= 0)
+ assert.exists(account.publicKey)
+ assert.exists(account.privateKey)
+ assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')
+ }
+ })
+
await test('sign open block from block', async () => {
openBlock = new ReceiveBlock(
account,
assert.ok(/[A-Fa-f0-9]{128}/.test(receiveBlock.signature))
})
- await test('destroy wallet', async () => {
- await assert.resolves(wallet.destroy())
- })
-
// nonce signing is currently broken: https://github.com/LedgerHQ/app-nano/pull/14
await test('sign a nonce', { skip: true }, async () => {
const nonce = new TextEncoder().encode('0123456789abcdef')
assert.OK(/[A-Fa-f0-9]{128}/.test(signature))
})
+ await test('destroy wallet', async () => {
+ await assert.resolves(wallet.destroy())
+ })
+
await test('fail when using new', async () => {
assert.throws(() => new LedgerWallet())
})