--- /dev/null
+# SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Save this file as `.env` and replace the following with real values
+NODE_URL="https://rpc.example.com"
+API_KEY_NAME="api_key"
+LIBNEMO_RPC_API_KEY="fedcba9876543210fedcba9876543210"
--- /dev/null
+// SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+'use strict'
+
+// Save this file as `env.mjs` and replace the following with real values
+const env = {
+ NODE_URL: "https://rpc.example.com",
+ API_KEY_NAME: "api_key",
+ LIBNEMO_RPC_API_KEY: "fedcba9876543210fedcba9876543210"
+}
+
+var process = process || { env }
+process.env ??= env
+process.NODE_URL ??= env.NODE_URL
+process.API_KEY_NAME ??= env.API_KEY_NAME
+process.LIBNEMO_RPC_API_KEY ??= env.LIBNEMO_RPC_API_KEY
+
+export { process }
// SPDX-License-Identifier: GPL-3.0-or-later
import { Queue } from './QUEUE.mjs'
+import { process } from '../env.mjs'
const queue = new Queue()
enumerable: true
})
}
+export { process }
+
+export const isNode = process.versions?.node != null
export function stats (times) {
if (times == null || times.length === 0) return null
\r
'use strict'\r
\r
-import { assert, suite, test } from './GLOBALS.mjs'\r
+import { assert, isNode, suite, test } from './GLOBALS.mjs'\r
import { NANO_TEST_VECTORS } from './VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '../dist/main.min.js'\r
\r
await assert.rejects(Blake2bWallet.create())\r
})\r
\r
- await test('connect to a Ledger device', { skip: false }, async () => {\r
+ await test('connect to a Ledger device', { skip: false || isNode }, async () => {\r
const wallet = await LedgerWallet.create()\r
let status = await new Promise(resolve => {\r
const button = document.createElement('button')\r
\r
'use strict'\r
\r
-import { assert, suite, test } from './GLOBALS.mjs'\r
+import { assert, isNode, suite, test } from './GLOBALS.mjs'\r
import { NANO_TEST_VECTORS } from './VECTORS.js'\r
import { Bip44Wallet, Blake2bWallet, LedgerWallet } from '../dist/main.min.js'\r
\r
\r
await wallet.destroy()\r
})\r
+})\r
\r
- await test('fetch the first account from a Ledger device', { skip: true }, async () => {\r
- const wallet = await LedgerWallet.create()\r
- const accounts = await wallet.accounts()\r
+/**\r
+* This suite requires a connected unlocked Ledger device to execute tests.\r
+*/\r
+await suite('should derive accounts for a Ledger device wallet', { skip: false || isNode }, async () => {\r
+ const wallet = await LedgerWallet.create()\r
+ await wallet.connect()\r
\r
- assert.equals(accounts.length, 1)\r
- assert.exists(accounts[0].publicKey)\r
- assert.exists(accounts[0].address)\r
+ await test('fetch the first account from a Ledger device', async () => {\r
+ const account = await wallet.account()\r
\r
- await wallet.destroy()\r
+ assert.exists(account.publicKey)\r
+ assert.exists(account.address)\r
+ assert.exists(account.privateKey)\r
+ assert.equals(account.privateKey, '0000000000000000000000000000000000000000000000000000000000000000')\r
})\r
+\r
+ await test('fail to return multiple accounts from a Ledger device', async () => {\r
+ assert.rejects(wallet.accounts())\r
+ })\r
+\r
+ await wallet.destroy()\r
})\r
'use strict'
-import { env } from '../env.mjs'
-import { assert, suite, test } from './GLOBALS.mjs'
+import { assert, process, suite, test } from './GLOBALS.mjs'
import { NANO_TEST_VECTORS } from './VECTORS.js'
import { Account, Bip44Wallet, Rpc } from '../dist/main.min.js'
-let rpc
-var process = process || env || null
-rpc = new Rpc(process?.env?.NODE_URL ?? '', process?.env?.API_KEY_NAME)
+const rpc = new Rpc(process.env.NODE_URL ?? '', process.env.API_KEY_NAME)
await suite('refreshing account info', { skip: false }, async () => {