@@ -9,32 +9,32 @@ use bdk_chain::{
9
9
local_chain:: CheckPoint ,
10
10
BlockId ,
11
11
} ;
12
- use bitcoincore_rpc:: {
13
- bitcoincore_rpc_json:: { GetBlockTemplateModes , GetBlockTemplateRules } ,
14
- RpcApi ,
15
- } ;
16
- use electrsd:: bitcoind :: anyhow:: Context ;
12
+ // use bitcoincore_rpc::{
13
+ // bitcoincore_rpc_json::{GetBlockTemplateModes, GetBlockTemplateRules},
14
+ // RpcApi,
15
+ // };
16
+ use electrsd:: corepc_node :: anyhow:: Context ;
17
17
18
18
pub use electrsd;
19
- pub use electrsd:: bitcoind ;
20
- pub use electrsd:: bitcoind :: anyhow ;
21
- pub use electrsd:: bitcoind :: bitcoincore_rpc ;
19
+ pub use electrsd:: corepc_client ;
20
+ pub use electrsd:: corepc_node ;
21
+ pub use electrsd:: corepc_node :: anyhow ;
22
22
pub use electrsd:: electrum_client;
23
23
use electrsd:: electrum_client:: ElectrumApi ;
24
- use std:: time:: Duration ;
24
+ use std:: { str :: FromStr , time:: Duration } ;
25
25
26
26
/// Struct for running a regtest environment with a single `bitcoind` node with an `electrs`
27
27
/// instance connected to it.
28
28
pub struct TestEnv {
29
- pub bitcoind : electrsd:: bitcoind :: BitcoinD ,
29
+ pub bitcoind : electrsd:: corepc_node :: Node ,
30
30
pub electrsd : electrsd:: ElectrsD ,
31
31
}
32
32
33
33
/// Configuration parameters.
34
34
#[ derive( Debug ) ]
35
35
pub struct Config < ' a > {
36
36
/// [`bitcoind::Conf`]
37
- pub bitcoind : bitcoind :: Conf < ' a > ,
37
+ pub bitcoind : corepc_node :: Conf < ' a > ,
38
38
/// [`electrsd::Conf`]
39
39
pub electrsd : electrsd:: Conf < ' a > ,
40
40
}
@@ -44,7 +44,7 @@ impl Default for Config<'_> {
44
44
/// which is required for testing `bdk_esplora`.
45
45
fn default ( ) -> Self {
46
46
Self {
47
- bitcoind : bitcoind :: Conf :: default ( ) ,
47
+ bitcoind : corepc_node :: Conf :: default ( ) ,
48
48
electrsd : {
49
49
let mut conf = electrsd:: Conf :: default ( ) ;
50
50
conf. http_enabled = true ;
@@ -64,11 +64,11 @@ impl TestEnv {
64
64
pub fn new_with_config ( config : Config ) -> anyhow:: Result < Self > {
65
65
let bitcoind_exe = match std:: env:: var ( "BITCOIND_EXE" ) {
66
66
Ok ( path) => path,
67
- Err ( _) => bitcoind :: downloaded_exe_path ( ) . context (
67
+ Err ( _) => corepc_node :: downloaded_exe_path ( ) . context (
68
68
"you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature" ,
69
69
) ?,
70
70
} ;
71
- let bitcoind = bitcoind :: BitcoinD :: with_conf ( bitcoind_exe, & config. bitcoind ) ?;
71
+ let bitcoind = corepc_node :: Node :: with_conf ( bitcoind_exe, & config. bitcoind ) ?;
72
72
73
73
let electrs_exe = match std:: env:: var ( "ELECTRS_EXE" ) {
74
74
Ok ( path) => path,
@@ -86,7 +86,7 @@ impl TestEnv {
86
86
}
87
87
88
88
/// Exposes the [`RpcApi`] calls from [`bitcoincore_rpc`].
89
- pub fn rpc_client ( & self ) -> & impl RpcApi {
89
+ pub fn rpc_client ( & self ) -> & corepc_node :: Client {
90
90
& self . bitcoind . client
91
91
}
92
92
@@ -117,16 +117,14 @@ impl TestEnv {
117
117
) -> anyhow:: Result < Vec < BlockHash > > {
118
118
let coinbase_address = match address {
119
119
Some ( address) => address,
120
- None => self
121
- . bitcoind
122
- . client
123
- . get_new_address ( None , None ) ?
124
- . assume_checked ( ) ,
120
+ None => self . bitcoind . client . new_address ( ) ?,
125
121
} ;
126
122
let block_hashes = self
127
123
. bitcoind
128
124
. client
129
- . generate_to_address ( count as _ , & coinbase_address) ?;
125
+ . generate_to_address ( count as _ , & coinbase_address) ?
126
+ . into_model ( ) ?
127
+ . 0 ;
130
128
Ok ( block_hashes)
131
129
}
132
130
@@ -298,14 +296,17 @@ impl TestEnv {
298
296
. client
299
297
. get_block_hash ( height as u64 )
300
298
. ok ( )
301
- . map ( |hash| BlockId { height, hash } )
299
+ . map ( |get_block_hash| {
300
+ let hash = get_block_hash. block_hash ( ) . expect ( "should `successfully convert to `BlockHash` from `GetBlockHash`" ) ;
301
+ BlockId { height, hash }
302
+ } )
302
303
} ) )
303
304
. expect ( "must craft tip" )
304
305
}
305
306
306
307
/// Get the genesis hash of the blockchain.
307
308
pub fn genesis_hash ( & self ) -> anyhow:: Result < BlockHash > {
308
- let hash = self . bitcoind . client . get_block_hash ( 0 ) ?;
309
+ let hash = self . bitcoind . client . get_block_hash ( 0 ) ?. into_model ( ) ? . 0 ;
309
310
Ok ( hash)
310
311
}
311
312
}
0 commit comments