@@ -432,7 +432,7 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
432
432
}
433
433
434
434
#[ inline]
435
- pub fn do_test < Out : Output > ( data : & [ u8 ] , underlying_out : Out ) {
435
+ pub fn do_test < Out : Output > ( data : & [ u8 ] , underlying_out : Out , anchors : bool ) {
436
436
let out = SearchingOutput :: new ( underlying_out) ;
437
437
let broadcast = Arc :: new ( TestBroadcaster { } ) ;
438
438
let router = FuzzRouter { } ;
@@ -450,6 +450,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
450
450
let mut config = UserConfig :: default ( ) ;
451
451
config. channel_config. forwarding_fee_proportional_millionths = 0 ;
452
452
config. channel_handshake_config. announced_channel = true ;
453
+ if anchors {
454
+ config. channel_handshake_config. negotiate_anchors_zero_fee_htlc_tx = true ;
455
+ config. manually_accept_inbound_channels = true ;
456
+ }
453
457
let network = Network :: Bitcoin ;
454
458
let best_block_timestamp = genesis_block( network) . header. time;
455
459
let params = ChainParameters {
@@ -473,6 +477,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
473
477
let mut config = UserConfig :: default ( ) ;
474
478
config. channel_config. forwarding_fee_proportional_millionths = 0 ;
475
479
config. channel_handshake_config. announced_channel = true ;
480
+ if anchors {
481
+ config. channel_handshake_config. negotiate_anchors_zero_fee_htlc_tx = true ;
482
+ config. manually_accept_inbound_channels = true ;
483
+ }
476
484
477
485
let mut monitors = HashMap :: new( ) ;
478
486
let mut old_monitors = $old_monitors. latest_monitors. lock( ) . unwrap( ) ;
@@ -509,7 +517,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
509
517
510
518
let mut channel_txn = Vec :: new ( ) ;
511
519
macro_rules! make_channel {
512
- ( $source: expr, $dest: expr, $chan_id: expr) => { {
520
+ ( $source: expr, $dest: expr, $dest_keys_manager : expr , $ chan_id: expr) => { {
513
521
$source. peer_connected( & $dest. get_our_node_id( ) , & Init {
514
522
features: $dest. init_features( ) , networks: None , remote_network_address: None
515
523
} , true ) . unwrap( ) ;
@@ -528,6 +536,22 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
528
536
529
537
$dest. handle_open_channel( & $source. get_our_node_id( ) , & open_channel) ;
530
538
let accept_channel = {
539
+ if anchors {
540
+ let events = $dest. get_and_clear_pending_events( ) ;
541
+ assert_eq!( events. len( ) , 1 ) ;
542
+ if let events:: Event :: OpenChannelRequest {
543
+ ref temporary_channel_id, ref counterparty_node_id, ..
544
+ } = events[ 0 ] {
545
+ let mut random_bytes = [ 0u8 ; 16 ] ;
546
+ random_bytes. copy_from_slice( & $dest_keys_manager. get_secure_random_bytes( ) [ ..16 ] ) ;
547
+ let user_channel_id = u128 :: from_be_bytes( random_bytes) ;
548
+ $dest. accept_inbound_channel(
549
+ temporary_channel_id,
550
+ counterparty_node_id,
551
+ user_channel_id,
552
+ ) . unwrap( ) ;
553
+ } else { panic!( "Wrong event type" ) ; }
554
+ }
531
555
let events = $dest. get_and_clear_pending_msg_events( ) ;
532
556
assert_eq!( events. len( ) , 1 ) ;
533
557
if let events:: MessageSendEvent :: SendAcceptChannel { ref msg, .. } = events[ 0 ] {
@@ -639,8 +663,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
639
663
640
664
let mut nodes = [ node_a, node_b, node_c] ;
641
665
642
- let chan_1_funding = make_channel ! ( nodes[ 0 ] , nodes[ 1 ] , 0 ) ;
643
- let chan_2_funding = make_channel ! ( nodes[ 1 ] , nodes[ 2 ] , 1 ) ;
666
+ let chan_1_funding = make_channel ! ( nodes[ 0 ] , nodes[ 1 ] , keys_manager_b , 0 ) ;
667
+ let chan_2_funding = make_channel ! ( nodes[ 1 ] , nodes[ 2 ] , keys_manager_c , 1 ) ;
644
668
645
669
for node in nodes. iter ( ) {
646
670
confirm_txn ! ( node) ;
@@ -1338,10 +1362,12 @@ impl<O: Output> SearchingOutput<O> {
1338
1362
}
1339
1363
1340
1364
pub fn chanmon_consistency_test < Out : Output > ( data : & [ u8 ] , out : Out ) {
1341
- do_test ( data, out) ;
1365
+ do_test ( data, out. clone ( ) , false ) ;
1366
+ do_test ( data, out, true ) ;
1342
1367
}
1343
1368
1344
1369
#[ no_mangle]
1345
1370
pub extern "C" fn chanmon_consistency_run ( data : * const u8 , datalen : usize ) {
1346
- do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
1371
+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } , false ) ;
1372
+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } , true ) ;
1347
1373
}
0 commit comments