1
1
//! Functional tests testing channel feerate handling.
2
2
3
3
use 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
+ } ;
7
12
use crate :: ln:: channelmanager:: PaymentId ;
13
+ use crate :: ln:: functional_test_utils:: * ;
14
+ use crate :: ln:: msgs:: {
15
+ self , BaseMessageHandler , ChannelMessageHandler , ErrorAction , MessageSendEvent ,
16
+ } ;
8
17
use crate :: ln:: outbound_payment:: RecipientOnionFields ;
9
- use crate :: ln:: msgs:: { self , BaseMessageHandler , ErrorAction , ChannelMessageHandler , MessageSendEvent } ;
10
18
use crate :: sign:: ecdsa:: EcdsaChannelSigner ;
11
19
use crate :: util:: config:: UserConfig ;
12
20
use crate :: util:: errors:: APIError ;
@@ -29,7 +37,7 @@ pub fn test_async_inbound_update_fee() {
29
37
create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
30
38
31
39
// balancing
32
- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
40
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
33
41
34
42
// A B
35
43
// update_fee ->
@@ -69,8 +77,9 @@ pub fn test_async_inbound_update_fee() {
69
77
70
78
// ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
71
79
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 ( ) ;
74
83
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
75
84
76
85
let payment_event = {
@@ -150,7 +159,7 @@ pub fn test_update_fee_unordered_raa() {
150
159
create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
151
160
152
161
// balancing
153
- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
162
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
154
163
155
164
// First nodes[0] generates an update_fee
156
165
{
@@ -173,8 +182,9 @@ pub fn test_update_fee_unordered_raa() {
173
182
174
183
// ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
175
184
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 ( ) ;
178
188
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
179
189
180
190
let payment_event = {
@@ -317,7 +327,6 @@ pub fn test_multi_flight_update_fee() {
317
327
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
318
328
}
319
329
320
-
321
330
#[ xtest( feature = "_externalize_tests" ) ]
322
331
pub fn test_update_fee_vanilla ( ) {
323
332
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -340,7 +349,7 @@ pub fn test_update_fee_vanilla() {
340
349
let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
341
350
assert_eq ! ( events_0. len( ) , 1 ) ;
342
351
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, .. } , .. } => {
344
353
( update_fee. as_ref ( ) , commitment_signed)
345
354
} ,
346
355
_ => panic ! ( "Unexpected event" ) ,
@@ -381,7 +390,8 @@ pub fn test_update_fee_that_funder_cannot_afford() {
381
390
let channel_id = chan. 2 ;
382
391
let secp_ctx = Secp256k1 :: new ( ) ;
383
392
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) ;
385
395
386
396
let channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
387
397
@@ -421,24 +431,29 @@ pub fn test_update_fee_that_funder_cannot_afford() {
421
431
* feerate_lock += 4 ;
422
432
}
423
433
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 ) ;
425
436
check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
426
437
427
438
const INITIAL_COMMITMENT_NUMBER : u64 = 281474976710654 ;
428
439
429
440
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 ( )
435
448
} ;
436
449
437
450
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
+
442
457
let nondust_htlcs: Vec < HTLCOutputInCommitment > = vec ! [ ] ;
443
458
let commitment_tx = CommitmentTransaction :: new (
444
459
INITIAL_COMMITMENT_NUMBER - 1 ,
@@ -447,13 +462,15 @@ pub fn test_update_fee_that_funder_cannot_afford() {
447
462
channel_value - push_sats - commit_tx_fee_msat ( non_buffer_feerate + 4 , 0 , & channel_type_features) / 1000 ,
448
463
non_buffer_feerate + 4 ,
449
464
nondust_htlcs,
450
- & local_chan. funding . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
465
+ & local_chan. funding ( ) . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
451
466
& secp_ctx,
452
467
) ;
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 ( )
457
474
} ;
458
475
459
476
let commit_signed_msg = msgs:: CommitmentSigned {
@@ -476,11 +493,12 @@ pub fn test_update_fee_that_funder_cannot_afford() {
476
493
//check to see if the funder, who sent the update_fee request, can afford the new fee (funder_balance >= fee+channel_reserve)
477
494
//Should produce and error.
478
495
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 ) ;
480
498
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
481
499
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) ;
484
502
}
485
503
486
504
#[ xtest( feature = "_externalize_tests" ) ]
@@ -498,7 +516,6 @@ pub fn test_update_fee_that_saturates_subs() {
498
516
let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
499
517
500
518
let node_a_id = nodes[ 0 ] . node . get_our_node_id ( ) ;
501
- let node_b_id = nodes[ 1 ] . node . get_our_node_id ( ) ;
502
519
503
520
let chan_id = create_chan_between_nodes_with_value ( & nodes[ 0 ] , & nodes[ 1 ] , 10_000 , 8_500_000 ) . 3 ;
504
521
@@ -515,18 +532,20 @@ pub fn test_update_fee_that_saturates_subs() {
515
532
// in `commitment_signed`.
516
533
517
534
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 ( ) ;
522
540
chan_signer. as_ref ( ) . get_per_commitment_point ( INITIAL_COMMITMENT_NUMBER , & secp_ctx) . unwrap ( )
523
541
} ;
524
542
525
543
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 ( ) ;
530
549
let nondust_htlcs: Vec < HTLCOutputInCommitment > = vec ! [ ] ;
531
550
let commitment_tx = CommitmentTransaction :: new (
532
551
INITIAL_COMMITMENT_NUMBER ,
@@ -537,13 +556,15 @@ pub fn test_update_fee_that_saturates_subs() {
537
556
0 ,
538
557
FEERATE ,
539
558
nondust_htlcs,
540
- & local_chan. funding . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
559
+ & local_chan. funding ( ) . channel_transaction_parameters . as_counterparty_broadcastable ( ) ,
541
560
& secp_ctx,
542
561
) ;
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 ( )
547
568
} ;
548
569
549
570
let commit_signed_msg = msgs:: CommitmentSigned {
@@ -563,11 +584,12 @@ pub fn test_update_fee_that_saturates_subs() {
563
584
nodes[ 1 ] . node . handle_update_fee ( node_a_id, & update_fee) ;
564
585
565
586
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 ) ;
567
589
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
568
590
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 ) ;
571
593
}
572
594
573
595
#[ xtest( feature = "_externalize_tests" ) ]
@@ -583,7 +605,7 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
583
605
let chan = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
584
606
585
607
// balancing
586
- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 8000000 ) ;
608
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 8000000 ) ;
587
609
588
610
{
589
611
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() {
595
617
let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
596
618
assert_eq ! ( events_0. len( ) , 1 ) ;
597
619
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, .. } , .. } => {
599
621
( update_fee. as_ref ( ) , commitment_signed)
600
622
} ,
601
623
_ => panic ! ( "Unexpected event" ) ,
@@ -608,13 +630,10 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
608
630
let ( route, our_payment_hash, our_payment_preimage, our_payment_secret) = get_route_and_payment_hash ! ( nodes[ 1 ] , nodes[ 0 ] , 800000 ) ;
609
631
610
632
// 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 ) ;
618
637
assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
619
638
assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
620
639
// node[1] has nothing to do
@@ -665,13 +684,15 @@ pub fn test_update_fee_with_fundee_update_add_htlc() {
665
684
_ => panic ! ( "Unexpected event" ) ,
666
685
} ;
667
686
668
- claim_payment ( & nodes[ 1 ] , & vec ! ( & nodes[ 0 ] ) [ .. ] , our_payment_preimage) ;
687
+ claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , our_payment_preimage) ;
669
688
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 ) ;
672
691
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 ) ;
675
696
}
676
697
677
698
#[ xtest( feature = "_externalize_tests" ) ]
@@ -714,7 +735,7 @@ pub fn test_update_fee() {
714
735
let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
715
736
assert_eq ! ( events_0. len( ) , 1 ) ;
716
737
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, .. } , .. } => {
718
739
( update_fee. as_ref ( ) , commitment_signed)
719
740
} ,
720
741
_ => panic ! ( "Unexpected event" ) ,
@@ -741,7 +762,7 @@ pub fn test_update_fee() {
741
762
let events_0 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
742
763
assert_eq ! ( events_0. len( ) , 1 ) ;
743
764
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, .. } , .. } => {
745
766
( update_fee. as_ref ( ) , commitment_signed)
746
767
} ,
747
768
_ => panic ! ( "Unexpected event" ) ,
@@ -788,8 +809,10 @@ pub fn test_update_fee() {
788
809
assert_eq ! ( get_feerate!( nodes[ 0 ] , nodes[ 1 ] , channel_id) , feerate + 30 ) ;
789
810
assert_eq ! ( get_feerate!( nodes[ 1 ] , nodes[ 0 ] , channel_id) , feerate + 30 ) ;
790
811
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 ) ;
793
816
}
794
817
795
818
#[ xtest( feature = "_externalize_tests" ) ]
@@ -826,7 +849,7 @@ pub fn test_chan_init_feerate_unaffordability() {
826
849
let msg_events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
827
850
assert_eq ! ( msg_events. len( ) , 1 ) ;
828
851
match msg_events[ 0 ] {
829
- MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , node_id : _ } => {
852
+ MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , .. } => {
830
853
assert_eq ! ( msg. data, "Insufficient funding amount for initial reserve" ) ;
831
854
} ,
832
855
_ => panic ! ( "Unexpected event" ) ,
@@ -904,9 +927,11 @@ pub fn accept_busted_but_better_fee() {
904
927
match events[ 0 ] {
905
928
MessageSendEvent :: UpdateHTLCs { updates : msgs:: CommitmentUpdate { ref update_fee, .. } , .. } => {
906
929
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 ) ;
910
935
check_closed_broadcast ! ( nodes[ 1 ] , true ) ;
911
936
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
912
937
} ,
0 commit comments