1- use std:: { collections:: BTreeSet , ops :: Deref } ;
1+ use std:: collections:: BTreeSet ;
22
3+ use bdk_bitcoind_client:: jsonrpc:: serde_json;
34use bdk_bitcoind_rpc:: { Emitter , NO_EXPECTED_MEMPOOL_TXS } ;
45use bdk_chain:: {
56 bitcoin:: { Address , Amount , Txid } ,
67 local_chain:: { CheckPoint , LocalChain } ,
78 spk_txout:: SpkTxOutIndex ,
89 Balance , BlockId , CanonicalizationParams , IndexedTxGraph , Merge ,
910} ;
10- use bdk_testenv:: {
11- anyhow,
12- corepc_node:: { Input , Output } ,
13- TestEnv ,
14- } ;
15- use bitcoin:: { hashes:: Hash , Block , Network , ScriptBuf , WScriptHash } ;
11+ use bdk_testenv:: { anyhow, TestEnv } ;
12+ use bitcoin:: { hashes:: Hash , Block , Network , OutPoint , ScriptBuf , WScriptHash } ;
1613
1714use crate :: common:: ClientExt ;
1815
@@ -31,14 +28,14 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
3128 let ( mut local_chain, _) = LocalChain :: from_genesis ( env. genesis_hash ( ) ?) ;
3229
3330 let client = ClientExt :: get_rpc_client ( & env) ?;
34- let mut emitter = Emitter :: new ( & client, local_chain. tip ( ) , 0 , NO_EXPECTED_MEMPOOL_TXS ) ;
31+ let mut emitter = Emitter :: new ( client, local_chain. tip ( ) , 0 , NO_EXPECTED_MEMPOOL_TXS ) ;
3532
3633 // Mine some blocks and return the actual block hashes.
3734 // Because initializing `ElectrsD` already mines some blocks, we must include those too when
3835 // returning block hashes.
3936 let exp_hashes = {
4037 let mut hashes = ( 0 ..=network_tip)
41- . map ( |height| env. get_block_hash ( height) )
38+ . map ( |height| env. get_block_hash ( height as u64 ) )
4239 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
4340 hashes. extend ( env. mine_blocks ( 101 - network_tip as usize , None ) ?) ;
4441 hashes
@@ -171,7 +168,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
171168 } ) ;
172169
173170 let client = ClientExt :: get_rpc_client ( & env) ?;
174- let emitter = & mut Emitter :: new ( & client, chain. tip ( ) , 0 , NO_EXPECTED_MEMPOOL_TXS ) ;
171+ let emitter = & mut Emitter :: new ( client, chain. tip ( ) , 0 , NO_EXPECTED_MEMPOOL_TXS ) ;
175172
176173 while let Some ( emission) = emitter. next_block ( ) ? {
177174 let height = emission. block_height ( ) ;
@@ -183,6 +180,8 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
183180 // send 3 txs to a tracked address, these txs will be in the mempool
184181 let exp_txids = {
185182 let mut txids = BTreeSet :: new ( ) ;
183+ let client = ClientExt :: get_rpc_client ( & env) ?;
184+
186185 for _ in 0 ..3 {
187186 txids. insert (
188187 env. rpc_client ( )
@@ -261,7 +260,7 @@ fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> {
261260
262261 let client = ClientExt :: get_rpc_client ( & env) ?;
263262 let mut emitter = Emitter :: new (
264- & client,
263+ client,
265264 CheckPoint :: new ( 0 , env. genesis_hash ( ) ?) ,
266265 EMITTER_START_HEIGHT as _ ,
267266 NO_EXPECTED_MEMPOOL_TXS ,
@@ -298,15 +297,11 @@ fn process_block(
298297 Ok ( ( ) )
299298}
300299
301- fn sync_from_emitter < C > (
300+ fn sync_from_emitter (
302301 recv_chain : & mut LocalChain ,
303302 recv_graph : & mut IndexedTxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
304- emitter : & mut Emitter < C > ,
305- ) -> anyhow:: Result < ( ) >
306- where
307- C : Deref ,
308- C :: Target : bitcoincore_rpc:: RpcApi ,
309- {
303+ emitter : & mut Emitter ,
304+ ) -> anyhow:: Result < ( ) > {
310305 while let Some ( emission) = emitter. next_block ( ) ? {
311306 let height = emission. block_height ( ) ;
312307 process_block ( recv_chain, recv_graph, emission. block , height) ?;
@@ -338,7 +333,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
338333
339334 let client = ClientExt :: get_rpc_client ( & env) ?;
340335 let mut emitter = Emitter :: new (
341- & client,
336+ client,
342337 CheckPoint :: new ( 0 , env. genesis_hash ( ) ?) ,
343338 0 ,
344339 NO_EXPECTED_MEMPOOL_TXS ,
@@ -350,6 +345,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
350345 . get_new_address ( None , None ) ?
351346 . address ( ) ?
352347 . assume_checked ( ) ;
348+
353349 let spk_to_track = ScriptBuf :: new_p2wsh ( & WScriptHash :: all_zeros ( ) ) ;
354350 let addr_to_track = Address :: from_script ( & spk_to_track, Network :: Regtest ) ?;
355351
@@ -431,7 +427,7 @@ fn mempool_avoids_re_emission() -> anyhow::Result<()> {
431427
432428 let client = ClientExt :: get_rpc_client ( & env) ?;
433429 let mut emitter = Emitter :: new (
434- & client,
430+ client,
435431 CheckPoint :: new ( 0 , env. genesis_hash ( ) ?) ,
436432 0 ,
437433 NO_EXPECTED_MEMPOOL_TXS ,
@@ -503,7 +499,7 @@ fn no_agreement_point() -> anyhow::Result<()> {
503499 let client = ClientExt :: get_rpc_client ( & env) ?;
504500 // start height is 99
505501 let mut emitter = Emitter :: new (
506- & client,
502+ client,
507503 CheckPoint :: new ( 0 , env. genesis_hash ( ) ?) ,
508504 ( PREMINE_COUNT - 2 ) as u32 ,
509505 NO_EXPECTED_MEMPOOL_TXS ,
@@ -560,7 +556,6 @@ fn no_agreement_point() -> anyhow::Result<()> {
560556/// 3. Insert the eviction into the graph and assert tx1 is no longer canonical.
561557#[ test]
562558fn test_expect_tx_evicted ( ) -> anyhow:: Result < ( ) > {
563- use bdk_bitcoind_rpc:: bitcoincore_rpc:: bitcoin;
564559 use bdk_chain:: miniscript;
565560 use bdk_chain:: spk_txout:: SpkTxOutIndex ;
566561 use bitcoin:: constants:: genesis_block;
@@ -590,7 +585,7 @@ fn test_expect_tx_evicted() -> anyhow::Result<()> {
590585 let tx_1 = env. rpc_client ( ) . get_transaction ( txid_1) ?. into_model ( ) ?. tx ;
591586
592587 let client = ClientExt :: get_rpc_client ( & env) ?;
593- let mut emitter = Emitter :: new ( & client, chain. tip ( ) , 1 , core:: iter:: once ( tx_1) ) ;
588+ let mut emitter = Emitter :: new ( client, chain. tip ( ) , 1 , core:: iter:: once ( tx_1) ) ;
594589 while let Some ( emission) = emitter. next_block ( ) ? {
595590 let height = emission. block_height ( ) ;
596591 chain. apply_header ( & emission. block . header , height) ?;
@@ -674,7 +669,7 @@ fn detect_new_mempool_txs() -> anyhow::Result<()> {
674669
675670 let client = ClientExt :: get_rpc_client ( & env) ?;
676671 let mut emitter = Emitter :: new (
677- & client,
672+ client,
678673 CheckPoint :: new ( 0 , env. genesis_hash ( ) ?) ,
679674 0 ,
680675 NO_EXPECTED_MEMPOOL_TXS ,
0 commit comments