@@ -9053,7 +9053,7 @@ mod tests {
90539053 let random_seed_bytes = [ 42 ; 32 ] ;
90549054
90559055 // Enable channel 1
9056- update_channel ( & gossip_sync , & secp_ctx , & our_privkey , UnsignedChannelUpdate {
9056+ let update_1 = UnsignedChannelUpdate {
90579057 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
90589058 short_channel_id : 1 ,
90599059 timestamp : 2 ,
@@ -9064,11 +9064,12 @@ mod tests {
90649064 htlc_maximum_msat : 10_000_000 ,
90659065 fee_base_msat : 0 ,
90669066 fee_proportional_millionths : 0 ,
9067- excess_data : Vec :: new ( )
9068- } ) ;
9067+ excess_data : Vec :: new ( ) ,
9068+ } ;
9069+ update_channel ( & gossip_sync, & secp_ctx, & our_privkey, update_1) ;
90699070
90709071 // Set the fee on channel 3 to 1 sat, max HTLC to 1M msat
9071- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 0 ] , UnsignedChannelUpdate {
9072+ let update_3 = UnsignedChannelUpdate {
90729073 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
90739074 short_channel_id : 3 ,
90749075 timestamp : 2 ,
@@ -9079,11 +9080,12 @@ mod tests {
90799080 htlc_maximum_msat : 1_000_000 ,
90809081 fee_base_msat : 1_000 ,
90819082 fee_proportional_millionths : 0 ,
9082- excess_data : Vec :: new ( )
9083- } ) ;
9083+ excess_data : Vec :: new ( ) ,
9084+ } ;
9085+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 0 ] , update_3) ;
90849086
90859087 // Set the fee on channel 13 to 1 sat, max HTLC to 1M msat
9086- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 7 ] , UnsignedChannelUpdate {
9088+ let update_13 = UnsignedChannelUpdate {
90879089 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
90889090 short_channel_id : 13 ,
90899091 timestamp : 2 ,
@@ -9094,11 +9096,12 @@ mod tests {
90949096 htlc_maximum_msat : 1_000_000 ,
90959097 fee_base_msat : 1_000 ,
90969098 fee_proportional_millionths : 0 ,
9097- excess_data : Vec :: new ( )
9098- } ) ;
9099+ excess_data : Vec :: new ( ) ,
9100+ } ;
9101+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , update_13) ;
90999102
91009103 // Set the fee on channel 4 to 1 sat, max HTLC to 1M msat
9101- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 1 ] , UnsignedChannelUpdate {
9104+ let update_4 = UnsignedChannelUpdate {
91029105 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
91039106 short_channel_id : 4 ,
91049107 timestamp : 2 ,
@@ -9109,8 +9112,9 @@ mod tests {
91099112 htlc_maximum_msat : 1_000_000 ,
91109113 fee_base_msat : 1_000 ,
91119114 fee_proportional_millionths : 0 ,
9112- excess_data : Vec :: new ( )
9113- } ) ;
9115+ excess_data : Vec :: new ( ) ,
9116+ } ;
9117+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , update_4) ;
91149118
91159119 // The router will attempt to gather 3x the requested amount, and if it finds the new path
91169120 // through channel 16, added below, it'll always prefer that, even prior to the changes
@@ -9120,10 +9124,11 @@ mod tests {
91209124 for i in 0 ..6 {
91219125 // Finally, create a single channel with fee of 2 sat from node 1 to node 2 which allows
91229126 // for a larger payment.
9123- add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , & privkeys[ 2 ] , ChannelFeatures :: from_le_bytes ( vec ! [ ] ) , i + 42 ) ;
9127+ let chan_features = ChannelFeatures :: from_le_bytes ( vec ! [ ] ) ;
9128+ add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , & privkeys[ 2 ] , chan_features, i + 42 ) ;
91249129
91259130 // Set the fee on channel 16 to 2 sats, max HTLC to 3M msat
9126- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 7 ] , UnsignedChannelUpdate {
9131+ let update_a = UnsignedChannelUpdate {
91279132 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
91289133 short_channel_id : i + 42 ,
91299134 timestamp : 2 ,
@@ -9134,11 +9139,12 @@ mod tests {
91349139 htlc_maximum_msat : 1_000_000 ,
91359140 fee_base_msat : 1_000 ,
91369141 fee_proportional_millionths : 0 ,
9137- excess_data : Vec :: new ( )
9138- } ) ;
9142+ excess_data : Vec :: new ( ) ,
9143+ } ;
9144+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 7 ] , update_a) ;
91399145
91409146 // Enable channel 16 by providing an update in both directions
9141- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 2 ] , UnsignedChannelUpdate {
9147+ let update_b = UnsignedChannelUpdate {
91429148 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
91439149 short_channel_id : i + 42 ,
91449150 timestamp : 2 ,
@@ -9149,8 +9155,9 @@ mod tests {
91499155 htlc_maximum_msat : 10_000_000 ,
91509156 fee_base_msat : u32:: MAX ,
91519157 fee_proportional_millionths : 0 ,
9152- excess_data : Vec :: new ( )
9153- } ) ;
9158+ excess_data : Vec :: new ( ) ,
9159+ } ;
9160+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , update_b) ;
91549161 }
91559162
91569163 // Ensure that we can build a route for 3M msat across the three paths to node 2.
@@ -9159,20 +9166,31 @@ mod tests {
91599166 . with_bolt11_features ( channelmanager:: provided_bolt11_invoice_features ( & config) )
91609167 . unwrap ( ) ;
91619168 payment_params. max_channel_saturation_power_of_half = 0 ;
9162- let route_params = RouteParameters :: from_payment_params_and_value ( payment_params, 3_000_000 ) ;
9163- let route = get_route ( & our_id, & route_params, & network_graph. read_only ( ) , None ,
9164- Arc :: clone ( & logger) , & scorer, & Default :: default ( ) , & random_seed_bytes) . unwrap ( ) ;
9169+ let route_params =
9170+ RouteParameters :: from_payment_params_and_value ( payment_params, 3_000_000 ) ;
9171+ let route = get_route (
9172+ & our_id,
9173+ & route_params,
9174+ & network_graph. read_only ( ) ,
9175+ None ,
9176+ Arc :: clone ( & logger) ,
9177+ & scorer,
9178+ & Default :: default ( ) ,
9179+ & random_seed_bytes,
9180+ )
9181+ . unwrap ( ) ;
91659182 assert_eq ! ( route. paths. len( ) , 3 ) ;
91669183 for path in route. paths {
91679184 assert_eq ! ( path. hops. len( ) , 2 ) ;
91689185 }
91699186
91709187 // Finally, create a single channel with fee of 2 sat from node 1 to node 2 which allows
91719188 // for a larger payment.
9172- add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , & privkeys[ 2 ] , ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 16 ) ) , 16 ) ;
9189+ let features_16 = ChannelFeatures :: from_le_bytes ( id_to_feature_flags ( 16 ) ) ;
9190+ add_channel ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , & privkeys[ 2 ] , features_16, 16 ) ;
91739191
91749192 // Set the fee on channel 16 to 2 sats, max HTLC to 3M msat
9175- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 1 ] , UnsignedChannelUpdate {
9193+ let update_16_a = UnsignedChannelUpdate {
91769194 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
91779195 short_channel_id : 16 ,
91789196 timestamp : 2 ,
@@ -9183,11 +9201,12 @@ mod tests {
91839201 htlc_maximum_msat : 3_000_000 ,
91849202 fee_base_msat : 2_000 ,
91859203 fee_proportional_millionths : 0 ,
9186- excess_data : Vec :: new ( )
9187- } ) ;
9204+ excess_data : Vec :: new ( ) ,
9205+ } ;
9206+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , update_16_a) ;
91889207
91899208 // Enable channel 16 by providing an update in both directions
9190- update_channel ( & gossip_sync , & secp_ctx , & privkeys [ 2 ] , UnsignedChannelUpdate {
9209+ let update_16_b = UnsignedChannelUpdate {
91919210 chain_hash : ChainHash :: using_genesis_block ( Network :: Testnet ) ,
91929211 short_channel_id : 16 ,
91939212 timestamp : 2 ,
@@ -9198,12 +9217,22 @@ mod tests {
91989217 htlc_maximum_msat : 10_000_000 ,
91999218 fee_base_msat : u32:: MAX ,
92009219 fee_proportional_millionths : 0 ,
9201- excess_data : Vec :: new ( )
9202- } ) ;
9220+ excess_data : Vec :: new ( ) ,
9221+ } ;
9222+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , update_16_b) ;
92039223
92049224 // Ensure that we now build a route for 3M msat across just the new path
9205- let route = get_route ( & our_id, & route_params, & network_graph. read_only ( ) , None ,
9206- Arc :: clone ( & logger) , & scorer, & Default :: default ( ) , & random_seed_bytes) . unwrap ( ) ;
9225+ let route = get_route (
9226+ & our_id,
9227+ & route_params,
9228+ & network_graph. read_only ( ) ,
9229+ None ,
9230+ Arc :: clone ( & logger) ,
9231+ & scorer,
9232+ & Default :: default ( ) ,
9233+ & random_seed_bytes,
9234+ )
9235+ . unwrap ( ) ;
92079236 assert_eq ! ( route. paths. len( ) , 1 ) ;
92089237 assert_eq ! ( route. paths[ 0 ] . hops. len( ) , 2 ) ;
92099238 assert_eq ! ( route. paths[ 0 ] . hops[ 1 ] . short_channel_id, 16 ) ;
0 commit comments