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

test: cucumber check block heights in order test #3219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion integration_tests/features/BaseNodeConnectivity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ Feature: Base Node Connectivity
Then I wait for WALLET_A to have ONLINE connectivity
Then SEED_A is connected to WALLET_A

Scenario: Base node lists heights
Given I have 1 seed nodes
And I have a base node N1 connected to all seed nodes
When I mine 5 blocks on N1
Then node N1 lists heights 1 to 5

Scenario: Base node lists headers
Given I have 1 seed nodes
And I have a base node BN1 connected to all seed nodes
When I mine 5 blocks on BN1
Then node BN1 lists headers 1 to 5 with correct heights
Then node BN1 lists headers 1 to 5 with correct heights
23 changes: 23 additions & 0 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3478,3 +3478,26 @@ Then(
expect(await wallet.getContact("alias")).to.be.undefined;
}
);

Then(
/node (.*) lists heights (\d+) to (\d+)/,
async function (node, first, last) {
const client = this.getClient(node);
const start = first;
const end = last;
let heights = [];

for (let i = start; i <= end; i++) {
heights.push(i);
}
const blocks = await client.getBlocks(heights);
const results = blocks.map((result) =>
parseInt(result.block.header.height)
);
let i = 0; // for ordering check
for (let height = start; height <= end; height++) {
expect(results[i]).equal(height);
i++;
}
}
);
4 changes: 4 additions & 0 deletions integration_tests/helpers/baseNodeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ class BaseNodeClient {
const mempoolStats = await this.client.getMempoolStats().sendMessage({});
return mempoolStats;
}

async getBlocks(heights) {
return await this.client.getBlocks().sendMessage({ heights });
}
}

module.exports = BaseNodeClient;