@@ -167,7 +167,7 @@ pub(super) fn id_to_feature_flags(id: u8) -> Vec<u8> {
167
167
}
168
168
}
169
169
170
- pub ( super ) fn build_line_graph ( ) -> (
170
+ pub ( super ) fn build_line_graph ( node_features : NodeFeatures ) -> (
171
171
Secp256k1 < All > , sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > ,
172
172
P2PGossipSync < sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > , sync:: Arc < test_utils:: TestChainSource > , sync:: Arc < test_utils:: TestLogger > > ,
173
173
sync:: Arc < test_utils:: TestChainSource > , sync:: Arc < test_utils:: TestLogger > ,
@@ -213,7 +213,7 @@ pub(super) fn build_line_graph() -> (
213
213
excess_data : Vec :: new ( )
214
214
} ) ;
215
215
add_or_update_node ( & gossip_sync, & secp_ctx, & next_privkey,
216
- NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 1 ) ) , 0 ) ;
216
+ node_features . clone ( ) , 0 ) ;
217
217
}
218
218
219
219
( secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
@@ -225,6 +225,26 @@ pub(super) fn build_graph() -> (
225
225
P2PGossipSync < sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > , sync:: Arc < test_utils:: TestChainSource > , sync:: Arc < test_utils:: TestLogger > > ,
226
226
sync:: Arc < test_utils:: TestChainSource > ,
227
227
sync:: Arc < test_utils:: TestLogger > ,
228
+ ) {
229
+ build_graph_inner ( None )
230
+ }
231
+
232
+ pub ( super ) fn build_graph_with_features ( features : NodeFeatures ) -> (
233
+ Secp256k1 < All > ,
234
+ sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > ,
235
+ P2PGossipSync < sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > , sync:: Arc < test_utils:: TestChainSource > , sync:: Arc < test_utils:: TestLogger > > ,
236
+ sync:: Arc < test_utils:: TestChainSource > ,
237
+ sync:: Arc < test_utils:: TestLogger > ,
238
+ ) {
239
+ build_graph_inner ( Some ( features) )
240
+ }
241
+
242
+ fn build_graph_inner ( features : Option < NodeFeatures > ) -> (
243
+ Secp256k1 < All > ,
244
+ sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > ,
245
+ P2PGossipSync < sync:: Arc < NetworkGraph < Arc < test_utils:: TestLogger > > > , sync:: Arc < test_utils:: TestChainSource > , sync:: Arc < test_utils:: TestLogger > > ,
246
+ sync:: Arc < test_utils:: TestChainSource > ,
247
+ sync:: Arc < test_utils:: TestLogger > ,
228
248
) {
229
249
let secp_ctx = Secp256k1 :: new ( ) ;
230
250
let logger = Arc :: new ( test_utils:: TestLogger :: new ( ) ) ;
@@ -307,7 +327,7 @@ pub(super) fn build_graph() -> (
307
327
excess_data : Vec :: new ( )
308
328
} ) ;
309
329
310
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 0 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 1 ) ) , 0 ) ;
330
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 0 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 1 ) ) ) , 0 ) ;
311
331
312
332
add_channel ( & gossip_sync, & secp_ctx, & our_privkey, & privkeys[ 1 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 2 ) ) , 2 ) ;
313
333
update_channel ( & gossip_sync, & secp_ctx, & our_privkey, UnsignedChannelUpdate {
@@ -335,7 +355,7 @@ pub(super) fn build_graph() -> (
335
355
excess_data : Vec :: new ( )
336
356
} ) ;
337
357
338
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 2 ) ) , 0 ) ;
358
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 2 ) ) ) , 0 ) ;
339
359
340
360
add_channel ( & gossip_sync, & secp_ctx, & our_privkey, & privkeys[ 7 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 12 ) ) , 12 ) ;
341
361
update_channel ( & gossip_sync, & secp_ctx, & our_privkey, UnsignedChannelUpdate {
@@ -363,7 +383,7 @@ pub(super) fn build_graph() -> (
363
383
excess_data : Vec :: new ( )
364
384
} ) ;
365
385
366
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 8 ) ) , 0 ) ;
386
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 8 ) ) ) , 0 ) ;
367
387
368
388
add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 0 ] , & privkeys[ 2 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 3 ) ) , 3 ) ;
369
389
update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 0 ] , UnsignedChannelUpdate {
@@ -443,7 +463,7 @@ pub(super) fn build_graph() -> (
443
463
excess_data : Vec :: new ( )
444
464
} ) ;
445
465
446
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 3 ) ) , 0 ) ;
466
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 3 ) ) ) , 0 ) ;
447
467
448
468
add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , & privkeys[ 4 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 6 ) ) , 6 ) ;
449
469
update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , UnsignedChannelUpdate {
@@ -497,9 +517,9 @@ pub(super) fn build_graph() -> (
497
517
excess_data : Vec :: new ( )
498
518
} ) ;
499
519
500
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 4 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 5 ) ) , 0 ) ;
520
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 4 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 5 ) ) ) , 0 ) ;
501
521
502
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 3 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 4 ) ) , 0 ) ;
522
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 3 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 4 ) ) ) , 0 ) ;
503
523
504
524
add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , & privkeys[ 5 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 7 ) ) , 7 ) ;
505
525
update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , UnsignedChannelUpdate {
@@ -527,7 +547,7 @@ pub(super) fn build_graph() -> (
527
547
excess_data : Vec :: new ( )
528
548
} ) ;
529
549
530
- add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 5 ] , NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 6 ) ) , 0 ) ;
550
+ add_or_update_node ( & gossip_sync, & secp_ctx, & privkeys[ 5 ] , features . clone ( ) . unwrap_or_else ( || NodeFeatures :: from_le_bytes ( id_to_feature_flags ( 6 ) ) ) , 0 ) ;
531
551
532
552
( secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
533
553
}
0 commit comments