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 and utreexod instances from Rust code, useful in integration test contexts.

Pretty much bitcoind with utreexod support.

§Supported Implementations

ImplementationVersionFeature FlagDefault Feature
bitcoindv31.0bitcoind_31_0Yes
utreexodv0.5.1utreexod_0_5_1Yes

§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
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.
get_available_port
Ask the OS for an available port, immediately unbind and return it.
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.