From f274981f453154394775c52565dfc3121be63ca0 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Mon, 23 Aug 2021 17:41:19 +0200 Subject: [PATCH] test: Add rebuild-db integration test (#3232) 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"` --- .circleci/config.yml | 11 +++++++---- integration_tests/features/Recovery.feature | 17 +++++++++++++++++ integration_tests/features/support/steps.js | 8 ++++++++ integration_tests/features/support/world.js | 5 +++-- integration_tests/helpers/baseNodeProcess.js | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 integration_tests/features/Recovery.feature diff --git a/.circleci/config.yml b/.circleci/config.yml index 876d8c9e20..51fe4e5048 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/integration_tests/features/Recovery.feature b/integration_tests/features/Recovery.feature new file mode 100644 index 0000000000..c123dfa48b --- /dev/null +++ b/integration_tests/features/Recovery.feature @@ -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 blocks on B + Then all nodes are at height + 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 + Examples: + | NumBlocks | + | 10 | + | 25 | + | 50 | \ No newline at end of file diff --git a/integration_tests/features/support/steps.js b/integration_tests/features/support/steps.js index 2d13f664b6..d89f25fd82 100644 --- a/integration_tests/features/support/steps.js +++ b/integration_tests/features/support/steps.js @@ -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); }); diff --git a/integration_tests/features/support/world.js b/integration_tests/features/support/world.js index 1bf8283768..93ec09ca63 100644 --- a/integration_tests/features/support/world.js +++ b/integration_tests/features/support/world.js @@ -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) { @@ -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."); }); diff --git a/integration_tests/helpers/baseNodeProcess.js b/integration_tests/helpers/baseNodeProcess.js index a4a74ab41c..9fde4af4ae 100644 --- a/integration_tests/helpers/baseNodeProcess.js +++ b/integration_tests/helpers/baseNodeProcess.js @@ -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); }