Skip to main content

Crate halfin

Crate halfin 

Source
Expand description

§halfin

A bitcoin node and indexer running utility for integration testing.

A {regtest} bitcoin node runner 🏃‍♂️

This crate makes it simple to run regtest bitcoind, utreexod, electrs, and electrumx instances from Rust code, useful in integration test contexts.

§Supported Implementations

KindImplementationVersionFeature FlagDefault Feature
Nodebitcoindv31.0bitcoindYes
Nodeutreexodv0.6.0utreexodYes
Indexerelectrsv0.11.1electrsNo

§Example

use halfin::bitcoind::BitcoinD;
use halfin::connect;
use halfin::utreexod::UtreexoD;

let bitcoind = BitcoinD::new().unwrap();
bitcoind.generate(10).unwrap();
assert_eq!(bitcoind.get_chain_tip().unwrap(), 10);

let utreexod = UtreexoD::new().unwrap();
utreexod.generate(10).unwrap();
assert_eq!(utreexod.get_chain_tip().unwrap(), 10);

connect(&bitcoind, &utreexod).unwrap();

Re-exports§

pub use crate::error::Error;
pub use serde_json;

Modules§

bitcoind
BitcoinD: spawn and interact with a bitcoind process
electrsd
ElectrsD: spawn and interact with an electrs process
electrumxd
ElectrumxD: spawn and interact with an electrumx process
error
Error
node
Node trait
utreexod
UtreexoD: spawn and interact with a utreexod process

Enums§

DataDir
Owns a node’s working directory, either as a temporary or a persistent path.

Constants§

CONNECTION_INTERVAL
Period between successive attempts of Node connection.
CONNECTION_TIMEOUT
Timeout for Node connection.
POLL_INTERVAL
Period between polls for connect and wait_for_height.
SPAWN_ATTEMPTS
Maximum number of attempts at spawning a process.
SPAWN_INTERVAL
Period between attempts at spawning a process.
WAIT_TIMEOUT
Timeout for connect and wait_for_height.

Functions§

get_available_port
Ask the OS for an available port, immediately unbind and return it.