var process = process || env || null
rpc = new Rpc(process?.env?.NODE_URL ?? '', process?.env?.API_KEY_NAME)
-await suite('refreshing account info', { skip: true }, async () => {
+await suite('refreshing account info', { skip: false }, async () => {
await 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]
+ const account = await wallet.account()
await account.refresh(rpc)
assert.equals(typeof account.balance, 'bigint')
- assert.notEqual(account.balance, undefined)
- assert.notEqual(account.balance, null)
+ assert.exists(account.balance)
assert.notEqual(account.balance, '')
assert.notEqual(account.balance && account.balance < 0, true)
+ assert.exists(account.frontier)
assert.equals(typeof account.frontier, 'string')
- assert.notEqual(account.frontier, undefined)
- assert.notEqual(account.frontier, null)
assert.notEqual(account.frontier, '')
- assert.match(account.frontier ?? '', /^[0-9A-F]{64}$/i)
+ assert.ok(/^[A-Fa-f0-9]{64}$/.test(account.frontier))
assert.equals(account.representative && account.representative.constructor, Account)
- assert.notEqual(account.representative, undefined)
- assert.notEqual(account.representative, null)
+ assert.exists(account.representative)
assert.notEqual(account.representative, '')
- assert.notEqual(account.representative?.address, undefined)
- assert.notEqual(account.representative?.address, null)
+ assert.exists(account.representative?.address)
assert.notEqual(account.representative?.address, '')
await wallet.destroy()
await 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]
+ const account = await wallet.account(0x7fffffff)
+
await assert.rejects(account.refresh(rpc),
{ message: 'Account not found' })
await 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),
+ await assert.rejects(wallet.account(0x80000000),
{ message: 'Invalid child key index 0x80000000' })
+
+ await wallet.destroy()
})
await 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]
+ const account = await wallet.account()
+
await assert.rejects(account.refresh(invalidNode),
{ message: 'Account not found' })
})
})
-await suite('Fetch next unopened account', { skip: true }, async () => {
+await suite('Fetch next unopened account', { skip: false }, async () => {
await test('return correct account from test vector', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
})
})
-await suite('Refreshing wallet accounts', { skip: true }, async () => {
+await suite('Refreshing wallet accounts', { skip: false }, async () => {
await test('should get balance, frontier, and representative for one account', async () => {
const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)
const account = accounts[0]
assert.ok(account instanceof Account)
assert.equals(typeof account.balance, 'bigint')
- assert.notEqual(account.frontier, undefined)
- assert.notEqual(account.frontier, null)
+ assert.exists(account.frontier)
assert.equals(typeof account.frontier, 'string')
await wallet.destroy()