Migrate functional tests from Python to Rust with integrated RPC and node setup #690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Which crates are being modified?
Description and Notes
This PR migrates the existing Python functional tests to Rust to align with the project’s ecosystem and take advantage of Rust’s testing capabilities. Since Floresta and its supporting components are written in Rust, keeping tests in Python added unnecessary complexity and dependency management.
The new Rust-based functional test suite can automatically instantiate a bitcoind, utreexod, and florestad node, simulating full regtest integration. It validates the interoperability between these nodes and verifies that Floresta’s RPC responses match those of Bitcoin Core, essential since Floresta aims to maintain RPC compatibility with Core.
A shared static setup,
SHARED_FLORESTAD_BITCOIND_UTREEXOD_WITH_BLOCKS, is provided for tests that require a pre-initialized chain with blocks, improving runtime performance by avoiding repeated setup overhead.The following RPC endpoints are covered:
add_nodeget_best_block_hashget_blockget_blockchain_infoget_block_countget_block_hashget_block_headerget_memory_infoget_peer_infoget_rootsget_rpc_infoget_tx_outpingstopuptimeThe tests use the electrsd crate to manage the bitcoind node. This library (also used by BDK and LDK) automatically downloads and launches a bitcoind binary matching the desired version, simplifying setup and communication via RPC.
In CI, a preparation step was added to download the Bitcoin binaries and build utreexod, placing them under /tmp/floresta-func-tests/bin. The CI uses prebuilt binaries for Linux and macOS to reduce build time (Linux only for now).
Additionally, the minimum Rust version was updated to 1.90.0, as some dependencies required a newer compiler. This update aligns the project with the latest stable toolchain.
Tests are isolated behind the functional-tests feature to prevent them from running as part of the standard test suite, since they require external binaries and setup.
This PR depends on #689 #688 #683 #682
How to verify the changes you have done?
Run the functional test suite with the following:
cargo test --features=functional-tests -p test-functional -- --test-threads=1Alternatively, use prepare.sh to download and prepare the required binaries before running. The tests will automatically start bitcoind, utreexod, and florestad instances and validate RPC responses against bitcoind.