Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIP BlockId tests #1607

Merged
merged 78 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c514afa
uncomment block id tests
Alex6323 Nov 10, 2023
70644c9
move json as fixtures into own .json files
Alex6323 Nov 10, 2023
3753570
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Nov 26, 2023
4aa8bbf
Remove bindings fixtures
thibault-martinez Nov 26, 2023
18524de
Cleanup fixtures
thibault-martinez Nov 26, 2023
4a9620b
Cleanup tests
thibault-martinez Nov 26, 2023
3af258f
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Nov 27, 2023
392fb8b
Uncomment tests
thibault-martinez Nov 27, 2023
24d100e
Add TODO
thibault-martinez Nov 27, 2023
fd96253
Merge branch '2.0' into chore/tests/block-id
Alex6323 Nov 29, 2023
695ac06
Merge branch '2.0' into chore/tests/block-id
Alex6323 Nov 30, 2023
918e51d
Merge branch '2.0' into chore/tests/block-id
Alex6323 Nov 30, 2023
91235a3
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 5, 2023
565758e
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 6, 2023
8bd6062
python: basic block tagged data payload
Alex6323 Dec 6, 2023
519bfcf
python: it's a signed block
Alex6323 Dec 6, 2023
762b6ca
python: basic block transaction payload
Alex6323 Dec 6, 2023
8c99094
python: validation block
Alex6323 Dec 6, 2023
109d70f
nodejs: basic block tagged data payload
Alex6323 Dec 6, 2023
359db00
nodejs: basic block transaction payload
Alex6323 Dec 6, 2023
beb9f62
nodejs: validation block
Alex6323 Dec 6, 2023
1c77a11
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 6, 2023
d2035a0
simplify
Alex6323 Dec 6, 2023
6a4f41b
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 6, 2023
12a79a4
nodejs: fix some block tests
Alex6323 Dec 8, 2023
d247175
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 8, 2023
d13f493
remove temporary stuff
Alex6323 Dec 8, 2023
8673bd3
nits
Alex6323 Dec 8, 2023
71ea79e
back to interfaces
Alex6323 Dec 8, 2023
dfcbea0
format
Alex6323 Dec 8, 2023
091ce0a
nit
Alex6323 Dec 8, 2023
4bd270e
cleanup
Alex6323 Dec 8, 2023
ccd1273
rename instead of serde rename
Alex6323 Dec 8, 2023
19aaef4
reverted u64
Dec 12, 2023
5bd5307
Merge branch '2.0' into chore/tests/block-id
Dec 12, 2023
03854d0
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 12, 2023
0331515
update test vectors
Alex6323 Dec 13, 2023
e9c1737
Merge branch '2.0' into chore/tests/block-id
Alex6323 Dec 15, 2023
a3090b6
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 8, 2024
167aad5
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 17, 2024
9911f17
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 18, 2024
699afe0
attempt to fix tests
Alex6323 Jan 18, 2024
e5658ae
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Jan 18, 2024
7d1f288
Update JSONs
thibault-martinez Jan 18, 2024
af55bc1
Remove FIXMEs
thibault-martinez Jan 18, 2024
2549030
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Jan 19, 2024
3ffd794
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Jan 19, 2024
643eb92
Fix test
thibault-martinez Jan 19, 2024
2342134
copyright
Alex6323 Jan 19, 2024
a2c7b82
nodejs: re-enable validation block test
Alex6323 Jan 19, 2024
29b8471
fix 1/3 python block id tests
Alex6323 Jan 19, 2024
c296133
allow passing args to pytest
Alex6323 Jan 19, 2024
b76cad8
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 22, 2024
8c34827
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 23, 2024
f96bb87
Python: fix serialization/deserialization
Alex6323 Jan 25, 2024
05e2640
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 25, 2024
0d53fc8
linter, review
Alex6323 Jan 25, 2024
36b2f64
format
Alex6323 Jan 25, 2024
6d89240
format (are you serious?)
Alex6323 Jan 25, 2024
7edd5de
lint tests
Alex6323 Jan 25, 2024
7203cee
format annoying lints
Alex6323 Jan 25, 2024
d639118
assign id method for block
Alex6323 Jan 25, 2024
a6596a8
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 25, 2024
bb38c49
yarn lint
Alex6323 Jan 25, 2024
fed8ea1
Merge branch '2.0' into chore/tests/block-id
Jan 25, 2024
a3bd1f1
type field first
Alex6323 Jan 25, 2024
b43b3e8
get rid of to_dict
Alex6323 Jan 26, 2024
806aeec
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 26, 2024
1a9ec07
update fixture
Alex6323 Jan 26, 2024
b8261bd
format
Alex6323 Jan 26, 2024
36c3d74
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 28, 2024
6d9b7be
python: fix lint
Alex6323 Jan 28, 2024
8401470
python: fix metadata feature output tests
Alex6323 Jan 28, 2024
4e4cec4
apply review suggestion
Alex6323 Jan 29, 2024
88c4de3
Merge branch '2.0' into chore/tests/block-id
Alex6323 Jan 29, 2024
1e92843
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Jan 29, 2024
3ef3f71
Merge branch '2.0' into chore/tests/block-id
thibault-martinez Jan 30, 2024
33658e5
Nits
thibault-martinez Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions bindings/nodejs/tests/types/block.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2023 IOTA Stiftung
Alex6323 marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: Apache-2.0

import 'reflect-metadata';

import { expect, describe, it } from '@jest/globals';
import * as basic_block_tagged_data_payload_json from '../../../../sdk/tests/types/fixtures/basic_block_tagged_data_payload.json';
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, ValidationBlockBody } from '../../';

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

it('compares basic block tagged data payload from a fixture', async () => {
const block = basic_block_tagged_data_payload_json.block as unknown as Block;
expect(block.isBasic).toBe(true);
expect(block.body.isBasic).toBe(true);
expect(block.asBasic).toBeInstanceOf(BasicBlockBody);

const basic_block = block.body.asBasic();
expect(basic_block.payload).toBeInstanceOf(TaggedDataPayload);
const tagged_data_payload = basic_block.payload as unknown as TaggedDataPayload;
expect(tagged_data_payload.type).toBe(PayloadType.TaggedData);
expect(basic_block.maxBurnedMana).toEqual(864);
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

const params = protocol_parameters.params as unknown as ProtocolParameters;
const expected_id = basic_block_tagged_data_payload_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);
});

it('compares basic block transaction payload from a fixture', async () => {
const block = basic_block_transaction_payload_json.block as unknown as Block;
expect(block.isBasic).toBe(true);
expect(block.body.isBasic).toBe(true);
expect(block.asBasic).toBeInstanceOf(BasicBlockBody);

const basic_block = block.body.asBasic();
expect(basic_block.payload).toBeInstanceOf(SignedTransactionPayload);
const transaction_payload = basic_block.payload as unknown as SignedTransactionPayload;
expect(transaction_payload.type).toBe(PayloadType.SignedTransaction);
expect(basic_block.maxBurnedMana).toEqual(119);

const params = protocol_parameters.params as unknown as ProtocolParameters;
const expected_id = basic_block_transaction_payload_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);
});

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?
Alex6323 marked this conversation as resolved.
Show resolved Hide resolved
const id = Utils.blockId(block, params);
expect(id).toEqual(expected_id);
});
});
Loading
Loading