#testing #process #environment #utility #integration #run

bitcoind

Utility to run a regtest bitcoind process, useful in integration testing environment

18 breaking releases

0.19.0 Sep 20, 2021
0.17.0 Aug 17, 2021
0.13.0 Jul 22, 2021

#79 in Testing

Download history 678/week @ 2021-06-30 1336/week @ 2021-07-07 789/week @ 2021-07-14 1033/week @ 2021-07-21 1378/week @ 2021-07-28 523/week @ 2021-08-04 595/week @ 2021-08-11 548/week @ 2021-08-18 1207/week @ 2021-08-25 435/week @ 2021-09-01 597/week @ 2021-09-08 612/week @ 2021-09-15 1182/week @ 2021-09-22 533/week @ 2021-09-29 250/week @ 2021-10-06 286/week @ 2021-10-13

3,471 downloads per month
Used in 3 crates (2 directly)

MIT license

4.5MB
480 lines

MIT license Crates

Bitcoind

Utility to run a regtest bitcoind process, useful in integration testing environment.

use bitcoincore_rpc::RpcApi;
let bitcoind = bitcoind::BitcoinD::new("/usr/local/bin/bitcoind").unwrap();
assert_eq!(0, bitcoind.client.get_blockchain_info().unwrap().blocks);

MSRV

1.41.1

Features

  • It waits until bitcoind daemon become ready to accept RPC commands
  • bitcoind use a temporary directory as datadir
  • Free ports are asked to the OS (a low probability race condition is still possible)
  • the process is killed when the struct goes out of scope no matter how the test finishes
  • allows easy spawning of dependent process like https://github.com/RCasatta/electrsd

Cargo features

When a feature like 0_21_1 is selected, the build script will automatically download the bitcoin core version 0.21.1 and verify the hashes and place it in the build directory for this crate. Use utility function downloaded_exe_path() to get the downloaded executable path.

Example

Cargo.toml

[dev-dependencies]
bitcoind = { version = "0.12.0", features = "0_21_1" }

In your tests

let bitcoind = bitcoind::BitcoinD::new(bitcoind::downloaded_exe_path().unwrap()).unwrap();

Dependencies

~3.5–4.5MB
~93K SLoC