})
console.log('> rolodex data signature verification <')
-const data = 'Test data'
-const signature = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, data)
-const rolodex = new Rolodex()
test('should verify valid data and signature', async () => {
+ const data = 'Test data'
+ const signature = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, data)
+ const rolodex = new Rolodex()
await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
const result = await rolodex.verify('JohnDoe', signature, data)
assert.equals(result, true)
})
test('should reject incorrect contact for signature', async () => {
+ const data = 'Test data'
+ const signature = await Tools.sign(NANO_TEST_VECTORS.PRIVATE_0, data)
+ const rolodex = new Rolodex()
await rolodex.add('JaneSmith', NANO_TEST_VECTORS.ADDRESS_1)
const result = await rolodex.verify('JaneSmith', signature, data)
assert.equals(result, false)
import { NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'
import { Account, Bip44Wallet, Rpc } from '#dist/main.js'
-const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
-await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
let rpc
//@ts-ignore
var process = process || null
console.log('refreshing account info')
test('fetch balance, frontier, and representative', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.accounts()
const account = accounts[0]
await account.refresh(rpc)
})
test('throw when refreshing unopened account', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.accounts(0x7fffffff)
const account = accounts[0]
await assert.rejects(account.refresh(rpc),
})
test('throw when referencing invalid account index', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.rejects(wallet.accounts(0x80000000),
{ message: 'Invalid child key index 0x80000000' })
})
test('throw with invalid node', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const invalidNode = new Rpc('http://invalid.com')
const accounts = await wallet.accounts()
const account = accounts[0]
console.log('finding next unopened account')
test('return correct account from test vector', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc)
assert.ok(account)
assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1)
})
test('return successfully for small batch size', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc, 1)
assert.ok(account)
assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1)
})
test('return successfully for large batch size', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const account = await wallet.getNextNewAccount(rpc, 100)
assert.ok(account)
assert.equals(account.address, NANO_TEST_VECTORS.ADDRESS_1)
})
test('should throw on invalid node URL', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
await assert.rejects(wallet.getNextNewAccount())
//@ts-expect-error
})
test('should throw on invalid batch size', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
//@ts-expect-error
await assert.rejects(wallet.getNextNewAccount(rpc, null))
await assert.rejects(wallet.getNextNewAccount(rpc, -1))
console.log('> refreshing wallet accounts <')
skip('should get balance, frontier, and representative for one account', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc)
const account = accounts[0]
assert.ok(account instanceof Account)
})
skip('should get balance, frontier, and representative for multiple accounts', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
const accounts = await wallet.refresh(rpc, 0, 2)
assert.equals(accounts.length, 1)
assert.ok(accounts[0] instanceof Account)
})
skip('should handle failure gracefully', async () => {
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)
await assert.doesNotReject(wallet.refresh(rpc, 0, 20))
})
import { RAW_MAX, NANO_TEST_VECTORS } from '#test/TEST_VECTORS.js'\r
import { Bip44Wallet, Account, SendBlock, Rpc, Tools } from '#dist/main.js'\r
\r
-const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
-await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
let rpc\r
//@ts-ignore\r
var process = process || null\r
})\r
\r
test('should verify a block using the public key', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
const account = accounts[0]\r
const sendBlock = new SendBlock(\r
})\r
\r
test('should reject a block using the wrong public key', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const accounts = await wallet.accounts()\r
const account = accounts[0]\r
const sendBlock = new SendBlock(\r
})\r
\r
skip('sweeper fails gracefully for ineligible accounts', async () => {\r
+ const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
const results = await Tools.sweep(rpc, wallet, NANO_TEST_VECTORS.ADDRESS_1)\r
assert.ok(results)\r
assert.equals(results.length, 1)\r