Utility to run a regtest electrs process connected to a given bitcoind instance, useful in integration testing environment.
rust
let bitcoind = bitcoind::BitcoinD::new("/usr/local/bin/bitcoind").unwrap();
let electrsd = electrsd::ElectrsD::new("/usr/local/bin/electrs", bitcoind).unwrap();
let header = electrsd.client.block_headers_subscribe().unwrap();
assert_eq!(header.height, 0);
In your project Cargo.toml, activate the following features
yml
electrsd = { version= "0.12", features = ["bitcoind_0_22", "electrs_0_9_1"] }
Then use it:
rust
let bitcoind_exe = bitcoind::downloaded_exe_path().expect("bitcoind version feature must be enabled");
let bitcoind = bitcoind::BitcoinD::new(bitcoind_exe).unwrap();
let electrs_exe = electrsd::downloaded_exe_path().expect("electrs version feature must be enabled");
let electrsd = electrsd::ElectrsD::new(electrs_exe, bitcoind).unwrap();
I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like:
electrs
executable with enabled features. Since there are no official binaries, they are built using the manual workflow under this project. Supported version are:
Thanks to these features every #[test]
could easily run isolated with its own environment