Skip to content

Commit

Permalink
Cucumber check block heights in order test
Browse files Browse the repository at this point in the history
  • Loading branch information
StriderDM committed Aug 19, 2021
1 parent b03a6f8 commit 7be2457
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions integration_tests/features/BaseNodeConnectivity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ Feature: Base Node Connectivity
Then I wait for WALLET_A to have 1 node connections
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
23 changes: 23 additions & 0 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3464,3 +3464,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 @@ -438,6 +438,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;

0 comments on commit 7be2457

Please sign in to comment.