Skip to content

Commit

Permalink
test: Add integration test for ListHeaders (#3212)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
Adds a simple integration test for checking the heights returned from ListHeaders gRPC 

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Increased test coverage 

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
Integration test

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
* [x] I'm merging against the `development` branch.
* [x] I have squashed my commits into a single commit.
  • Loading branch information
aviator-app[bot] authored Aug 19, 2021
2 parents 706ff5e + be8502e commit 4fd0327
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,13 @@ commands:
- run:
name: Run ffi cucumber scenarios
command: cd integration_tests && mkdir -p cucumber_output && node_modules/.bin/cucumber-js --tags "not @long-running and not @broken and not @flaky and @wallet-ffi" --format json:cucumber_output/tests-ffi.cucumber

- run:
name: Generate report (ff)
command: cd integration_tests && node ./generate_report.js cucumber_output/tests-ffi.cucumber temp/reports/cucumber_ffi_report.html
name: Generate report (ffi)
command: cd integration_tests && touch cucumber_output/tests-ffi.cucumber && node ./generate_report.js cucumber_output/tests-ffi.cucumber temp/reports/cucumber_ffi_report.html
when: always
# - run:
# name: Run flaky/broken cucumber scenarios (Always pass)
# command: cd integration_tests && node_modules/.bin/cucumber-js --tags "not @long-running and (@broken or @flaky)" --format json:cucumber_output/broken-tests.cucumber || true
# - run:
# name: Run flaky/broken cucumber scenarios (Always pass)
# command: cd integration_tests && node_modules/.bin/cucumber-js --tags "not @long-running and (@broken or @flaky)" --format json:cucumber_output/broken-tests.cucumber || true
- store_test_results:
path: integration_tests/cucumber_output
- store_artifacts:
Expand Down
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 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
14 changes: 14 additions & 0 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,20 @@ Then(/node (.*) is at tip (.*)/, async function (node, name) {
);
});

Then(
/node (.*) lists headers (\d+) to (\d+) with correct heights/,
async function (node, start, end) {
const client = this.getClient(node);
const fromHeight = end;
const numHeaders = end - start + 1; // inclusive
const headers = await client.getHeaders(fromHeight, numHeaders);
const heights = headers.map((header) => parseInt(header.height));
for (let height = start; height <= end; height++) {
expect(heights).to.contain(height);
}
}
);

When(
/I mine a block on (.*) with coinbase (.*)/,
{ timeout: 600 * 1000 },
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/helpers/baseNodeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class BaseNodeClient {
});
}

async getHeaders(from_height, num_headers, sorting = 0) {
return await this.client
.listHeaders()
.sendMessage({ from_height, num_headers, sorting });
}

getTipHeight() {
return this.client
.getTipInfo()
Expand Down

0 comments on commit 4fd0327

Please sign in to comment.