\r
'use strict'\r
\r
-import { Account, Block, Wallet } from 'libnemo'\r
+import { Block, Rpc, Wallet } from 'libnemo'\r
import { assert, suite, test } from './GLOBALS.mjs'\r
import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs'\r
\r
await Promise.all([\r
+ suite('Block processing', async () => {\r
+ const { OPEN_BLOCK } = NANO_TEST_VECTORS\r
+ const rpc = new Rpc('https://example.com')\r
+\r
+ await test('generate work automatically when processing block', async () => {\r
+ const block = await new Block(OPEN_BLOCK.account, '0', OPEN_BLOCK.previous, OPEN_BLOCK.representative)\r
+ .receive(OPEN_BLOCK.link, OPEN_BLOCK.balance)\r
+ .sign(OPEN_BLOCK.key)\r
+ assert.nullish(block.work)\r
+\r
+ const p = block.process(rpc)\r
+ const result = await assert.rejects(p)\r
+\r
+ assert.exists(block.work)\r
+ assert.equal(result.message, 'Block could not be processed')\r
+ })\r
+ }),\r
+\r
suite('Block format', async () => {\r
const { ADDRESS_0, ADDRESS_1, ADDRESS_2, RECEIVE_BLOCK } = NANO_TEST_VECTORS\r
\r