Skip to main content

Crate halfin

Crate halfin 

Source
Expand description

§Halfin

A bitcoin node running utility for integration testing.

A {regtest} bitcoin node runner 🏃‍♂️

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

§Supported Implementations

ImplementationVersionFeature FlagDefault Feature
bitcoindv31.0bitcoind_31_0Yes
utreexodv0.5.2utreexod_0_5_2Yes
electrsv0.11.1electrs_0_11_1No

§Example

use halfin::connect;
use halfin::bitcoind::BitcoinD;
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 serde_json;

Modules§

bitcoind
BitcoinD: spawn and interact with a bitcoind process
electrsd
ElectrsD: spawn and interact with an electrs process
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.
Error

Constants§

CONNECTION_INTERVAL
The interval Duration between successive attempts of node connection.
CONNECTION_TIMEOUT
The timeout Duration for node connection.
NODE_BUILDING_INTERVAL
The Duration between attempts at instantiating a Node.
NODE_BUILDING_MAX_RETRIES
The maximum number of attempts at instantiating a BitcoinD/UtreexoD.
POLL_INTERVAL
The Duration interval between polls for connect and wait_for_height.
WAIT_TIMEOUT
The timeout Duration for connect and wait_for_height.

Traits§

Node
Common interface across all node implementations (BitcoinD/UtreexoD).

Functions§

connect
Connect Node A to Node B.
connect_and_sync
Connect Node A to Node B and wait for them to synchronize chains.
get_available_port
Ask the OS for an available port, immediately unbind and return it.
wait_for_filter_height
Poll a Node until its Compact Block Filters reach height.
wait_for_height
Poll a Node until its chain reaches height.
wait_for_height_with_timeout
Poll a Node until its chain reaches height with a custom timeout.