Skip to content

Commit

Permalink
test: Add rebuild-db integration test (#3232)
Browse files Browse the repository at this point in the history
Description:

Adds a cucumber test to cover the `--rebuild-db` blockchain recovery functionality on the base node 

Motivation and Context:

Improved test coverage

How Has This Been Tested?

`npm test -- --name "Blockchain database recovery"`
  • Loading branch information
Byron Hambly authored Aug 23, 2021
1 parent bb6e87f commit f274981
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
11 changes: 7 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,19 @@ commands:
name: Check eslint
command: cd integration_tests && npm run lint
- run:
name: Pre-build base node
name: Build base node
command: cargo build --release --bin tari_base_node
- run:
name: Pre-build wallet
name: Build wallet
command: cargo build --release --bin tari_console_wallet
- run:
name: Pre-build mmproxy
name: Build wallet FFI
command: cargo build --release --package tari_wallet_ffi
- run:
name: Build mmproxy
command: cargo build --release --bin tari_merge_mining_proxy
- run:
name: Pre-build mining_node
name: Build mining_node
command: cargo build --release --bin tari_mining_node
- run:
name: Run cucumber scenarios
Expand Down
17 changes: 17 additions & 0 deletions integration_tests/features/Recovery.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@recovery
Feature: Recovery

Scenario Outline: Blockchain database recovery
Given I have 2 seed nodes
And I have a base node B connected to all seed nodes
When I mine <NumBlocks> blocks on B
Then all nodes are at height <NumBlocks>
When I stop node B
And I run blockchain recovery on node B
And I start base node B
Then all nodes are at height <NumBlocks>
Examples:
| NumBlocks |
| 10 |
| 25 |
| 50 |
8 changes: 8 additions & 0 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,14 @@ When(/I start base node (.*)/, { timeout: 20 * 1000 }, async function (name) {
await this.startNode(name);
});

When(
/I run blockchain recovery on node (\S*)/,
{ timeout: 120 * 1000 },
async function (name) {
await this.startNode(name, ["--rebuild-db"]);
}
);

When(/I stop node (.*)/, async function (name) {
await this.stopNode(name);
});
Expand Down
5 changes: 3 additions & 2 deletions integration_tests/features/support/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ class CustomWorld {
await node.stop();
}

async startNode(name) {
async startNode(name, args) {
const node = this.seeds[name] || this.nodes[name];
await node.start();
await node.start(args);
}

addTransaction(pubKey, txId) {
Expand Down Expand Up @@ -338,6 +338,7 @@ BeforeAll({ timeout: 1200000 }, async function () {
await miningNode.init(1, 1, 1, 1, true, 1);
await miningNode.compile();

console.log("Compiling wallet FFI...");
await WalletFFIClient.Init();
console.log("Finished compilation.");
});
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/helpers/baseNodeProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ class BaseNodeProcess {
return await this.createGrpcClient();
}

async start() {
async start(opts = []) {
const args = ["--base-path", "."];
if (this.logFilePath) {
args.push("--log-config", this.logFilePath);
}
args.push(...opts);
return await this.run(await this.compile(), args);
}

Expand Down

0 comments on commit f274981

Please sign in to comment.