11//! Functional tests testing channel feerate handling.
22
33use crate :: events:: { ClosureReason , Event } ;
4- use crate :: ln:: functional_test_utils:: * ;
5- use crate :: ln:: chan_utils:: { self , CommitmentTransaction , commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC , HTLCOutputInCommitment } ;
6- use crate :: ln:: channel:: { Channel , MIN_AFFORDABLE_HTLC_COUNT , get_holder_selected_channel_reserve_satoshis, CONCURRENT_INBOUND_HTLC_FEE_BUFFER } ;
4+ use crate :: ln:: chan_utils:: {
5+ self , commitment_tx_base_weight, CommitmentTransaction , HTLCOutputInCommitment ,
6+ COMMITMENT_TX_WEIGHT_PER_HTLC ,
7+ } ;
8+ use crate :: ln:: channel:: {
9+ get_holder_selected_channel_reserve_satoshis, CONCURRENT_INBOUND_HTLC_FEE_BUFFER ,
10+ MIN_AFFORDABLE_HTLC_COUNT ,
11+ } ;
712use crate :: ln:: channelmanager:: PaymentId ;
13+ use crate :: ln:: functional_test_utils:: * ;
14+ use crate :: ln:: msgs:: {
15+ self , BaseMessageHandler , ChannelMessageHandler , ErrorAction , MessageSendEvent ,
16+ } ;
817use crate :: ln:: outbound_payment:: RecipientOnionFields ;
9- use crate :: ln:: msgs:: { self , BaseMessageHandler , ErrorAction , ChannelMessageHandler , MessageSendEvent } ;
1018use crate :: sign:: ecdsa:: EcdsaChannelSigner ;
1119use crate :: util:: config:: UserConfig ;
1220use crate :: util:: errors:: APIError ;
@@ -29,7 +37,7 @@ pub fn test_async_inbound_update_fee() {
2937 create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
3038
3139 // balancing
32- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
40+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
3341
3442 // A B
3543 // update_fee ->
@@ -69,8 +77,9 @@ pub fn test_async_inbound_update_fee() {
6977
7078 // ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
7179 let ( route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash ! ( nodes[ 1 ] , nodes[ 0 ] , 40000 ) ;
72- nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash,
73- RecipientOnionFields :: secret_only ( our_payment_secret) , PaymentId ( our_payment_hash. 0 ) ) . unwrap ( ) ;
80+ let onion = RecipientOnionFields :: secret_only ( our_payment_secret) ;
81+ let id = PaymentId ( our_payment_hash. 0 ) ;
82+ nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash, onion, id) . unwrap ( ) ;
7483 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
7584
7685 let payment_event = {
@@ -150,7 +159,7 @@ pub fn test_update_fee_unordered_raa() {
150159 create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
151160
152161 // balancing
153- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
162+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
154163
155164 // First nodes[0] generates an update_fee
156165 {
@@ -173,8 +182,9 @@ pub fn test_update_fee_unordered_raa() {
173182
174183 // ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
175184 let ( route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash ! ( nodes[ 1 ] , nodes[ 0 ] , 40000 ) ;
176- nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash,
177- RecipientOnionFields :: secret_only ( our_payment_secret) , PaymentId ( our_payment_hash. 0 ) ) . unwrap ( ) ;
185+ let onion = RecipientOnionFields :: secret_only ( our_payment_secret) ;
186+ let id = PaymentId ( our_payment_hash. 0 ) ;
187+ nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash, onion, id) . unwrap ( ) ;
178188 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
179189
180190 let payment_event = {
@@ -317,7 +327,6 @@ pub fn test_multi_flight_update_fee() {
317327 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
318328}
319329
320-
321330#[ xtest( feature = "_externalize_tests" ) ]
322331pub fn test_update_fee_vanilla ( ) {
323332 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -340,7 +349,7 @@ pub fn test_update_fee_vanilla() {
340349 let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
341350 assert_eq ! ( events_0. len( ) , 1 ) ;
342351 let ( update_msg, commitment_signed) = match events_0[ 0 ] {
343- MessageSendEvent :: UpdateHTLCs { node_id : _ , channel_id : _ , updates : msgs:: CommitmentUpdate { update_add_htlcs : _ , update_fulfill_htlcs : _ , update_fail_htlcs : _ , update_fail_malformed_htlcs : _ , ref update_fee, ref commitment_signed } } => {
352+ MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, ref commitment_signed, .. } , .. } => {
344353 ( update_fee. as_ref ( ) , commitment_signed)
345354 } ,
346355 _ => panic ! ( "Unexpected event" ) ,
@@ -381,7 +390,8 @@ pub fn test_update_fee_that_funder_cannot_afford() {
381390 let channel_id = chan. 2 ;
382391 let secp_ctx = Secp256k1 :: new ( ) ;
383392 let default_config = UserConfig :: default ( ) ;
384- let bs_channel_reserve_sats = get_holder_selected_channel_reserve_satoshis ( channel_value, & default_config) ;
393+ let bs_channel_reserve_sats =
394+ get_holder_selected_channel_reserve_satoshis ( channel_value, & default_config) ;
385395
386396 let channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
387397
@@ -421,24 +431,29 @@ pub fn test_update_fee_that_funder_cannot_afford() {
421431 * feerate_lock += 4 ;
422432 }
423433 nodes[ 0 ] . node . timer_tick_occurred ( ) ;
424- nodes[ 0 ] . logger . assert_log ( "lightning::ln::channel" , format ! ( "Cannot afford to send new feerate at {}" , feerate + 4 ) , 1 ) ;
434+ let err = format ! ( "Cannot afford to send new feerate at {}" , feerate + 4 ) ;
435+ nodes[ 0 ] . logger . assert_log ( "lightning::ln::channel" , err, 1 ) ;
425436 check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
426437
427438 const INITIAL_COMMITMENT_NUMBER : u64 = 281474976710654 ;
428439
429440 let remote_point = {
430- let per_peer_state = nodes[ 1 ] . node . per_peer_state . read ( ) . unwrap ( ) ;
431- let chan_lock = per_peer_state. get ( & node_a_id) . unwrap ( ) . lock ( ) . unwrap ( ) ;
432- let remote_chan = chan_lock. channel_by_id . get ( & chan. 2 ) . and_then ( Channel :: as_funded) . unwrap ( ) ;
433- let chan_signer = remote_chan. get_signer ( ) ;
434- chan_signer. as_ref ( ) . get_per_commitment_point ( INITIAL_COMMITMENT_NUMBER - 1 , & secp_ctx) . unwrap ( )
441+ let mut per_peer_lock;
442+ let mut peer_state_lock;
443+
444+ let channel = get_channel_ref ! ( nodes[ 1 ] , nodes[ 0 ] , per_peer_lock, peer_state_lock, chan. 2 ) ;
445+ let chan_signer = channel. as_funded ( ) . unwrap ( ) . get_signer ( ) ;
446+ let point_number = INITIAL_COMMITMENT_NUMBER - 1 ;
447+ chan_signer. as_ref ( ) . get_per_commitment_point ( point_number, & secp_ctx) . unwrap ( )
435448 } ;
436449
437450 let res = {
438- let per_peer_state = nodes[ 0 ] . node . per_peer_state . read ( ) . unwrap ( ) ;
439- let local_chan_lock = per_peer_state. get ( & node_b_id) . unwrap ( ) . lock ( ) . unwrap ( ) ;
440- let local_chan = local_chan_lock. channel_by_id . get ( & chan. 2 ) . and_then ( Channel :: as_funded) . unwrap ( ) ;
441- let local_chan_signer = local_chan. get_signer ( ) ;
451+ let mut per_peer_lock;
452+ let mut peer_state_lock;
453+
454+ let local_chan = get_channel_ref ! ( nodes[ 0 ] , nodes[ 1 ] , per_peer_lock, peer_state_lock, chan. 2 ) ;
455+ let local_chan_signer = local_chan. as_funded ( ) . unwrap ( ) . get_signer ( ) ;
456+
442457 let nondust_htlcs: Vec < HTLCOutputInCommitment > = vec ! [ ] ;
443458 let commitment_tx = CommitmentTransaction :: new (
444459 INITIAL_COMMITMENT_NUMBER - 1 ,
@@ -447,13 +462,15 @@ pub fn test_update_fee_that_funder_cannot_afford() {
447462 channel_value - push_sats - commit_tx_fee_msat ( non_buffer_feerate + 4 , 0 , & channel_type_features) / 1000 ,
448463 non_buffer_feerate + 4 ,
449464 nondust_htlcs,
450- & local_chan. funding . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
465+ & local_chan. funding ( ) . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
451466 & secp_ctx,
452467 ) ;
453- local_chan_signer. as_ecdsa ( ) . unwrap ( ) . sign_counterparty_commitment (
454- & local_chan. funding . channel_transaction_parameters , & commitment_tx, Vec :: new ( ) ,
455- Vec :: new ( ) , & secp_ctx,
456- ) . unwrap ( )
468+ let params = & local_chan. funding ( ) . channel_transaction_parameters ;
469+ local_chan_signer
470+ . as_ecdsa ( )
471+ . unwrap ( )
472+ . sign_counterparty_commitment ( params, & commitment_tx, Vec :: new ( ) , Vec :: new ( ) , & secp_ctx)
473+ . unwrap ( )
457474 } ;
458475
459476 let commit_signed_msg = msgs:: CommitmentSigned {
@@ -476,11 +493,12 @@ pub fn test_update_fee_that_funder_cannot_afford() {
476493 //check to see if the funder, who sent the update_fee request, can afford the new fee (funder_balance >= fee+channel_reserve)
477494 //Should produce and error.
478495 nodes[ 1 ] . node . handle_commitment_signed ( node_a_id, & commit_signed_msg) ;
479- nodes[ 1 ] . logger . assert_log_contains ( "lightning::ln::channelmanager" , "Funding remote cannot afford proposed new fee" , 3 ) ;
496+ let err = "Funding remote cannot afford proposed new fee" ;
497+ nodes[ 1 ] . logger . assert_log_contains ( "lightning::ln::channelmanager" , err, 3 ) ;
480498 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
481499 check_closed_broadcast ! ( nodes[ 1 ] , true ) ;
482- check_closed_event ! ( nodes [ 1 ] , 1 , ClosureReason :: ProcessingError { err: String :: from ( "Funding remote cannot afford proposed new fee" ) } ,
483- [ node_a_id] , channel_value) ;
500+ let reason = ClosureReason :: ProcessingError { err : err . to_string ( ) } ;
501+ check_closed_event ! ( nodes [ 1 ] , 1 , reason , [ node_a_id] , channel_value) ;
484502}
485503
486504#[ xtest( feature = "_externalize_tests" ) ]
@@ -498,7 +516,6 @@ pub fn test_update_fee_that_saturates_subs() {
498516 let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
499517
500518 let node_a_id = nodes[ 0 ] . node . get_our_node_id ( ) ;
501- let node_b_id = nodes[ 1 ] . node . get_our_node_id ( ) ;
502519
503520 let chan_id = create_chan_between_nodes_with_value ( & nodes[ 0 ] , & nodes[ 1 ] , 10_000 , 8_500_000 ) . 3 ;
504521
@@ -515,18 +532,20 @@ pub fn test_update_fee_that_saturates_subs() {
515532 // in `commitment_signed`.
516533
517534 let remote_point = {
518- let per_peer_state = nodes[ 1 ] . node . per_peer_state . read ( ) . unwrap ( ) ;
519- let chan_lock = per_peer_state. get ( & node_a_id) . unwrap ( ) . lock ( ) . unwrap ( ) ;
520- let remote_chan = chan_lock. channel_by_id . get ( & chan_id) . and_then ( Channel :: as_funded) . unwrap ( ) ;
521- let chan_signer = remote_chan. get_signer ( ) ;
535+ let mut per_peer_lock;
536+ let mut peer_state_lock;
537+
538+ let channel = get_channel_ref ! ( nodes[ 1 ] , nodes[ 0 ] , per_peer_lock, peer_state_lock, chan_id) ;
539+ let chan_signer = channel. as_funded ( ) . unwrap ( ) . get_signer ( ) ;
522540 chan_signer. as_ref ( ) . get_per_commitment_point ( INITIAL_COMMITMENT_NUMBER , & secp_ctx) . unwrap ( )
523541 } ;
524542
525543 let res = {
526- let per_peer_state = nodes[ 0 ] . node . per_peer_state . read ( ) . unwrap ( ) ;
527- let local_chan_lock = per_peer_state. get ( & node_b_id) . unwrap ( ) . lock ( ) . unwrap ( ) ;
528- let local_chan = local_chan_lock. channel_by_id . get ( & chan_id) . and_then ( Channel :: as_funded) . unwrap ( ) ;
529- let local_chan_signer = local_chan. get_signer ( ) ;
544+ let mut per_peer_lock;
545+ let mut peer_state_lock;
546+
547+ let local_chan = get_channel_ref ! ( nodes[ 0 ] , nodes[ 1 ] , per_peer_lock, peer_state_lock, chan_id) ;
548+ let local_chan_signer = local_chan. as_funded ( ) . unwrap ( ) . get_signer ( ) ;
530549 let nondust_htlcs: Vec < HTLCOutputInCommitment > = vec ! [ ] ;
531550 let commitment_tx = CommitmentTransaction :: new (
532551 INITIAL_COMMITMENT_NUMBER ,
@@ -537,13 +556,15 @@ pub fn test_update_fee_that_saturates_subs() {
537556 0 ,
538557 FEERATE ,
539558 nondust_htlcs,
540- & local_chan. funding . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
559+ & local_chan. funding ( ) . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
541560 & secp_ctx,
542561 ) ;
543- local_chan_signer. as_ecdsa ( ) . unwrap ( ) . sign_counterparty_commitment (
544- & local_chan. funding . channel_transaction_parameters , & commitment_tx, Vec :: new ( ) ,
545- Vec :: new ( ) , & secp_ctx,
546- ) . unwrap ( )
562+ let params = & local_chan. funding ( ) . channel_transaction_parameters ;
563+ local_chan_signer
564+ . as_ecdsa ( )
565+ . unwrap ( )
566+ . sign_counterparty_commitment ( params, & commitment_tx, Vec :: new ( ) , Vec :: new ( ) , & secp_ctx)
567+ . unwrap ( )
547568 } ;
548569
549570 let commit_signed_msg = msgs:: CommitmentSigned {
@@ -563,11 +584,12 @@ pub fn test_update_fee_that_saturates_subs() {
563584 nodes[ 1 ] . node . handle_update_fee ( node_a_id, & update_fee) ;
564585
565586 nodes[ 1 ] . node . handle_commitment_signed ( node_a_id, & commit_signed_msg) ;
566- nodes[ 1 ] . logger . assert_log_contains ( "lightning::ln::channelmanager" , "Funding remote cannot afford proposed new fee" , 3 ) ;
587+ let err = "Funding remote cannot afford proposed new fee" ;
588+ nodes[ 1 ] . logger . assert_log_contains ( "lightning::ln::channelmanager" , err, 3 ) ;
567589 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
568590 check_closed_broadcast ! ( nodes[ 1 ] , true ) ;
569- check_closed_event ! ( nodes [ 1 ] , 1 , ClosureReason :: ProcessingError { err: String :: from ( "Funding remote cannot afford proposed new fee" ) } ,
570- [ node_a_id] , 10_000 ) ;
591+ let reason = ClosureReason :: ProcessingError { err : err . to_string ( ) } ;
592+ check_closed_event ! ( nodes [ 1 ] , 1 , reason , [ node_a_id] , 10_000 ) ;
571593}
572594
573595#[ xtest( feature = "_externalize_tests" ) ]
@@ -583,7 +605,7 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
583605 let chan = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
584606
585607 // balancing
586- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
608+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
587609
588610 {
589611 let mut feerate_lock = chanmon_cfgs[ 0 ] . fee_estimator . sat_per_kw . lock ( ) . unwrap ( ) ;
@@ -595,7 +617,7 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
595617 let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
596618 assert_eq ! ( events_0. len( ) , 1 ) ;
597619 let ( update_msg, commitment_signed) = match events_0[ 0 ] {
598- MessageSendEvent :: UpdateHTLCs { node_id : _ , channel_id : _ , updates : msgs:: CommitmentUpdate { update_add_htlcs : _ , update_fulfill_htlcs : _ , update_fail_htlcs : _ , update_fail_malformed_htlcs : _ , ref update_fee, ref commitment_signed } } => {
620+ MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, ref commitment_signed, .. } , .. } => {
599621 ( update_fee. as_ref ( ) , commitment_signed)
600622 } ,
601623 _ => panic ! ( "Unexpected event" ) ,
@@ -608,13 +630,10 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
608630 let ( route, our_payment_hash, our_payment_preimage, our_payment_secret) = get_route_and_payment_hash ! ( nodes[ 1 ] , nodes[ 0 ] , 800000 ) ;
609631
610632 // nothing happens since node[1] is in AwaitingRemoteRevoke
611- nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash,
612- RecipientOnionFields :: secret_only ( our_payment_secret) , PaymentId ( our_payment_hash. 0 ) ) . unwrap ( ) ;
613- {
614- let mut added_monitors = nodes[ 0 ] . chain_monitor . added_monitors . lock ( ) . unwrap ( ) ;
615- assert_eq ! ( added_monitors. len( ) , 0 ) ;
616- added_monitors. clear ( ) ;
617- }
633+ let onion = RecipientOnionFields :: secret_only ( our_payment_secret) ;
634+ let id = PaymentId ( our_payment_hash. 0 ) ;
635+ nodes[ 1 ] . node . send_payment_with_route ( route, our_payment_hash, onion, id) . unwrap ( ) ;
636+ check_added_monitors ( & nodes[ 1 ] , 0 ) ;
618637 assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
619638 assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
620639 // node[1] has nothing to do
@@ -665,13 +684,15 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
665684 _ => panic ! ( "Unexpected event" ) ,
666685 } ;
667686
668- claim_payment ( & nodes[ 1 ] , & vec ! ( & nodes[ 0 ] ) [ .. ] , our_payment_preimage) ;
687+ claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , our_payment_preimage) ;
669688
670- send_payment ( & nodes[ 1 ] , & vec ! ( & nodes[ 0 ] ) [ .. ] , 800000 ) ;
671- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 800000 ) ;
689+ send_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 800000 ) ;
690+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 800000 ) ;
672691 close_channel ( & nodes[ 0 ] , & nodes[ 1 ] , & chan. 2 , chan. 3 , true ) ;
673- check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: CounterpartyInitiatedCooperativeClosure , [ node_b_id] , 100000 ) ;
674- check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: LocallyInitiatedCooperativeClosure , [ node_a_id] , 100000 ) ;
692+ let node_a_reason = ClosureReason :: CounterpartyInitiatedCooperativeClosure ;
693+ check_closed_event ! ( nodes[ 0 ] , 1 , node_a_reason, [ node_b_id] , 100000 ) ;
694+ let node_b_reason = ClosureReason :: LocallyInitiatedCooperativeClosure ;
695+ check_closed_event ! ( nodes[ 1 ] , 1 , node_b_reason, [ node_a_id] , 100000 ) ;
675696}
676697
677698#[ xtest( feature = "_externalize_tests" ) ]
@@ -714,7 +735,7 @@ pub fn test_update_fee() {
714735 let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
715736 assert_eq ! ( events_0. len( ) , 1 ) ;
716737 let ( update_msg, commitment_signed) = match events_0[ 0 ] {
717- MessageSendEvent :: UpdateHTLCs { node_id : _ , channel_id : _ , updates : msgs:: CommitmentUpdate { update_add_htlcs : _ , update_fulfill_htlcs : _ , update_fail_htlcs : _ , update_fail_malformed_htlcs : _ , ref update_fee, ref commitment_signed } } => {
738+ MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, ref commitment_signed, .. } , .. } => {
718739 ( update_fee. as_ref ( ) , commitment_signed)
719740 } ,
720741 _ => panic ! ( "Unexpected event" ) ,
@@ -741,7 +762,7 @@ pub fn test_update_fee() {
741762 let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
742763 assert_eq ! ( events_0. len( ) , 1 ) ;
743764 let ( update_msg, commitment_signed) = match events_0[ 0 ] {
744- MessageSendEvent :: UpdateHTLCs { node_id : _ , channel_id : _ , updates : msgs:: CommitmentUpdate { update_add_htlcs : _ , update_fulfill_htlcs : _ , update_fail_htlcs : _ , update_fail_malformed_htlcs : _ , ref update_fee, ref commitment_signed } } => {
765+ MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, ref commitment_signed, .. } , .. } => {
745766 ( update_fee. as_ref ( ) , commitment_signed)
746767 } ,
747768 _ => panic ! ( "Unexpected event" ) ,
@@ -788,8 +809,10 @@ pub fn test_update_fee() {
788809 assert_eq ! ( get_feerate!( nodes[ 0 ] , nodes[ 1 ] , channel_id) , feerate + 30 ) ;
789810 assert_eq ! ( get_feerate!( nodes[ 1 ] , nodes[ 0 ] , channel_id) , feerate + 30 ) ;
790811 close_channel ( & nodes[ 0 ] , & nodes[ 1 ] , & chan. 2 , chan. 3 , true ) ;
791- check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: CounterpartyInitiatedCooperativeClosure , [ node_b_id] , 100000 ) ;
792- check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: LocallyInitiatedCooperativeClosure , [ node_a_id] , 100000 ) ;
812+ let node_a_reason = ClosureReason :: CounterpartyInitiatedCooperativeClosure ;
813+ check_closed_event ! ( nodes[ 0 ] , 1 , node_a_reason, [ node_b_id] , 100000 ) ;
814+ let node_b_reason = ClosureReason :: LocallyInitiatedCooperativeClosure ;
815+ check_closed_event ! ( nodes[ 1 ] , 1 , node_b_reason, [ node_a_id] , 100000 ) ;
793816}
794817
795818#[ xtest( feature = "_externalize_tests" ) ]
@@ -826,7 +849,7 @@ pub fn test_chan_init_feerate_unaffordability() {
826849 let msg_events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
827850 assert_eq ! ( msg_events. len( ) , 1 ) ;
828851 match msg_events[ 0 ] {
829- MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , node_id : _ } => {
852+ MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , .. } => {
830853 assert_eq ! ( msg. data, "Insufficient funding amount for initial reserve" ) ;
831854 } ,
832855 _ => panic ! ( "Unexpected event" ) ,
@@ -904,9 +927,11 @@ pub fn accept_busted_but_better_fee() {
904927 match events[ 0 ] {
905928 MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, .. } , .. } => {
906929 nodes[ 1 ] . node . handle_update_fee ( node_a_id, update_fee. as_ref ( ) . unwrap ( ) ) ;
907- check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: PeerFeerateTooLow {
908- peer_feerate_sat_per_kw: 1000 , required_feerate_sat_per_kw: 5000 ,
909- } , [ node_a_id] , 100000 ) ;
930+ let reason = ClosureReason :: PeerFeerateTooLow {
931+ peer_feerate_sat_per_kw : 1000 ,
932+ required_feerate_sat_per_kw : 5000 ,
933+ } ;
934+ check_closed_event ! ( nodes[ 1 ] , 1 , reason, [ node_a_id] , 100000 ) ;
910935 check_closed_broadcast ! ( nodes[ 1 ] , true ) ;
911936 check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
912937 } ,
0 commit comments