Skip to main content

BitcoinTest

Trait BitcoinTest 

Source
pub trait BitcoinTest {
Show 13 methods // Required methods fn lock_exclusive<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Box<dyn BitcoinTest + Send + Sync>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn mine_blocks<'life0, 'async_trait>( &'life0 self, block_num: u64, ) -> Pin<Box<dyn Future<Output = Vec<BlockHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn prepare_funding_wallet<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn send_and_mine_block<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, amount: Amount, ) -> Pin<Box<dyn Future<Output = (TxOutProof, Transaction)> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn send_without_mining<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, amount: Amount, ) -> Pin<Box<dyn Future<Output = Transaction> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_new_address<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Address> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn mine_block_and_get_received<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, ) -> Pin<Box<dyn Future<Output = Amount> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_mempool_tx_fee<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Amount> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_tx_block_height<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_block_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_mempool_tx<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Option<Transaction>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn fail_mempool_tx_fetches(&self, _failing: bool) { ... } fn delay_mempool_tx_fetches(&self, _delay: Duration) { ... }
}

Required Methods§

Source

fn lock_exclusive<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Box<dyn BitcoinTest + Send + Sync>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Make the underlying instance act as if it was exclusively available for the existence of the returned guard.

Source

fn mine_blocks<'life0, 'async_trait>( &'life0 self, block_num: u64, ) -> Pin<Box<dyn Future<Output = Vec<BlockHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mines a given number of blocks

Source

fn prepare_funding_wallet<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prepare funding wallet

If needed will mine initial 100 blocks for send_and_mine_block to work.

Source

fn send_and_mine_block<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, amount: Amount, ) -> Pin<Box<dyn Future<Output = (TxOutProof, Transaction)> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send some bitcoin to an address then mine a block to confirm it. Returns the proof that the transaction occurred.

The implementation is responsible for making sure the funds can be sent (e.g. first 100 blocks are mined to make funds available)

Source

fn send_without_mining<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, amount: Amount, ) -> Pin<Box<dyn Future<Output = Transaction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send some bitcoin to an address and leave the transaction unconfirmed in the mempool.

The counterpart to BitcoinTest::send_and_mine_block, for exercising behaviour that depends on a transaction being seen before it is mined. Mine a block afterwards to confirm it.

Source

fn get_new_address<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Address> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a new address.

Source

fn mine_block_and_get_received<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, ) -> Pin<Box<dyn Future<Output = Amount> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mine a block to include any pending transactions then get the amount received to an address

Source

fn get_mempool_tx_fee<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Amount> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Waits till tx is found in mempool and returns the fees

Source

fn get_tx_block_height<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the block height for the txid if found.

Note: this exists since there’s a bug for using bitcoind without txindex for finding a tx block height. see: <https://github.com/fedimint/fedimint/issues/5329>

Source

fn get_block_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the current block count

Source

fn get_mempool_tx<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Option<Transaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns a transaction with the provided txid if it exists in the mempool

Provided Methods§

Source

fn fail_mempool_tx_fetches(&self, _failing: bool)

Makes every subsequent mempool transaction fetch by a guardian fail, until called again with false.

Lets a test drive a guardian’s mempool scan into failing partway through, which is otherwise only reachable by breaking a real node. Listing the mempool keeps working, so the guardian still learns which transactions exist and only the fetches fail.

Only the mock backend can do this, so a test that calls it must skip itself on real daemons via Fixtures::is_real_test.

Source

fn delay_mempool_tx_fetches(&self, _delay: Duration)

Makes every subsequent mempool transaction fetch by a guardian take delay before answering, until called again with Duration::ZERO.

Lets a test make a guardian’s mempool scan slow enough to run out of its time budget, which is otherwise only reachable with a large mempool.

Only the mock backend can do this, so a test that calls it must skip itself on real daemons via Fixtures::is_real_test.

Implementors§