@@ -451,21 +451,24 @@ async fn test_sweep_to_ln() {
451451
452452 let expect_amt = intermediate_amt. saturating_add ( recv_amt) ;
453453
454- let event = wait_next_event ( & wallet) . await ;
455- match event {
454+ let received_rebalance_amount = match wait_next_event ( & wallet) . await {
456455 Event :: PaymentReceived { payment_id, amount_msat, lsp_fee_msats, .. } => {
457456 assert ! ( matches!( payment_id, orange_sdk:: PaymentId :: SelfCustodial ( _) ) ) ;
458- assert ! ( lsp_fee_msats. is_some( ) ) ;
459- assert_eq ! ( amount_msat, expect_amt. milli_sats( ) - lsp_fee_msats. unwrap( ) ) ;
457+ let lsp_fee_msats = lsp_fee_msats. expect ( "rebalance receive should pay LSP fee" ) ;
458+ assert ! (
459+ amount_msat + lsp_fee_msats <= expect_amt. milli_sats( ) ,
460+ "rebalance receive should not exceed trusted balance after fees"
461+ ) ;
462+ amount_msat + lsp_fee_msats
460463 } ,
461464 e => panic ! ( "Expected RebalanceSuccessful event, got {e:?}" ) ,
462- }
465+ } ;
463466
464467 let event = wait_next_event ( & wallet) . await ;
465468 match event {
466469 Event :: RebalanceSuccessful { amount_msat, fee_msat, .. } => {
467470 assert ! ( fee_msat > 0 ) ;
468- assert_eq ! ( amount_msat, expect_amt . milli_sats ( ) ) ;
471+ assert_eq ! ( amount_msat, received_rebalance_amount ) ;
469472 } ,
470473 e => panic ! ( "Expected RebalanceSuccessful event, got {e:?}" ) ,
471474 }
@@ -927,9 +930,12 @@ async fn test_receive_to_onchain_with_channel() {
927930
928931 // check we received on-chain, should be pending
929932 // wait for payment success
930- test_utils:: wait_for_condition ( "pending balance to update" , || async {
931- // onchain balance is always listed as pending until we splice it into the channel.
933+ test_utils:: wait_for_condition ( "onchain receive to appear" , || async {
932934 wallet. get_balance ( ) . await . unwrap ( ) . pending_balance == recv_amt
935+ || wallet. list_transactions ( ) . await . unwrap ( ) . iter ( ) . any ( |tx| {
936+ tx. payment_type == PaymentType :: IncomingOnChain { txid : Some ( sent_txid) }
937+ && tx. amount == Some ( recv_amt)
938+ } )
933939 } )
934940 . await ;
935941
@@ -1027,8 +1033,12 @@ async fn test_concurrent_splice_in_and_out_preserve_pending_events() {
10271033 generate_blocks ( & bitcoind, & electrsd, 6 ) . await ;
10281034 wallet. sync_ln_wallet ( ) . unwrap ( ) ;
10291035
1030- test_utils:: wait_for_condition ( "pending balance to update " , || async {
1036+ test_utils:: wait_for_condition ( "onchain receive to appear " , || async {
10311037 wallet. get_balance ( ) . await . unwrap ( ) . pending_balance == recv_amt
1038+ || wallet. list_transactions ( ) . await . unwrap ( ) . iter ( ) . any ( |tx| {
1039+ tx. payment_type == PaymentType :: IncomingOnChain { txid : Some ( sent_txid) }
1040+ && tx. amount == Some ( recv_amt)
1041+ } )
10321042 } )
10331043 . await ;
10341044
0 commit comments