@@ -415,13 +415,17 @@ fn test_upfront_shutdown_script() {
415
415
let flags = InitFeatures :: known ( ) ;
416
416
let chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 2 , 1000000 , 1000000 , flags. clone ( ) , flags. clone ( ) ) ;
417
417
nodes[ 0 ] . node . close_channel ( & OutPoint { txid : chan. 3 . txid ( ) , index : 0 } . to_channel_id ( ) ) . unwrap ( ) ;
418
- let mut node_0_shutdown = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendShutdown , nodes[ 2 ] . node. get_our_node_id( ) ) ;
418
+ let node_0_orig_shutdown = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendShutdown , nodes[ 2 ] . node. get_our_node_id( ) ) ;
419
+ let mut node_0_shutdown = node_0_orig_shutdown. clone ( ) ;
419
420
node_0_shutdown. scriptpubkey = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_RETURN ) . into_script ( ) . to_p2sh ( ) ;
420
- // Test we enforce upfront_scriptpbukey if by providing a diffrent one at closing that we disconnect peer
421
+ // Test we enforce upfront_scriptpbukey if by providing a different one at closing that we warn
422
+ // the peer and ignore the message.
421
423
nodes[ 2 ] . node . handle_shutdown ( & nodes[ 0 ] . node . get_our_node_id ( ) , & InitFeatures :: known ( ) , & node_0_shutdown) ;
422
- assert ! ( regex:: Regex :: new( r"Got shutdown request with a scriptpubkey \([A-Fa-f0-9]+\) which did not match their previous scriptpubkey." ) . unwrap( ) . is_match( check_closed_broadcast!( nodes[ 2 ] , true ) . unwrap( ) . data. as_str( ) ) ) ;
423
- check_closed_event ! ( nodes[ 2 ] , 1 , ClosureReason :: ProcessingError { err: "Got shutdown request with a scriptpubkey (a91441c98a140039816273e50db317422c11c2bfcc8887) which did not match their previous scriptpubkey." . to_string( ) } ) ;
424
- check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
424
+ assert ! ( regex:: Regex :: new( r"Got shutdown request with a scriptpubkey \([A-Fa-f0-9]+\) which did not match their previous scriptpubkey." )
425
+ . unwrap( ) . is_match( & check_warn_msg!( nodes[ 2 ] , nodes[ 0 ] . node. get_our_node_id( ) , chan. 2 ) ) ) ;
426
+ // This allows nodes[2] to retry the shutdown message, which should get a response:
427
+ nodes[ 2 ] . node . handle_shutdown ( & nodes[ 0 ] . node . get_our_node_id ( ) , & InitFeatures :: known ( ) , & node_0_orig_shutdown) ;
428
+ get_event_msg ! ( nodes[ 2 ] , MessageSendEvent :: SendShutdown , nodes[ 0 ] . node. get_our_node_id( ) ) ;
425
429
426
430
// We test that in case of peer committing upfront to a script, if it doesn't change at closing, we sign
427
431
let chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 2 , 1000000 , 1000000 , flags. clone ( ) , flags. clone ( ) ) ;
@@ -668,17 +672,8 @@ fn test_unsupported_anysegwit_shutdown_script() {
668
672
node_0_shutdown. scriptpubkey = unsupported_shutdown_script. into_inner ( ) ;
669
673
nodes[ 0 ] . node . handle_shutdown ( & nodes[ 1 ] . node . get_our_node_id ( ) , & node_cfgs[ 1 ] . features , & node_0_shutdown) ;
670
674
671
- let events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
672
- assert_eq ! ( events. len( ) , 2 ) ;
673
- match events[ 1 ] {
674
- MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , node_id } => {
675
- assert_eq ! ( node_id, nodes[ 1 ] . node. get_our_node_id( ) ) ;
676
- assert_eq ! ( msg. data, "Got a nonstandard scriptpubkey (60020028) from remote peer" . to_owned( ) ) ;
677
- } ,
678
- _ => panic ! ( "Unexpected event" ) ,
679
- }
680
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
681
- check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: ProcessingError { err: "Got a nonstandard scriptpubkey (60020028) from remote peer" . to_string( ) } ) ;
675
+ assert_eq ! ( & check_warn_msg!( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) , chan. 2 ) ,
676
+ "Got a nonstandard scriptpubkey (60020028) from remote peer" ) ;
682
677
}
683
678
684
679
#[ test]
@@ -704,17 +699,8 @@ fn test_invalid_shutdown_script() {
704
699
. into_script ( ) ;
705
700
nodes[ 0 ] . node . handle_shutdown ( & nodes[ 1 ] . node . get_our_node_id ( ) , & InitFeatures :: known ( ) , & node_0_shutdown) ;
706
701
707
- let events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
708
- assert_eq ! ( events. len( ) , 2 ) ;
709
- match events[ 1 ] {
710
- MessageSendEvent :: HandleError { action : ErrorAction :: SendErrorMessage { ref msg } , node_id } => {
711
- assert_eq ! ( node_id, nodes[ 1 ] . node. get_our_node_id( ) ) ;
712
- assert_eq ! ( msg. data, "Got a nonstandard scriptpubkey (00020000) from remote peer" . to_owned( ) )
713
- } ,
714
- _ => panic ! ( "Unexpected event" ) ,
715
- }
716
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
717
- check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: ProcessingError { err: "Got a nonstandard scriptpubkey (00020000) from remote peer" . to_string( ) } ) ;
702
+ assert_eq ! ( & check_warn_msg!( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) , chan. 2 ) ,
703
+ "Got a nonstandard scriptpubkey (00020000) from remote peer" ) ;
718
704
}
719
705
720
706
#[ derive( PartialEq ) ]
@@ -762,10 +748,8 @@ fn do_test_closing_signed_reinit_timeout(timeout_step: TimeoutStep) {
762
748
763
749
if timeout_step != TimeoutStep :: AfterShutdown {
764
750
nodes[ 1 ] . node . handle_closing_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & node_0_closing_signed) ;
765
- // At this point nodes[1] should send back a warning message indicating it disagrees with the
766
- // given channel-closing fee. Currently we do not implement warning messages so instead we
767
- // remain silent here.
768
- assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
751
+ assert ! ( check_warn_msg!( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) , chan_id)
752
+ . starts_with( "Unable to come to consensus about closing feerate" ) ) ;
769
753
770
754
// Now deliver a mutated closing_signed indicating a higher acceptable fee range, which
771
755
// nodes[1] should happily accept and respond to.
0 commit comments