Skip to content

Commit

Permalink
nodejs: validation block
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Dec 6, 2023
1 parent 359db00 commit beb9f62
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bindings/nodejs/tests/types/block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as basic_block_tagged_data_payload_json from '../../../../sdk/tests/typ
import * as basic_block_transaction_payload_json from '../../../../sdk/tests/types/fixtures/basic_block_transaction_payload.json';
import * as validation_block_json from '../../../../sdk/tests/types/fixtures/validation_block.json';
import * as protocol_parameters from '../../../../sdk/tests/types/fixtures/protocol_parameters.json';
import { BasicBlockBody, Utils, ProtocolParameters, Block, HexEncodedString, TaggedDataPayload, Transaction, PayloadType, SignedTransactionPayload } from '../../';
import { BasicBlockBody, Utils, ProtocolParameters, Block, HexEncodedString, TaggedDataPayload, Transaction, PayloadType, SignedTransactionPayload, ValidationBlockBody } from '../../';

describe('Block tests', () => {

Expand Down Expand Up @@ -49,4 +49,17 @@ describe('Block tests', () => {
const id = Utils.blockId(block, params);
expect(id).toEqual(expected_id);
});

it('compares validation block from a fixture', async () => {
const block = validation_block_json.block as unknown as Block;
expect(block.isValidation).toBe(true);
expect(block.body.isValidation).toBe(true);
expect(block.asValidation).toBeInstanceOf(ValidationBlockBody);

const params = protocol_parameters.params as unknown as ProtocolParameters;
const expected_id = validation_block_json.id as unknown as HexEncodedString;
// TODO: should we add an id() method on Block like we have in Python?
const id = Utils.blockId(block, params);
expect(id).toEqual(expected_id);
});
});

0 comments on commit beb9f62

Please sign in to comment.