})
await test('sign open block from block', async () => {
- openBlock = new Block(account, '0', RECEIVE_BLOCK.representative, account.publicKey)
+ openBlock = new Block(account, '0', '0', RECEIVE_BLOCK.representative)
.receive(RECEIVE_BLOCK.link, RECEIVE_BLOCK.balance)
- assert.ok(/^[A-Fa-f0-9]{64}$/.test(openBlock.hash))
+ assert.ok(/^[A-F0-9]{64}$/i.test(openBlock.hash))
assert.nullish(openBlock.signature)
assert.equal(openBlock.account.publicKey, account.publicKey)
- const signature = await wallet.sign(0, openBlock)
+ const signature = await wallet.sign(0, openBlock, 'hex')
assert.ok(/^[A-Fa-f0-9]{128}$/.test(signature))
})
await test('sign send block from wallet which requires cache to be up-to-date', async () => {
- sendBlock = new Block(account, openBlock.balance, SEND_BLOCK.representative, openBlock.hash)
+ sendBlock = new Block(account, openBlock.balance, openBlock.hash, SEND_BLOCK.representative)
.send(account.address, '0')
assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash))
assert.nullish(sendBlock.signature)
assert.equal(sendBlock.account.publicKey, account.publicKey)
- const signature = await wallet.sign(0, sendBlock)
+ const signature = await wallet.sign(0, sendBlock, 'hex')
assert.ok(/^[A-Fa-f0-9]{128}$/.test(signature))
assert.equal(signature, sendBlock.signature)
})
await test('sign a receive block from block object which can accept previous block for cache', async () => {
- receiveBlock = new Block(account, sendBlock.balance, RECEIVE_BLOCK.representative, sendBlock.hash)
+ receiveBlock = new Block(account, sendBlock.balance, sendBlock.hash, RECEIVE_BLOCK.representative)
.receive(sendBlock.hash, '0')
assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash))
assert.ok(/^[A-Fa-f0-9]{128}$/.test(receiveBlock.signature ?? ''))
})
- await test('sign a send block from wallet without frontier block inheriting cache contents', async () => {
- sendBlock = new Block(account, receiveBlock.balance, SEND_BLOCK.representative, receiveBlock.hash)
+ await test('fail to sign a send block from wallet without caching frontier block', async () => {
+ sendBlock = new Block(account, receiveBlock.balance, receiveBlock.hash, SEND_BLOCK.representative)
.send(account.address, '0')
assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash))
assert.nullish(sendBlock.signature)
assert.equal(sendBlock.account.publicKey, account.publicKey)
- const signature = await wallet.sign(0, sendBlock)
-
- assert.exists(sendBlock.signature)
- assert.ok(/^[A-Fa-f0-9]{128}$/.test(sendBlock.signature ?? ''))
- assert.equal(signature, sendBlock.signature)
+ await assert.rejects(wallet.sign(0, sendBlock, 'hex'))
})
- await test('sign a receive block from wallet including frontier block for cache', async () => {
- sendBlock = new Block(account, receiveBlock.balance, RECEIVE_BLOCK.representative, receiveBlock.hash)
- .receive(receiveBlock.hash, '0')
+ await test('sign a send block from wallet including frontier block for cache', async () => {
+ sendBlock = new Block(account, receiveBlock.balance, receiveBlock.hash, SEND_BLOCK.representative)
+ .send(account.address, '0')
- assert.ok(/^[A-Fa-f0-9]{64}$/.test(receiveBlock.hash))
+ assert.ok(/^[A-Fa-f0-9]{64}$/.test(sendBlock.hash))
assert.nullish(sendBlock.signature)
assert.equal(sendBlock.account.publicKey, account.publicKey)
- const signature = await wallet.sign(0, sendBlock, receiveBlock)
+ const signature = await wallet.sign(0, sendBlock, 'hex', receiveBlock)
assert.exists(sendBlock.signature)
assert.ok(/^[A-Fa-f0-9]{128}$/.test(sendBlock.signature ?? ''))
})
await test('fail to sign a block without caching frontier', async () => {
- sendBlock = new Block(account, receiveBlock.balance, SEND_BLOCK.representative, receiveBlock.previous)
+ sendBlock = new Block(account, receiveBlock.balance, receiveBlock.hash, SEND_BLOCK.representative)
.send(account.address, '0')
await assert.rejects(sendBlock.sign(0))
})