@@ -431,7 +431,7 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
431431}
432432
433433#[ inline]
434- pub fn do_test < Out : Output > ( data : & [ u8 ] , underlying_out : Out ) {
434+ pub fn do_test < Out : Output > ( data : & [ u8 ] , underlying_out : Out , anchors : bool ) {
435435 let out = SearchingOutput :: new ( underlying_out) ;
436436 let broadcast = Arc :: new ( TestBroadcaster { } ) ;
437437 let router = FuzzRouter { } ;
@@ -449,6 +449,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
449449 let mut config = UserConfig :: default ( ) ;
450450 config. channel_config. forwarding_fee_proportional_millionths = 0 ;
451451 config. channel_handshake_config. announced_channel = true ;
452+ if anchors {
453+ config. channel_handshake_config. negotiate_anchors_zero_fee_htlc_tx = true ;
454+ config. manually_accept_inbound_channels = true ;
455+ }
452456 let network = Network :: Bitcoin ;
453457 let best_block_timestamp = genesis_block( network) . header. time;
454458 let params = ChainParameters {
@@ -472,6 +476,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
472476 let mut config = UserConfig :: default ( ) ;
473477 config. channel_config. forwarding_fee_proportional_millionths = 0 ;
474478 config. channel_handshake_config. announced_channel = true ;
479+ if anchors {
480+ config. channel_handshake_config. negotiate_anchors_zero_fee_htlc_tx = true ;
481+ config. manually_accept_inbound_channels = true ;
482+ }
475483
476484 let mut monitors = HashMap :: new( ) ;
477485 let mut old_monitors = $old_monitors. latest_monitors. lock( ) . unwrap( ) ;
@@ -508,7 +516,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
508516
509517 let mut channel_txn = Vec :: new ( ) ;
510518 macro_rules! make_channel {
511- ( $source: expr, $dest: expr, $chan_id: expr) => { {
519+ ( $source: expr, $dest: expr, $dest_keys_manager : expr , $ chan_id: expr) => { {
512520 $source. peer_connected( & $dest. get_our_node_id( ) , & Init {
513521 features: $dest. init_features( ) , networks: None , remote_network_address: None
514522 } , true ) . unwrap( ) ;
@@ -527,6 +535,22 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
527535
528536 $dest. handle_open_channel( & $source. get_our_node_id( ) , & open_channel) ;
529537 let accept_channel = {
538+ if anchors {
539+ let events = $dest. get_and_clear_pending_events( ) ;
540+ assert_eq!( events. len( ) , 1 ) ;
541+ if let events:: Event :: OpenChannelRequest {
542+ ref temporary_channel_id, ref counterparty_node_id, ..
543+ } = events[ 0 ] {
544+ let mut random_bytes = [ 0u8 ; 16 ] ;
545+ random_bytes. copy_from_slice( & $dest_keys_manager. get_secure_random_bytes( ) [ ..16 ] ) ;
546+ let user_channel_id = u128 :: from_be_bytes( random_bytes) ;
547+ $dest. accept_inbound_channel(
548+ temporary_channel_id,
549+ counterparty_node_id,
550+ user_channel_id,
551+ ) . unwrap( ) ;
552+ } else { panic!( "Wrong event type" ) ; }
553+ }
530554 let events = $dest. get_and_clear_pending_msg_events( ) ;
531555 assert_eq!( events. len( ) , 1 ) ;
532556 if let events:: MessageSendEvent :: SendAcceptChannel { ref msg, .. } = events[ 0 ] {
@@ -638,8 +662,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
638662
639663 let mut nodes = [ node_a, node_b, node_c] ;
640664
641- let chan_1_funding = make_channel ! ( nodes[ 0 ] , nodes[ 1 ] , 0 ) ;
642- let chan_2_funding = make_channel ! ( nodes[ 1 ] , nodes[ 2 ] , 1 ) ;
665+ let chan_1_funding = make_channel ! ( nodes[ 0 ] , nodes[ 1 ] , keys_manager_b , 0 ) ;
666+ let chan_2_funding = make_channel ! ( nodes[ 1 ] , nodes[ 2 ] , keys_manager_c , 1 ) ;
643667
644668 for node in nodes. iter ( ) {
645669 confirm_txn ! ( node) ;
@@ -1337,10 +1361,12 @@ impl<O: Output> SearchingOutput<O> {
13371361}
13381362
13391363pub fn chanmon_consistency_test < Out : Output > ( data : & [ u8 ] , out : Out ) {
1340- do_test ( data, out) ;
1364+ do_test ( data, out. clone ( ) , false ) ;
1365+ do_test ( data, out, true ) ;
13411366}
13421367
13431368#[ no_mangle]
13441369pub extern "C" fn chanmon_consistency_run ( data : * const u8 , datalen : usize ) {
1345- do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
1370+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } , false ) ;
1371+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } , true ) ;
13461372}
0 commit comments