From 4b20a49a415b1dbf2a28e2e60fde5da2c7e690f1 Mon Sep 17 00:00:00 2001 From: striderDM <51991544+StriderDM@users.noreply.github.com> Date: Thu, 19 Aug 2021 17:53:14 +0200 Subject: [PATCH] Cucumber check block heights in order test --- .../features/BaseNodeConnectivity.feature | 8 ++++++- integration_tests/features/support/steps.js | 23 +++++++++++++++++++ integration_tests/helpers/baseNodeClient.js | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/integration_tests/features/BaseNodeConnectivity.feature b/integration_tests/features/BaseNodeConnectivity.feature index 2ef4fd6597..54f806cff8 100644 --- a/integration_tests/features/BaseNodeConnectivity.feature +++ b/integration_tests/features/BaseNodeConnectivity.feature @@ -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 \ No newline at end of file + Then node BN1 lists headers 1 to 5 with correct heights diff --git a/integration_tests/features/support/steps.js b/integration_tests/features/support/steps.js index b3a70ae85a..ca54c5d4ff 100644 --- a/integration_tests/features/support/steps.js +++ b/integration_tests/features/support/steps.js @@ -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++; + } + } +); diff --git a/integration_tests/helpers/baseNodeClient.js b/integration_tests/helpers/baseNodeClient.js index 5ee2db67d6..5ca483f65a 100644 --- a/integration_tests/helpers/baseNodeClient.js +++ b/integration_tests/helpers/baseNodeClient.js @@ -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;