From fc3d901a145f4302c4dd36593b0116e7bda23b6d Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 23 Apr 2026 14:49:33 -0700 Subject: [PATCH] Add auto-PoW block processing test. --- test/test.blocks.mjs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/test.blocks.mjs b/test/test.blocks.mjs index 6395db6..c56593c 100644 --- a/test/test.blocks.mjs +++ b/test/test.blocks.mjs @@ -3,11 +3,29 @@ 'use strict' -import { Account, Block, Wallet } from 'libnemo' +import { Block, Rpc, Wallet } from 'libnemo' import { assert, suite, test } from './GLOBALS.mjs' import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS } from './VECTORS.mjs' await Promise.all([ + suite('Block processing', async () => { + const { OPEN_BLOCK } = NANO_TEST_VECTORS + const rpc = new Rpc('https://example.com') + + await test('generate work automatically when processing block', async () => { + const block = await new Block(OPEN_BLOCK.account, '0', OPEN_BLOCK.previous, OPEN_BLOCK.representative) + .receive(OPEN_BLOCK.link, OPEN_BLOCK.balance) + .sign(OPEN_BLOCK.key) + assert.nullish(block.work) + + const p = block.process(rpc) + const result = await assert.rejects(p) + + assert.exists(block.work) + assert.equal(result.message, 'Block could not be processed') + }) + }), + suite('Block format', async () => { const { ADDRESS_0, ADDRESS_1, ADDRESS_2, RECEIVE_BLOCK } = NANO_TEST_VECTORS -- 2.47.3