This directory contains Behavior-Driven Development (BDD) integration tests for the Minotari CLI wallet using the Cucumber framework.
Before building or running the tests, you need to install the Protocol Buffers compiler (protoc):
sudo apt-get install protobuf-compilerbrew install protobufDownload from: https://github.com/protocolbuffers/protobuf/releases
The test suite covers all major functionality of the Minotari CLI wallet:
- Wallet Creation: Creating new wallets with/without encryption
- Wallet Import: Importing wallets using view/spend keys or seed words
- Balance Operations: Checking wallet balances
- Blockchain Scanning: Scanning for transactions, re-scanning, and incremental scans
- Transaction Creation: Creating unsigned one-sided transactions
- Fund Locking: Locking UTXOs for pending transactions
- Daemon Mode: Running the wallet daemon with REST API
- Base Node Integration: Real base node integration for testing
integration-tests/
├── Cargo.toml # Package configuration
├── features/ # Gherkin feature files
│ ├── wallet_creation.feature
│ ├── wallet_import.feature
│ ├── balance.feature
│ ├── scanning.feature
│ ├── transactions.feature
│ ├── fund_locking.feature
│ ├── daemon.feature
│ └── base_node.feature
├── steps/ # Step definitions (Rust code)
│ ├── mod.rs
│ ├── common.rs # Shared world and utilities
│ ├── wallet_creation.rs
│ ├── wallet_import.rs
│ ├── balance.rs
│ ├── scanning.rs
│ ├── transactions.rs
│ ├── fund_locking.rs
│ ├── daemon.rs
│ └── base_node.rs
├── src/ # Support code
│ ├── lib.rs
│ └── base_node_process.rs
└── tests/ # Test runners
└── cucumber.rs
# Run all integration tests
cargo test -p integration-tests
# Run with output
cargo test -p integration-tests -- --nocapturecd integration-tests
# Run all tests
cargo test
# Run with output
cargo test -- --nocapturecargo test --test cucumber -- --nocaptureCreate a new .feature file in features/:
Feature: My New Feature
As a user
I want to do something
So that I achieve some goal
Scenario: Do something specific
Given some precondition
When I perform an action
Then I should see the expected resultCreate or update a step definition file in steps/:
use cucumber::{given, when, then};
use super::common::MinotariWorld;
#[given("some precondition")]
async fn setup_precondition(world: &mut MinotariWorld) {
// Setup code
}
#[when("I perform an action")]
async fn perform_action(world: &mut MinotariWorld) {
// Action code
}
#[then("I should see the expected result")]
async fn verify_result(world: &mut MinotariWorld) {
// Assertion code
}Add your new module to steps/mod.rs:
pub mod my_new_feature;The MinotariWorld struct in common.rs provides shared state across steps:
temp_dir: Temporary directory for test filesdatabase_path: Path to test databaseoutput_file: Path to output files (wallet.json, transactions, etc.)wallet_data: Parsed wallet JSON datalast_command_output: stdout from last commandlast_command_error: stderr from last commandlast_command_exit_code: Exit code from last commanddaemon_handle: Handle to running daemon processapi_port: Port number for API server
The integration tests use the following crates:
cucumber- BDD testing frameworktempfile- Temporary file/directory managementserial_test- Sequential test executiontokio- Async runtimereqwest- HTTP client for API testing
- Tests run sequentially (
max_concurrent_scenarios(1)) to avoid port conflicts when testing daemon mode - Each test gets its own temporary directory that is cleaned up automatically
- Tests use a consistent test password and keys for deterministic behavior
- Some tests may require a running Tari node to fully execute (scanning scenarios)
- Database operations are tested using SQLite in temporary directories
Most scanning tests will gracefully handle connection failures to real nodes. This is expected in the test environment. The tests verify that the commands execute correctly even if they can't connect to a blockchain node.
If daemon tests fail with port conflicts, ensure no other instances are running:
pkill -f minotariEnsure previous test runs have cleaned up properly. Delete any stale test databases:
find /tmp -name "test_wallet.db" -deletePotential improvements to the test suite:
- Mock blockchain node for more deterministic scanning tests
- Test fixtures with pre-populated wallets and outputs
- Performance benchmarks for scanning operations
- Integration with CI/CD pipeline
- Code coverage reporting
- Parallel test execution where safe