|
2 | 2 |
|
3 | 3 | pub mod utils; |
4 | 4 |
|
5 | | -use bdk_chain::{ |
6 | | - bitcoin::{ |
7 | | - address::NetworkChecked, block::Header, hash_types::TxMerkleNode, hashes::Hash, |
8 | | - secp256k1::rand::random, transaction, Address, Amount, Block, BlockHash, ScriptBuf, |
9 | | - ScriptHash, Transaction, TxIn, TxOut, Txid, |
10 | | - }, |
11 | | - local_chain::CheckPoint, |
12 | | -}; |
13 | | -use electrsd::corepc_node::{anyhow::Context, TemplateRequest, TemplateRules}; |
| 5 | +use anyhow::Context; |
| 6 | +use bdk_chain::CheckPoint; |
| 7 | +use bitcoin::{address::NetworkChecked, Address, Amount, BlockHash, Txid}; |
| 8 | +use std::time::Duration; |
14 | 9 |
|
15 | 10 | pub use electrsd; |
16 | 11 | pub use electrsd::corepc_client; |
17 | 12 | pub use electrsd::corepc_node; |
18 | 13 | pub use electrsd::corepc_node::anyhow; |
19 | 14 | pub use electrsd::electrum_client; |
20 | 15 | use electrsd::electrum_client::ElectrumApi; |
21 | | -use std::time::Duration; |
22 | 16 |
|
23 | 17 | /// Struct for running a regtest environment with a single `bitcoind` node with an `electrs` |
24 | 18 | /// instance connected to it. |
@@ -126,7 +120,14 @@ impl TestEnv { |
126 | 120 | } |
127 | 121 |
|
128 | 122 | /// Mine a block that is guaranteed to be empty even with transactions in the mempool. |
| 123 | + #[cfg(feature = "std")] |
129 | 124 | pub fn mine_empty_block(&self) -> anyhow::Result<(usize, BlockHash)> { |
| 125 | + use bitcoin::secp256k1::rand::random; |
| 126 | + use bitcoin::{ |
| 127 | + block::Header, hashes::Hash, transaction, Block, ScriptBuf, ScriptHash, Transaction, |
| 128 | + TxIn, TxMerkleNode, TxOut, |
| 129 | + }; |
| 130 | + use corepc_node::{TemplateRequest, TemplateRules}; |
130 | 131 | let request = TemplateRequest { |
131 | 132 | rules: vec![TemplateRules::Segwit], |
132 | 133 | }; |
@@ -266,6 +267,7 @@ impl TestEnv { |
266 | 267 | } |
267 | 268 |
|
268 | 269 | /// Reorg with a number of empty blocks of a given size `count`. |
| 270 | + #[cfg(feature = "std")] |
269 | 271 | pub fn reorg_empty_blocks(&self, count: usize) -> anyhow::Result<Vec<(usize, BlockHash)>> { |
270 | 272 | let start_height = self.bitcoind.client.get_block_count()?; |
271 | 273 | self.invalidate_blocks(count)?; |
|
0 commit comments