@@ -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
@@ -2515,10 +2515,6 @@ async fn onchain_fee_bump_rbf() {
25152515 // Successful fee bump
25162516 let new_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25172517 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-
25222518 node_a. sync_wallets ( ) . unwrap ( ) ;
25232519 node_b. sync_wallets ( ) . unwrap ( ) ;
25242520
@@ -2540,26 +2536,13 @@ async fn onchain_fee_bump_rbf() {
25402536 _ => panic ! ( "Unexpected payment kind" ) ,
25412537 }
25422538
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- }
2539+ // Brief delay before second bump: mirrors real-world usage where a user
2540+ // waits between bumps, giving the wallet sync cycle time to complete.
2541+ tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
25552542
25562543 // Multiple consecutive bumps
25572544 let second_bump_txid = node_b. onchain_payment ( ) . bump_fee_rbf ( payment_id, None ) . unwrap ( ) ;
25582545 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-
25632546 node_a. sync_wallets ( ) . unwrap ( ) ;
25642547 node_b. sync_wallets ( ) . unwrap ( ) ;
25652548
@@ -2579,19 +2562,6 @@ async fn onchain_fee_bump_rbf() {
25792562 _ => panic ! ( "Unexpected payment kind" ) ,
25802563 }
25812564
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-
25952565 // Confirm the transaction and try to bump again (should fail)
25962566 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) . await ;
25972567 node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -2613,10 +2583,20 @@ async fn onchain_fee_bump_rbf() {
26132583 }
26142584
26152585 // 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- ) ;
2586+ let node_a_received_payment = node_a. list_payments_with_filter ( |p| {
2587+ p. id == payment_id && matches ! ( p. kind, PaymentKind :: Onchain { .. } )
2588+ } ) ;
2589+
26192590 assert_eq ! ( node_a_received_payment. len( ) , 1 ) ;
2591+ match & node_a_received_payment[ 0 ] . kind {
2592+ PaymentKind :: Onchain { txid : inbound_txid, .. } => {
2593+ assert_eq ! (
2594+ * inbound_txid, second_bump_txid,
2595+ "node_a inbound payment txid should be updated to the second replacement txid"
2596+ ) ;
2597+ } ,
2598+ _ => panic ! ( "Unexpected payment kind" ) ,
2599+ }
26202600 assert_eq ! ( node_a_received_payment[ 0 ] . amount_msat, Some ( amount_to_send_sats * 1000 ) ) ;
26212601 assert_eq ! ( node_a_received_payment[ 0 ] . status, PaymentStatus :: Succeeded ) ;
26222602}
0 commit comments