@@ -2466,7 +2466,7 @@ async fn persistence_backwards_compatibility() {
24662466#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
24672467async fn onchain_fee_bump_rbf ( ) {
24682468 let ( bitcoind, electrsd) = setup_bitcoind_and_electrsd ( ) ;
2469- let chain_source = TestChainSource :: Esplora ( & electrsd) ;
2469+ let chain_source = random_chain_source ( & bitcoind , & electrsd) ;
24702470 let ( node_a, node_b) = setup_two_nodes ( & chain_source, false , true , false ) ;
24712471
24722472 // Fund both nodes
@@ -2490,6 +2490,10 @@ async fn onchain_fee_bump_rbf() {
24902490 let txid =
24912491 node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
24922492 wait_for_tx ( & electrsd. client , txid) . await ;
2493+ // Give the chain source time to index the unconfirmed transaction before syncing.
2494+ // Without this, Esplora may not yet have the tx, causing sync to miss it and
2495+ // leaving the BDK wallet graph empty.
2496+ tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) . await ;
24932497 node_a. sync_wallets ( ) . unwrap ( ) ;
24942498 node_b. sync_wallets ( ) . unwrap ( ) ;
24952499
@@ -2515,10 +2519,10 @@ async fn onchain_fee_bump_rbf() {
25152519 // Successful fee bump
25162520 let new_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25172521 wait_for_tx ( & electrsd. client , new_txid) . await ;
2518-
2519- // Sleep to allow for transaction propagation
2520- tokio :: time :: sleep ( std :: time :: Duration :: from_secs ( 5 ) ) . await ;
2521-
2522+ // Give the chain source time to index the unconfirmed transaction before syncing.
2523+ // Without this, Esplora may not yet have the tx, causing sync to miss it and
2524+ // leaving the BDK wallet graph empty.
2525+ tokio :: time :: sleep ( std :: time :: Duration :: from_secs ( 1 ) ) . await ;
25222526 node_a. sync_wallets ( ) . unwrap ( ) ;
25232527 node_b. sync_wallets ( ) . unwrap ( ) ;
25242528
@@ -2540,26 +2544,9 @@ async fn onchain_fee_bump_rbf() {
25402544 _ => panic ! ( "Unexpected payment kind" ) ,
25412545 }
25422546
2543- // Verify node_a has the inbound payment txid updated to the replacement txid
2544- let node_a_inbound_payment = node_a. payment ( & payment_id) . unwrap ( ) ;
2545- assert_eq ! ( node_a_inbound_payment. direction, PaymentDirection :: Inbound ) ;
2546- match & node_a_inbound_payment. kind {
2547- PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2548- assert_eq ! (
2549- * inbound_txid, new_txid,
2550- "node_a inbound payment txid should be updated to the replacement txid"
2551- ) ;
2552- } ,
2553- _ => panic ! ( "Unexpected payment kind" ) ,
2554- }
2555-
25562547 // Multiple consecutive bumps
25572548 let second_bump_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25582549 wait_for_tx ( & electrsd. client , second_bump_txid) . await ;
2559-
2560- // Sleep to allow for transaction propagation
2561- tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
2562-
25632550 node_a. sync_wallets ( ) . unwrap ( ) ;
25642551 node_b. sync_wallets ( ) . unwrap ( ) ;
25652552
@@ -2579,19 +2566,6 @@ async fn onchain_fee_bump_rbf() {
25792566 _ => panic ! ( "Unexpected payment kind" ) ,
25802567 }
25812568
2582- // Verify node_a has the inbound payment txid updated to the second replacement txid
2583- let node_a_second_inbound_payment = node_a. payment ( & payment_id) . unwrap ( ) ;
2584- assert_eq ! ( node_a_second_inbound_payment. direction, PaymentDirection :: Inbound ) ;
2585- match & node_a_second_inbound_payment. kind {
2586- PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2587- assert_eq ! (
2588- * inbound_txid, second_bump_txid,
2589- "node_a inbound payment txid should be updated to the second replacement txid"
2590- ) ;
2591- } ,
2592- _ => panic ! ( "Unexpected payment kind" ) ,
2593- }
2594-
25952569 // Confirm the transaction and try to bump again (should fail)
25962570 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) . await ;
25972571 node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -2613,10 +2587,20 @@ async fn onchain_fee_bump_rbf() {
26132587 }
26142588
26152589 // Verify node A received the funds correctly
2616- let node_a_received_payment = node_a. list_payments_with_filter (
2617- |p| matches ! ( p. kind, PaymentKind :: Onchain { txid, .. } if txid == second_bump_txid) ,
2618- ) ;
2590+ let node_a_received_payment = node_a. list_payments_with_filter ( |p| {
2591+ p. id == payment_id && matches ! ( p. kind, PaymentKind :: Onchain { .. } )
2592+ } ) ;
2593+
26192594 assert_eq ! ( node_a_received_payment. len( ) , 1 ) ;
2595+ match & node_a_received_payment[ 0 ] . kind {
2596+ PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2597+ assert_eq ! (
2598+ * inbound_txid, second_bump_txid,
2599+ "node_a inbound payment txid should be updated to the second replacement txid"
2600+ ) ;
2601+ } ,
2602+ _ => panic ! ( "Unexpected payment kind" ) ,
2603+ }
26202604 assert_eq ! ( node_a_received_payment[ 0 ] . amount_msat, Some ( amount_to_send_sats * 1000 ) ) ;
26212605 assert_eq ! ( node_a_received_payment[ 0 ] . status, PaymentStatus :: Succeeded ) ;
26222606}
0 commit comments