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: ElectrsDImplementations§
Source§impl TestEnv
impl TestEnv
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Construct a new TestEnv instance with the default configuration used by BDK.
Sourcepub fn new_with_config(config: Config<'_>) -> Result<Self>
pub fn new_with_config(config: Config<'_>) -> Result<Self>
Sourcepub fn electrum_client(&self) -> &impl ElectrumApi
pub fn electrum_client(&self) -> &impl ElectrumApi
Exposes the [ElectrumApi] calls from the Electrum client.
Sourcepub fn rpc_client(&self) -> &impl RpcApi
pub fn rpc_client(&self) -> &impl RpcApi
Exposes the [RpcApi] calls from [bitcoincore_rpc].
pub fn reset_electrsd(self) -> Result<Self>
Sourcepub fn mine_blocks(
&self,
count: usize,
address: Option<Address>,
) -> Result<Vec<BlockHash>>
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.
Sourcepub fn mine_empty_block(&self) -> Result<(usize, BlockHash)>
pub fn mine_empty_block(&self) -> Result<(usize, BlockHash)>
Mine a block that is guaranteed to be empty even with transactions in the mempool.
Sourcepub fn wait_until_electrum_sees_block(&self, timeout: Duration) -> Result<()>
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.
Sourcepub fn wait_until_electrum_sees_txid(
&self,
txid: Txid,
timeout: Duration,
) -> Result<()>
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.
Sourcepub fn invalidate_blocks(&self, count: usize) -> Result<()>
pub fn invalidate_blocks(&self, count: usize) -> Result<()>
Invalidate a number of blocks of a given size count.
Sourcepub fn reorg(&self, count: usize) -> Result<Vec<BlockHash>>
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.
Sourcepub fn reorg_empty_blocks(
&self,
count: usize,
) -> Result<Vec<(usize, BlockHash)>>
pub fn reorg_empty_blocks( &self, count: usize, ) -> Result<Vec<(usize, BlockHash)>>
Reorg with a number of empty blocks of a given size count.
Sourcepub fn send(
&self,
address: &Address<NetworkChecked>,
amount: Amount,
) -> Result<Txid>
pub fn send( &self, address: &Address<NetworkChecked>, amount: Amount, ) -> Result<Txid>
Send a tx of a given amount to a given address.
Sourcepub fn make_checkpoint_tip(&self) -> CheckPoint
pub fn make_checkpoint_tip(&self) -> CheckPoint
Create a checkpoint linked list of all the blocks in the chain.
Sourcepub fn genesis_hash(&self) -> Result<BlockHash>
pub fn genesis_hash(&self) -> Result<BlockHash>
Get the genesis hash of the blockchain.
Auto Trait Implementations§
impl !Freeze for TestEnv
impl !RefUnwindSafe for TestEnv
impl Send for TestEnv
impl Sync for TestEnv
impl Unpin for TestEnv
impl !UnwindSafe for TestEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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