Struct bdk_testenv::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
impl TestEnv
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) -> Result<()>
pub fn wait_until_electrum_sees_block(&self) -> Result<()>
This method waits for the Electrum notification indicating that a new block has been mined.
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 !RefUnwindSafe for TestEnv
impl Send for TestEnv
impl Sync for TestEnv
impl Unpin for TestEnv
impl !UnwindSafe for TestEnv
Blanket Implementations§
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>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
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