Struct TestEnv

Source
pub struct TestEnv {
    pub bitcoind: BitcoinD,
    pub electrsd: ElectrsD,
}
Expand description

Struct for running a regtest environment with a single bitcoind node with an electrs instance connected to it.

Fields§

§bitcoind: BitcoinD§electrsd: ElectrsD

Implementations§

Source§

impl TestEnv

Source

pub fn new() -> Result<Self>

Construct a new TestEnv instance with the default configuration used by BDK.

Source

pub fn new_with_config(config: Config<'_>) -> Result<Self>

Construct a new TestEnv instance with the provided Config.

Source

pub fn electrum_client(&self) -> &impl ElectrumApi

Exposes the [ElectrumApi] calls from the Electrum client.

Source

pub fn rpc_client(&self) -> &impl RpcApi

Exposes the [RpcApi] calls from [bitcoincore_rpc].

Source

pub fn reset_electrsd(self) -> Result<Self>

Source

pub fn mine_blocks( &self, count: usize, address: Option<Address>, ) -> Result<Vec<BlockHash>>

Mine a number of blocks of a given size count, which may be specified to a given coinbase address.

Source

pub fn mine_empty_block(&self) -> Result<(usize, BlockHash)>

Mine a block that is guaranteed to be empty even with transactions in the mempool.

Source

pub fn wait_until_electrum_sees_block(&self, timeout: Duration) -> Result<()>

This method waits for the Electrum notification indicating that a new block has been mined. timeout is the maximum Duration we want to wait for a response from Electrsd.

Source

pub fn wait_until_electrum_sees_txid( &self, txid: Txid, timeout: Duration, ) -> Result<()>

This method waits for Electrsd to see a transaction with given txid. timeout is the maximum Duration we want to wait for a response from Electrsd.

Source

pub fn invalidate_blocks(&self, count: usize) -> Result<()>

Invalidate a number of blocks of a given size count.

Source

pub fn reorg(&self, count: usize) -> Result<Vec<BlockHash>>

Reorg a number of blocks of a given size count. Refer to TestEnv::mine_empty_block for more information.

Source

pub fn reorg_empty_blocks( &self, count: usize, ) -> Result<Vec<(usize, BlockHash)>>

Reorg with a number of empty blocks of a given size count.

Source

pub fn send( &self, address: &Address<NetworkChecked>, amount: Amount, ) -> Result<Txid>

Send a tx of a given amount to a given address.

Source

pub fn make_checkpoint_tip(&self) -> CheckPoint

Create a checkpoint linked list of all the blocks in the chain.

Source

pub fn genesis_hash(&self) -> Result<BlockHash>

Get the genesis hash of the blockchain.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V