/ fedimint-testing / src / btc / mod.rs
mod.rs
 1  pub mod mock;
 2  pub mod real;
 3  
 4  use async_trait::async_trait;
 5  use bitcoin::{Address, Transaction, Txid};
 6  use fedimint_core::txoproof::TxOutProof;
 7  use fedimint_core::Amount;
 8  
 9  #[async_trait]
10  pub trait BitcoinTest {
11      /// Make the underlying instance act as if it was exclusively available
12      /// for the existence of the returned guard.
13      async fn lock_exclusive(&self) -> Box<dyn BitcoinTest + Send + Sync>;
14  
15      /// Mines a given number of blocks
16      async fn mine_blocks(&self, block_num: u64);
17  
18      /// Prepare funding wallet
19      ///
20      /// If needed will mine initial 100 blocks for `send_and_mine_block` to
21      /// work.
22      async fn prepare_funding_wallet(&self);
23  
24      /// Send some bitcoin to an address then mine a block to confirm it.
25      /// Returns the proof that the transaction occurred.
26      ///
27      /// The implementation is responsible for making sure the funds can
28      /// be sent (e.g. first 100 blocks are mined to make funds available)
29      async fn send_and_mine_block(
30          &self,
31          address: &Address,
32          amount: bitcoin::Amount,
33      ) -> (TxOutProof, Transaction);
34  
35      /// Returns a new address.
36      async fn get_new_address(&self) -> Address;
37  
38      /// Mine a block to include any pending transactions then get the amount
39      /// received to an address
40      async fn mine_block_and_get_received(&self, address: &Address) -> Amount;
41  
42      /// Waits till tx is found in mempool and returns the fees
43      async fn get_mempool_tx_fee(&self, txid: &Txid) -> Amount;
44  }