const skip = true
describe('refreshing account info', { skip }, async () => {
- it('should fetch balance, frontier, and representative', async () => {
- const accounts = await wallet.accounts()
- const account = accounts[0]
- await account.refresh(node)
-
- assert.equal(typeof account.balance, 'string')
- assert.notEqual(account.balance, undefined)
- assert.notEqual(account.balance, null)
- assert.notEqual(account.balance, '')
- assert.equal(isNaN(parseInt(account.balance)), false)
- assert.equal(parseInt(account.balance) < 0, false)
-
- assert.equal(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.equal(account.representative.constructor, Account)
- assert.notEqual(account.representative, undefined)
- assert.notEqual(account.representative, null)
- assert.notEqual(account.representative, '')
- assert.notEqual(account.representative.address, undefined)
- assert.notEqual(account.representative.address, null)
- assert.notEqual(account.representative.address, '')
- })
-
- it('should throw when refreshing unopened account', async () => {
- const accounts = await wallet.accounts(0x7fffffff)
- const account = accounts[0]
- await assert.rejects(account.refresh(node),
- { message: 'Account not found' })
- })
-
- it('should throw when referencing invalid account index', async () => {
- await assert.rejects(wallet.accounts(0x80000000),
- { message: 'Invalid child key index 0x80000000' })
- })
-
- it('should throw with invalid node', async () => {
- const invalidNode = new Node('http://invalid.com')
- const accounts = await wallet.accounts()
- const account = accounts[0]
- await assert.rejects(account.refresh(invalidNode),
- { message: 'Account not found' })
- })
+ it('should fetch balance, frontier, and representative', async () => {
+ const accounts = await wallet.accounts()
+ const account = accounts[0]
+ await account.refresh(node)
+
+ assert.equal(typeof account.balance, 'string')
+ assert.notEqual(account.balance, undefined)
+ assert.notEqual(account.balance, null)
+ assert.notEqual(account.balance, '')
+ assert.equal(isNaN(parseInt(account.balance)), false)
+ assert.equal(parseInt(account.balance) < 0, false)
+
+ assert.equal(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.equal(account.representative.constructor, Account)
+ assert.notEqual(account.representative, undefined)
+ assert.notEqual(account.representative, null)
+ assert.notEqual(account.representative, '')
+ assert.notEqual(account.representative.address, undefined)
+ assert.notEqual(account.representative.address, null)
+ assert.notEqual(account.representative.address, '')
+ })
+
+ it('should throw when refreshing unopened account', async () => {
+ const accounts = await wallet.accounts(0x7fffffff)
+ const account = accounts[0]
+ await assert.rejects(account.refresh(node),
+ { message: 'Account not found' })
+ })
+
+ it('should throw when referencing invalid account index', async () => {
+ await assert.rejects(wallet.accounts(0x80000000),
+ { message: 'Invalid child key index 0x80000000' })
+ })
+
+ it('should throw with invalid node', async () => {
+ const invalidNode = new Node('http://invalid.com')
+ const accounts = await wallet.accounts()
+ const account = accounts[0]
+ await assert.rejects(account.refresh(invalidNode),
+ { message: 'Account not found' })
+ })
})
describe('finding next unopened account', { skip }, async () => {
- it('should return correct account from test vector', async () => {
- const account = await wallet.getNextNewAccount(node)
- assert.ok(account)
- assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
- assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
- })
-
- it('should return successfully for small batch size', async () => {
- const account = await wallet.getNextNewAccount(node, 1)
- assert.ok(account)
- assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
- assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
- })
-
- it('should return successfully for large batch size', async () => {
- const account = await wallet.getNextNewAccount(node, 100)
- assert.ok(account)
- assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
- assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
- })
-
- it('should throw on invalid node URL', async () => {
- await assert.rejects(wallet.getNextNewAccount())
- await assert.rejects(wallet.getNextNewAccount(null))
- await assert.rejects(wallet.getNextNewAccount(1))
- await assert.rejects(wallet.getNextNewAccount(''))
- await assert.rejects(wallet.getNextNewAccount('foo'))
- })
-
- it('should throw on invalid batch size', async () => {
- await assert.rejects(wallet.getNextNewAccount(node, null))
- await assert.rejects(wallet.getNextNewAccount(node, -1))
- await assert.rejects(wallet.getNextNewAccount(node, ''))
- await assert.rejects(wallet.getNextNewAccount(node, 'foo'))
- await assert.rejects(wallet.getNextNewAccount(node, { 'foo': 'bar' }))
- })
+ it('should return correct account from test vector', async () => {
+ const account = await wallet.getNextNewAccount(node)
+ assert.ok(account)
+ assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
+ assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
+ })
+
+ it('should return successfully for small batch size', async () => {
+ const account = await wallet.getNextNewAccount(node, 1)
+ assert.ok(account)
+ assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
+ assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
+ })
+
+ it('should return successfully for large batch size', async () => {
+ const account = await wallet.getNextNewAccount(node, 100)
+ assert.ok(account)
+ assert.equal(account.address, NANO_TEST_VECTORS.ADDRESS_1)
+ assert.equal(account.publicKey, NANO_TEST_VECTORS.PUBLIC_1)
+ })
+
+ it('should throw on invalid node URL', async () => {
+ await assert.rejects(wallet.getNextNewAccount())
+ await assert.rejects(wallet.getNextNewAccount(null))
+ await assert.rejects(wallet.getNextNewAccount(1))
+ await assert.rejects(wallet.getNextNewAccount(''))
+ await assert.rejects(wallet.getNextNewAccount('foo'))
+ })
+
+ it('should throw on invalid batch size', async () => {
+ await assert.rejects(wallet.getNextNewAccount(node, null))
+ await assert.rejects(wallet.getNextNewAccount(node, -1))
+ await assert.rejects(wallet.getNextNewAccount(node, ''))
+ await assert.rejects(wallet.getNextNewAccount(node, 'foo'))
+ await assert.rejects(wallet.getNextNewAccount(node, { 'foo': 'bar' }))
+ })
})
describe('refreshing wallet accounts', { skip }, async () => {
- it('should get balance, frontier, and representative for one account', async () => {
- const accounts = await wallet.refresh(node)
- assert.ok(accounts[0] instanceof Account)
- assert.equal(typeof accounts[0].balance, 'string')
- assert.notEqual(accounts[0].frontier, undefined)
- assert.notEqual(accounts[0].frontier, null)
- assert.equal(typeof accounts[0].frontier, 'string')
- })
-
- it('should get balance, frontier, and representative for multiple accounts', async () => {
- const accounts = await wallet.refresh(node, 0, 2)
- assert.equal(accounts.length, 1)
- assert.ok(accounts[0] instanceof Account)
- })
-
- it('should handle failure gracefully', async () => {
- await assert.doesNotReject(wallet.refresh(node, 0, 20))
- })
+ it('should get balance, frontier, and representative for one account', async () => {
+ const accounts = await wallet.refresh(node)
+ assert.ok(accounts[0] instanceof Account)
+ assert.equal(typeof accounts[0].balance, 'bigint')
+ assert.notEqual(accounts[0].frontier, undefined)
+ assert.notEqual(accounts[0].frontier, null)
+ assert.equal(typeof accounts[0].frontier, 'string')
+ })
+
+ it('should get balance, frontier, and representative for multiple accounts', async () => {
+ const accounts = await wallet.refresh(node, 0, 2)
+ assert.equal(accounts.length, 1)
+ assert.ok(accounts[0] instanceof Account)
+ })
+
+ it('should handle failure gracefully', async () => {
+ await assert.doesNotReject(wallet.refresh(node, 0, 20))
+ })
})