@@ -197,6 +197,55 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
197
197
let mut node_pks = HashSet :: new ( ) ;
198
198
let mut scid = 42 ;
199
199
200
+ macro_rules! first_hops {
201
+ ( $first_hops_vec: expr) => {
202
+ match get_slice!( 1 ) [ 0 ] {
203
+ 0 => None ,
204
+ count => {
205
+ for _ in 0 ..count {
206
+ scid += 1 ;
207
+ let rnid = node_pks. iter( ) . skip( u16 :: from_be_bytes( get_slice!( 2 ) . try_into( ) . unwrap( ) ) as usize % node_pks. len( ) ) . next( ) . unwrap( ) ;
208
+ let capacity = u64 :: from_be_bytes( get_slice!( 8 ) . try_into( ) . unwrap( ) ) ;
209
+ $first_hops_vec. push( ChannelDetails {
210
+ channel_id: [ 0 ; 32 ] ,
211
+ counterparty: ChannelCounterparty {
212
+ node_id: * rnid,
213
+ features: channelmanager:: provided_init_features( & UserConfig :: default ( ) ) ,
214
+ unspendable_punishment_reserve: 0 ,
215
+ forwarding_info: None ,
216
+ outbound_htlc_minimum_msat: None ,
217
+ outbound_htlc_maximum_msat: None ,
218
+ } ,
219
+ funding_txo: Some ( OutPoint { txid: bitcoin:: Txid :: from_slice( & [ 0 ; 32 ] ) . unwrap( ) , index: 0 } ) ,
220
+ channel_type: None ,
221
+ short_channel_id: Some ( scid) ,
222
+ inbound_scid_alias: None ,
223
+ outbound_scid_alias: None ,
224
+ channel_value_satoshis: capacity,
225
+ user_channel_id: 0 , inbound_capacity_msat: 0 ,
226
+ unspendable_punishment_reserve: None ,
227
+ confirmations_required: None ,
228
+ confirmations: None ,
229
+ force_close_spend_delay: None ,
230
+ is_outbound: true , is_channel_ready: true ,
231
+ is_usable: true , is_public: true ,
232
+ balance_msat: 0 ,
233
+ outbound_capacity_msat: capacity. saturating_mul( 1000 ) ,
234
+ next_outbound_htlc_limit_msat: capacity. saturating_mul( 1000 ) ,
235
+ next_outbound_htlc_minimum_msat: 0 ,
236
+ inbound_htlc_minimum_msat: None ,
237
+ inbound_htlc_maximum_msat: None ,
238
+ config: None ,
239
+ feerate_sat_per_1000_weight: None ,
240
+ channel_shutdown_state: Some ( channelmanager:: ChannelShutdownState :: NotShuttingDown ) ,
241
+ } ) ;
242
+ }
243
+ Some ( & $first_hops_vec[ ..] )
244
+ } ,
245
+ }
246
+ }
247
+ }
248
+
200
249
loop {
201
250
match get_slice ! ( 1 ) [ 0 ] {
202
251
0 => {
@@ -232,50 +281,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
232
281
_ if node_pks. is_empty ( ) => { } ,
233
282
_ => {
234
283
let mut first_hops_vec = Vec :: new ( ) ;
235
- let first_hops = match get_slice ! ( 1 ) [ 0 ] {
236
- 0 => None ,
237
- count => {
238
- for _ in 0 ..count {
239
- scid += 1 ;
240
- let rnid = node_pks. iter ( ) . skip ( u16:: from_be_bytes ( get_slice ! ( 2 ) . try_into ( ) . unwrap ( ) ) as usize % node_pks. len ( ) ) . next ( ) . unwrap ( ) ;
241
- let capacity = u64:: from_be_bytes ( get_slice ! ( 8 ) . try_into ( ) . unwrap ( ) ) ;
242
- first_hops_vec. push ( ChannelDetails {
243
- channel_id : [ 0 ; 32 ] ,
244
- counterparty : ChannelCounterparty {
245
- node_id : * rnid,
246
- features : channelmanager:: provided_init_features ( & UserConfig :: default ( ) ) ,
247
- unspendable_punishment_reserve : 0 ,
248
- forwarding_info : None ,
249
- outbound_htlc_minimum_msat : None ,
250
- outbound_htlc_maximum_msat : None ,
251
- } ,
252
- funding_txo : Some ( OutPoint { txid : bitcoin:: Txid :: from_slice ( & [ 0 ; 32 ] ) . unwrap ( ) , index : 0 } ) ,
253
- channel_type : None ,
254
- short_channel_id : Some ( scid) ,
255
- inbound_scid_alias : None ,
256
- outbound_scid_alias : None ,
257
- channel_value_satoshis : capacity,
258
- user_channel_id : 0 , inbound_capacity_msat : 0 ,
259
- unspendable_punishment_reserve : None ,
260
- confirmations_required : None ,
261
- confirmations : None ,
262
- force_close_spend_delay : None ,
263
- is_outbound : true , is_channel_ready : true ,
264
- is_usable : true , is_public : true ,
265
- balance_msat : 0 ,
266
- outbound_capacity_msat : capacity. saturating_mul ( 1000 ) ,
267
- next_outbound_htlc_limit_msat : capacity. saturating_mul ( 1000 ) ,
268
- next_outbound_htlc_minimum_msat : 0 ,
269
- inbound_htlc_minimum_msat : None ,
270
- inbound_htlc_maximum_msat : None ,
271
- config : None ,
272
- feerate_sat_per_1000_weight : None ,
273
- channel_shutdown_state : Some ( channelmanager:: ChannelShutdownState :: NotShuttingDown ) ,
274
- } ) ;
275
- }
276
- Some ( & first_hops_vec[ ..] )
277
- } ,
278
- } ;
284
+ let first_hops = first_hops ! ( first_hops_vec) ;
279
285
let mut last_hops = Vec :: new ( ) ;
280
286
{
281
287
let count = get_slice ! ( 1 ) [ 0 ] ;
0 commit comments