const testOpenBlock = await new Block(testAccount.address, '0', testAccount.publicKey, testAccount.address)
.receive(testAccount.publicKey, 0)
.sign(testWallet, 0)
- const testSendBlock = new Block(testAccount.address, '0', testOpenBlock.hash, testAccount.address)
+ const testSendBlock = await new Block(testAccount.address, '0', testOpenBlock.hash, testAccount.address)
.send(testAccount.address, 0)
- await testWallet.sign(0, testOpenBlock)
+ .sign(testWallet, 0)
+ const testSignature = testSendBlock.signature
try {
- await Ledger.sign(0, testSendBlock, testOpenBlock)
- return testSendBlock.signature === testOpenBlock.signature
+ const ledgerSignature = await Ledger.sign(0, testSendBlock, testOpenBlock)
+ return ledgerSignature === testSignature
} catch (err) {
throw new Error('Failed to verify wallet', { cause: err })
}
// derived using BIP-44 from actual Ledger Nano S hardware wallet designated for dedicated testing
LEDGER_MNEMONIC: "slight govern pepper assist escape target bread repair long faith maid bread donor situate swamp toss garage master stage gift vendor jacket client upset",
+ LEDGER_SEED: "1913E77BCFD9AA95BCB5171B1E781EC0EA3531F1FC427686D8BBA3D655BEFA43FDED6985B5E5806199A33539332DF8780426EDAD17E7BC2D95324D678BEEEE34",
LEDGER_PRIVATE_0: "174A5E324A107D66E1AB17D9BCFC676D89F2940A4B90CB64A6656005756EBDA1",
LEDGER_PUBLIC_0: "4423C456B9AF40A82807114BA3F77822E5CE1E5B4C2885296C6BBE7B9B377D48",
LEDGER_ADDRESS_0: "nano_1j35rjddmdt1o1n1g6cdnhuqiaq7srh7pm3ainnprtxyhgfmgzcat494fyrr",
'use strict'
import { assert, click, env, isNode, suite, test } from './GLOBALS.mjs'
-import { NANO_TEST_VECTORS } from './VECTORS.mjs'
+import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs'
/**
* @type {typeof import('../dist/types.d.ts').Account}
/**
* HID interactions require user gestures, so to reduce clicks, the variables
* shared among tests like wallet and account are declared at the top-level.
+*
+* Some of these tests depend on a specific Ledger wallet owned by the developer
+* and dedicated to testing. Project clones or forks will need to modify the test
+* vectors to use the mnemonics, seeds, private keys, public keys, and addresses
+* from their own Ledger hardware wallets.
*/
await Promise.all([
/* node:coverage disable */
suite('Ledger hardware wallet', { skip: false || isNode || navigator?.usb == null }, async () => {
+ const { LEDGER_MNEMONIC, LEDGER_SEED, LEDGER_PUBLIC_0, LEDGER_ADDRESS_0 } = CUSTOM_TEST_VECTORS
const { OPEN_BLOCK, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS
let wallet, account, openBlock, sendBlock, receiveBlock
try {
assert.equal(wallet.isLocked, false)
})
+ await test('verify mnemonic', async () => {
+ const isVerified = await wallet.verify(LEDGER_MNEMONIC)
+
+ assert.exists(isVerified)
+ assert.equal(typeof isVerified, 'boolean')
+ assert.equal(isVerified, true)
+ })
+
+ await test('verify seed', async () => {
+ const isVerified = await wallet.verify(LEDGER_SEED)
+
+ assert.exists(isVerified)
+ assert.equal(typeof isVerified, 'boolean')
+ assert.equal(isVerified, true)
+ })
+
await test('get first account', async () => {
account = await wallet.account()
assert.exists(account)
assert.ok(account instanceof Account)
- assert.exists(account.address)
assert.exists(account.publicKey)
+ assert.equal(account.publicKey, LEDGER_PUBLIC_0)
+ assert.exists(account.address)
+ assert.equal(account.address, LEDGER_ADDRESS_0)
})
await test('get second and third accounts', async () => {