@@ -507,6 +507,66 @@ fn do_test_splice_state_reset_on_disconnect(reload: bool) {
507
507
lock_splice_after_blocks ( & nodes[ 0 ] , & nodes[ 1 ] , channel_id, ANTI_REORG_DELAY - 1 ) ;
508
508
}
509
509
510
+ #[ test]
511
+ fn test_config_reject_inbound_splices ( ) {
512
+ // Tests that nodes with `reject_inbound_splices` properly reject inbound splices but still
513
+ // allow outbound ones.
514
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
515
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
516
+ let mut config = test_default_channel_config ( ) ;
517
+ config. reject_inbound_splices = true ;
518
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , Some ( config) ] ) ;
519
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
520
+
521
+ let node_id_0 = nodes[ 0 ] . node . get_our_node_id ( ) ;
522
+ let node_id_1 = nodes[ 1 ] . node . get_our_node_id ( ) ;
523
+
524
+ let ( _, _, channel_id, _) =
525
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100_000 , 50_000_000 ) ;
526
+
527
+ let contribution = SpliceContribution :: SpliceOut {
528
+ outputs : vec ! [ TxOut {
529
+ value: Amount :: from_sat( 1_000 ) ,
530
+ script_pubkey: nodes[ 0 ] . wallet_source. get_change_script( ) . unwrap( ) ,
531
+ } ] ,
532
+ } ;
533
+ nodes[ 0 ]
534
+ . node
535
+ . splice_channel (
536
+ & channel_id,
537
+ & node_id_1,
538
+ contribution. clone ( ) ,
539
+ FEERATE_FLOOR_SATS_PER_KW ,
540
+ None ,
541
+ )
542
+ . unwrap ( ) ;
543
+
544
+ let stfu = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendStfu , node_id_1) ;
545
+ nodes[ 1 ] . node . handle_stfu ( node_id_0, & stfu) ;
546
+ let stfu = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendStfu , node_id_0) ;
547
+ nodes[ 0 ] . node . handle_stfu ( node_id_1, & stfu) ;
548
+
549
+ let splice_init = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendSpliceInit , node_id_1) ;
550
+ nodes[ 1 ] . node . handle_splice_init ( node_id_0, & splice_init) ;
551
+
552
+ let msg_events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
553
+ assert_eq ! ( msg_events. len( ) , 1 ) ;
554
+ if let MessageSendEvent :: HandleError { action, .. } = & msg_events[ 0 ] {
555
+ assert ! ( matches!( action, msgs:: ErrorAction :: DisconnectPeerWithWarning { .. } ) ) ;
556
+ } else {
557
+ panic ! ( "Expected MessageSendEvent::HandleError" ) ;
558
+ }
559
+
560
+ nodes[ 0 ] . node . peer_disconnected ( node_id_1) ;
561
+ nodes[ 1 ] . node . peer_disconnected ( node_id_0) ;
562
+ let mut reconnect_args = ReconnectArgs :: new ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
563
+ reconnect_args. send_channel_ready = ( true , true ) ;
564
+ reconnect_args. send_announcement_sigs = ( true , true ) ;
565
+ reconnect_nodes ( reconnect_args) ;
566
+
567
+ let _ = splice_channel ( & nodes[ 1 ] , & nodes[ 0 ] , channel_id, contribution) ;
568
+ }
569
+
510
570
#[ test]
511
571
fn test_splice_in ( ) {
512
572
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments