@@ -2473,7 +2473,7 @@ async fn persistence_backwards_compatibility() {
24732473#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
24742474async fn onchain_fee_bump_rbf ( ) {
24752475 let ( bitcoind, electrsd) = setup_bitcoind_and_electrsd ( ) ;
2476- let chain_source = TestChainSource :: Esplora ( & electrsd) ;
2476+ let chain_source = random_chain_source ( & bitcoind , & electrsd) ;
24772477 let ( node_a, node_b) = setup_two_nodes ( & chain_source, false , true , false ) ;
24782478
24792479 // Fund both nodes
@@ -2497,6 +2497,10 @@ async fn onchain_fee_bump_rbf() {
24972497 let txid =
24982498 node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
24992499 wait_for_tx ( & electrsd. client , txid) . await ;
2500+ // Give the chain source time to index the unconfirmed transaction before syncing.
2501+ // Without this, Esplora may not yet have the tx, causing sync to miss it and
2502+ // leaving the BDK wallet graph empty.
2503+ tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
25002504 node_a. sync_wallets ( ) . unwrap ( ) ;
25012505 node_b. sync_wallets ( ) . unwrap ( ) ;
25022506
@@ -2522,10 +2526,10 @@ async fn onchain_fee_bump_rbf() {
25222526 // Successful fee bump
25232527 let new_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25242528 wait_for_tx ( & electrsd. client , new_txid) . await ;
2525-
2526- // Sleep to allow for transaction propagation
2529+ // Give the chain source time to index the unconfirmed transaction before syncing.
2530+ // Without this, Esplora may not yet have the tx, causing sync to miss it and
2531+ // leaving the BDK wallet graph empty.
25272532 tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
2528-
25292533 node_a. sync_wallets ( ) . unwrap ( ) ;
25302534 node_b. sync_wallets ( ) . unwrap ( ) ;
25312535
@@ -2547,26 +2551,9 @@ async fn onchain_fee_bump_rbf() {
25472551 _ => panic ! ( "Unexpected payment kind" ) ,
25482552 }
25492553
2550- // Verify node_a has the inbound payment txid updated to the replacement txid
2551- let node_a_inbound_payment = node_a. payment ( & payment_id) . unwrap ( ) ;
2552- assert_eq ! ( node_a_inbound_payment. direction, PaymentDirection :: Inbound ) ;
2553- match & node_a_inbound_payment. kind {
2554- PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2555- assert_eq ! (
2556- * inbound_txid, new_txid,
2557- "node_a inbound payment txid should be updated to the replacement txid"
2558- ) ;
2559- } ,
2560- _ => panic ! ( "Unexpected payment kind" ) ,
2561- }
2562-
25632554 // Multiple consecutive bumps
25642555 let second_bump_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25652556 wait_for_tx ( & electrsd. client , second_bump_txid) . await ;
2566-
2567- // Sleep to allow for transaction propagation
2568- tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
2569-
25702557 node_a. sync_wallets ( ) . unwrap ( ) ;
25712558 node_b. sync_wallets ( ) . unwrap ( ) ;
25722559
@@ -2586,19 +2573,6 @@ async fn onchain_fee_bump_rbf() {
25862573 _ => panic ! ( "Unexpected payment kind" ) ,
25872574 }
25882575
2589- // Verify node_a has the inbound payment txid updated to the second replacement txid
2590- let node_a_second_inbound_payment = node_a. payment ( & payment_id) . unwrap ( ) ;
2591- assert_eq ! ( node_a_second_inbound_payment. direction, PaymentDirection :: Inbound ) ;
2592- match & node_a_second_inbound_payment. kind {
2593- PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2594- assert_eq ! (
2595- * inbound_txid, second_bump_txid,
2596- "node_a inbound payment txid should be updated to the second replacement txid"
2597- ) ;
2598- } ,
2599- _ => panic ! ( "Unexpected payment kind" ) ,
2600- }
2601-
26022576 // Confirm the transaction and try to bump again (should fail)
26032577 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) . await ;
26042578 node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -2620,10 +2594,20 @@ async fn onchain_fee_bump_rbf() {
26202594 }
26212595
26222596 // Verify node A received the funds correctly
2623- let node_a_received_payment = node_a. list_payments_with_filter (
2624- |p| matches ! ( p. kind, PaymentKind :: Onchain { txid, .. } if txid == second_bump_txid) ,
2625- ) ;
2597+ let node_a_received_payment = node_a. list_payments_with_filter ( |p| {
2598+ p. id == payment_id && matches ! ( p. kind, PaymentKind :: Onchain { .. } )
2599+ } ) ;
2600+
26262601 assert_eq ! ( node_a_received_payment. len( ) , 1 ) ;
2602+ match & node_a_received_payment[ 0 ] . kind {
2603+ PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2604+ assert_eq ! (
2605+ * inbound_txid, second_bump_txid,
2606+ "node_a inbound payment txid should be updated to the second replacement txid"
2607+ ) ;
2608+ } ,
2609+ _ => panic ! ( "Unexpected payment kind" ) ,
2610+ }
26272611 assert_eq ! ( node_a_received_payment[ 0 ] . amount_msat, Some ( amount_to_send_sats * 1000 ) ) ;
26282612 assert_eq ! ( node_a_received_payment[ 0 ] . status, PaymentStatus :: Succeeded ) ;
26292613}
0 commit comments