Crates.io | corepc-node |
lib.rs | corepc-node |
version | 0.9.0 |
created_at | 2024-11-14 05:59:16.024156+00 |
updated_at | 2025-09-16 03:41:14.841479+00 |
description | Utility to run a regtest bitcoind process, useful in integration testing environments |
homepage | |
repository | https://github.com/rust-bitcoin/corepc |
max_upload_size | |
id | 1447467 |
size | 147,197 |
Utility to run a regtest bitcoind process, useful in integration testing environment.
When the auto-download feature is enabled, starting a regtest node is as simple as that:
// the download feature must be enabled with a specific version, for example `25_1` or `24_0_1`
#[cfg(feature = "download")]
{
let node = corepc_node::Node::from_downloaded().unwrap();
assert_eq!(0, node.client.get_blockchain_info().unwrap().blocks);
}
The build script will automatically download the bitcoin core version 25.1 from bitcoin core, verify the binary hash and place it in the build directory for this crate.
When you don't use the auto-download feature you have the following options:
bitcoind
executable in the PATH
bitcoind
executable via the BITCOIND_EXE
env varif let Ok(exe_path) = corepc_node::exe_path() {
let node = corepc_node::Node::new(exe_path).unwrap();
assert_eq!(0, node.client.get_blockchain_info().unwrap().blocks);
}
Startup options could be configured via the [Conf
] struct using [Node::with_conf
] or
Node::from_downloaded_with_conf
node
uses a temporary directory as datadir. You can specify the root of your temp
directories so that you have the node's datadir in a RAM disk (eg /dev/shm
)Thanks to these features every #[test]
could easily run isolated with its own environment.
To build docs:
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features download,doc --open
This library should always compile with any combination of features on Rust 1.63.0.
For reproducibility reasons, Nix build scripts cannot hit the internet, but the auto-download
feature does exactly that. To successfully build under Nix the user must provide the tarball locally
and specify its location via the BITCOIND_TARBALL_FILE
env var.
Another option is to specify the BITCOIND_SKIP_DOWNLOAD
env var and provide the executable via the
PATH
.
Alternatively, use the dep without the auto-download feature.