Re-order imports
[rust-lightning] / lightning / src / routing / test_utils.rs
1 // This file is Copyright its original authors, visible in version control
2 // history.
3 //
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
8 // licenses.
9
10 use crate::routing::gossip::{NetworkGraph, NodeAlias, P2PGossipSync};
11 use crate::ln::features::{ChannelFeatures, NodeFeatures};
12 use crate::ln::msgs::{ChannelAnnouncement, ChannelUpdate, MAX_VALUE_MSAT, NodeAnnouncement, RoutingMessageHandler, UnsignedChannelAnnouncement, UnsignedChannelUpdate, UnsignedNodeAnnouncement};
13 use crate::util::test_utils;
14 use crate::util::ser::Writeable;
15
16 use bitcoin::blockdata::constants::ChainHash;
17 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
18 use bitcoin::hashes::Hash;
19 use bitcoin::hashes::hex::FromHex;
20 use bitcoin::network::constants::Network;
21 use bitcoin::secp256k1::{PublicKey,SecretKey};
22 use bitcoin::secp256k1::{Secp256k1, All};
23
24 use crate::prelude::*;
25 use crate::sync::{self, Arc};
26
27 use crate::routing::gossip::NodeId;
28
29 // Using the same keys for LN and BTC ids
30 pub(super) fn add_channel(
31         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
32         secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
33 ) {
34         let node_id_1 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
35         let node_id_2 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_2_privkey));
36
37         let unsigned_announcement = UnsignedChannelAnnouncement {
38                 features,
39                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
40                 short_channel_id,
41                 node_id_1,
42                 node_id_2,
43                 bitcoin_key_1: node_id_1,
44                 bitcoin_key_2: node_id_2,
45                 excess_data: Vec::new(),
46         };
47
48         let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
49         let valid_announcement = ChannelAnnouncement {
50                 node_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_privkey),
51                 node_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
52                 bitcoin_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_privkey),
53                 bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
54                 contents: unsigned_announcement.clone(),
55         };
56         match gossip_sync.handle_channel_announcement(&valid_announcement) {
57                 Ok(res) => assert!(res),
58                 _ => panic!()
59         };
60 }
61
62 pub(super) fn add_or_update_node(
63         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
64         secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
65 ) {
66         let node_id = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_privkey));
67         let unsigned_announcement = UnsignedNodeAnnouncement {
68                 features,
69                 timestamp,
70                 node_id,
71                 rgb: [0; 3],
72                 alias: NodeAlias([0; 32]),
73                 addresses: Vec::new(),
74                 excess_address_data: Vec::new(),
75                 excess_data: Vec::new(),
76         };
77         let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
78         let valid_announcement = NodeAnnouncement {
79                 signature: secp_ctx.sign_ecdsa(&msghash, node_privkey),
80                 contents: unsigned_announcement.clone()
81         };
82
83         match gossip_sync.handle_node_announcement(&valid_announcement) {
84                 Ok(_) => (),
85                 Err(_) => panic!()
86         };
87 }
88
89 pub(super) fn update_channel(
90         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
91         secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
92 ) {
93         let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
94         let valid_channel_update = ChannelUpdate {
95                 signature: secp_ctx.sign_ecdsa(&msghash, node_privkey),
96                 contents: update.clone()
97         };
98
99         match gossip_sync.handle_channel_update(&valid_channel_update) {
100                 Ok(res) => assert!(res),
101                 Err(_) => panic!()
102         };
103 }
104
105 pub(super) fn get_nodes(secp_ctx: &Secp256k1<All>) -> (SecretKey, PublicKey, Vec<SecretKey>, Vec<PublicKey>) {
106         let privkeys: Vec<SecretKey> = (2..22).map(|i| {
107                 SecretKey::from_slice(&<Vec<u8>>::from_hex(&format!("{:02x}", i).repeat(32)).unwrap()[..]).unwrap()
108         }).collect();
109
110         let pubkeys = privkeys.iter().map(|secret| PublicKey::from_secret_key(&secp_ctx, secret)).collect();
111
112         let our_privkey = SecretKey::from_slice(&<Vec<u8>>::from_hex(&"01".repeat(32)).unwrap()[..]).unwrap();
113         let our_id = PublicKey::from_secret_key(&secp_ctx, &our_privkey);
114
115         (our_privkey, our_id, privkeys, pubkeys)
116 }
117
118 pub(super) fn id_to_feature_flags(id: u8) -> Vec<u8> {
119         // Set the feature flags to the id'th odd (ie non-required) feature bit so that we can
120         // test for it later.
121         let idx = (id - 1) * 2 + 1;
122         if idx > 8*3 {
123                 vec![1 << (idx - 8*3), 0, 0, 0]
124         } else if idx > 8*2 {
125                 vec![1 << (idx - 8*2), 0, 0]
126         } else if idx > 8*1 {
127                 vec![1 << (idx - 8*1), 0]
128         } else {
129                 vec![1 << idx]
130         }
131 }
132
133 pub(super) fn build_line_graph() -> (
134         Secp256k1<All>, sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
135         P2PGossipSync<sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>>,
136         sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>,
137 ) {
138         let secp_ctx = Secp256k1::new();
139         let logger = Arc::new(test_utils::TestLogger::new());
140         let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
141         let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger)));
142         let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
143
144         // Build network from our_id to node 19:
145         // our_id -1(1)2- node0 -1(2)2- node1 - ... - node19
146         let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
147
148         for (idx, (cur_privkey, next_privkey)) in core::iter::once(&our_privkey)
149                 .chain(privkeys.iter()).zip(privkeys.iter()).enumerate() {
150                         let cur_short_channel_id = (idx as u64) + 1;
151                         add_channel(&gossip_sync, &secp_ctx, &cur_privkey, &next_privkey,
152                                 ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), cur_short_channel_id);
153                         update_channel(&gossip_sync, &secp_ctx, &cur_privkey, UnsignedChannelUpdate {
154                                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
155                                 short_channel_id: cur_short_channel_id,
156                                 timestamp: idx as u32,
157                                 flags: 0,
158                                 cltv_expiry_delta: 0,
159                                 htlc_minimum_msat: 0,
160                                 htlc_maximum_msat: MAX_VALUE_MSAT,
161                                 fee_base_msat: 0,
162                                 fee_proportional_millionths: 0,
163                                 excess_data: Vec::new()
164                         });
165                         update_channel(&gossip_sync, &secp_ctx, &next_privkey, UnsignedChannelUpdate {
166                                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
167                                 short_channel_id: cur_short_channel_id,
168                                 timestamp: (idx as u32)+1,
169                                 flags: 1,
170                                 cltv_expiry_delta: 0,
171                                 htlc_minimum_msat: 0,
172                                 htlc_maximum_msat: MAX_VALUE_MSAT,
173                                 fee_base_msat: 0,
174                                 fee_proportional_millionths: 0,
175                                 excess_data: Vec::new()
176                         });
177                         add_or_update_node(&gossip_sync, &secp_ctx, &next_privkey,
178                                 NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
179                 }
180
181         (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
182 }
183
184 pub(super) fn build_graph() -> (
185         Secp256k1<All>,
186         sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
187         P2PGossipSync<sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>>,
188         sync::Arc<test_utils::TestChainSource>,
189         sync::Arc<test_utils::TestLogger>,
190 ) {
191         let secp_ctx = Secp256k1::new();
192         let logger = Arc::new(test_utils::TestLogger::new());
193         let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
194         let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger)));
195         let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
196         // Build network from our_id to node6:
197         //
198         //        -1(1)2-  node0  -1(3)2-
199         //       /                       \
200         // our_id -1(12)2- node7 -1(13)2--- node2
201         //       \                       /
202         //        -1(2)2-  node1  -1(4)2-
203         //
204         //
205         // chan1  1-to-2: disabled
206         // chan1  2-to-1: enabled, 0 fee
207         //
208         // chan2  1-to-2: enabled, ignored fee
209         // chan2  2-to-1: enabled, 0 fee
210         //
211         // chan3  1-to-2: enabled, 0 fee
212         // chan3  2-to-1: enabled, 100 msat fee
213         //
214         // chan4  1-to-2: enabled, 100% fee
215         // chan4  2-to-1: enabled, 0 fee
216         //
217         // chan12 1-to-2: enabled, ignored fee
218         // chan12 2-to-1: enabled, 0 fee
219         //
220         // chan13 1-to-2: enabled, 200% fee
221         // chan13 2-to-1: enabled, 0 fee
222         //
223         //
224         //       -1(5)2- node3 -1(8)2--
225         //       |         2          |
226         //       |       (11)         |
227         //      /          1           \
228         // node2--1(6)2- node4 -1(9)2--- node6 (not in global route map)
229         //      \                      /
230         //       -1(7)2- node5 -1(10)2-
231         //
232         // Channels 5, 8, 9 and 10 are private channels.
233         //
234         // chan5  1-to-2: enabled, 100 msat fee
235         // chan5  2-to-1: enabled, 0 fee
236         //
237         // chan6  1-to-2: enabled, 0 fee
238         // chan6  2-to-1: enabled, 0 fee
239         //
240         // chan7  1-to-2: enabled, 100% fee
241         // chan7  2-to-1: enabled, 0 fee
242         //
243         // chan8  1-to-2: enabled, variable fee (0 then 1000 msat)
244         // chan8  2-to-1: enabled, 0 fee
245         //
246         // chan9  1-to-2: enabled, 1001 msat fee
247         // chan9  2-to-1: enabled, 0 fee
248         //
249         // chan10 1-to-2: enabled, 0 fee
250         // chan10 2-to-1: enabled, 0 fee
251         //
252         // chan11 1-to-2: enabled, 0 fee
253         // chan11 2-to-1: enabled, 0 fee
254
255         let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
256
257         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[0], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
258         update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
259                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
260                 short_channel_id: 1,
261                 timestamp: 1,
262                 flags: 1,
263                 cltv_expiry_delta: 0,
264                 htlc_minimum_msat: 0,
265                 htlc_maximum_msat: MAX_VALUE_MSAT,
266                 fee_base_msat: 0,
267                 fee_proportional_millionths: 0,
268                 excess_data: Vec::new()
269         });
270
271         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[0], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
272
273         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
274         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
275                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
276                 short_channel_id: 2,
277                 timestamp: 1,
278                 flags: 0,
279                 cltv_expiry_delta: (5 << 4) | 3,
280                 htlc_minimum_msat: 0,
281                 htlc_maximum_msat: MAX_VALUE_MSAT,
282                 fee_base_msat: u32::max_value(),
283                 fee_proportional_millionths: u32::max_value(),
284                 excess_data: Vec::new()
285         });
286         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
287                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
288                 short_channel_id: 2,
289                 timestamp: 1,
290                 flags: 1,
291                 cltv_expiry_delta: 0,
292                 htlc_minimum_msat: 0,
293                 htlc_maximum_msat: MAX_VALUE_MSAT,
294                 fee_base_msat: 0,
295                 fee_proportional_millionths: 0,
296                 excess_data: Vec::new()
297         });
298
299         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
300
301         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
302         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
303                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
304                 short_channel_id: 12,
305                 timestamp: 1,
306                 flags: 0,
307                 cltv_expiry_delta: (5 << 4) | 3,
308                 htlc_minimum_msat: 0,
309                 htlc_maximum_msat: MAX_VALUE_MSAT,
310                 fee_base_msat: u32::max_value(),
311                 fee_proportional_millionths: u32::max_value(),
312                 excess_data: Vec::new()
313         });
314         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
315                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
316                 short_channel_id: 12,
317                 timestamp: 1,
318                 flags: 1,
319                 cltv_expiry_delta: 0,
320                 htlc_minimum_msat: 0,
321                 htlc_maximum_msat: MAX_VALUE_MSAT,
322                 fee_base_msat: 0,
323                 fee_proportional_millionths: 0,
324                 excess_data: Vec::new()
325         });
326
327         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[7], NodeFeatures::from_le_bytes(id_to_feature_flags(8)), 0);
328
329         add_channel(&gossip_sync, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
330         update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
331                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
332                 short_channel_id: 3,
333                 timestamp: 1,
334                 flags: 0,
335                 cltv_expiry_delta: (3 << 4) | 1,
336                 htlc_minimum_msat: 0,
337                 htlc_maximum_msat: MAX_VALUE_MSAT,
338                 fee_base_msat: 0,
339                 fee_proportional_millionths: 0,
340                 excess_data: Vec::new()
341         });
342         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
343                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
344                 short_channel_id: 3,
345                 timestamp: 1,
346                 flags: 1,
347                 cltv_expiry_delta: (3 << 4) | 2,
348                 htlc_minimum_msat: 0,
349                 htlc_maximum_msat: MAX_VALUE_MSAT,
350                 fee_base_msat: 100,
351                 fee_proportional_millionths: 0,
352                 excess_data: Vec::new()
353         });
354
355         add_channel(&gossip_sync, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
356         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
357                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
358                 short_channel_id: 4,
359                 timestamp: 1,
360                 flags: 0,
361                 cltv_expiry_delta: (4 << 4) | 1,
362                 htlc_minimum_msat: 0,
363                 htlc_maximum_msat: MAX_VALUE_MSAT,
364                 fee_base_msat: 0,
365                 fee_proportional_millionths: 1000000,
366                 excess_data: Vec::new()
367         });
368         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
369                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
370                 short_channel_id: 4,
371                 timestamp: 1,
372                 flags: 1,
373                 cltv_expiry_delta: (4 << 4) | 2,
374                 htlc_minimum_msat: 0,
375                 htlc_maximum_msat: MAX_VALUE_MSAT,
376                 fee_base_msat: 0,
377                 fee_proportional_millionths: 0,
378                 excess_data: Vec::new()
379         });
380
381         add_channel(&gossip_sync, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
382         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
383                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
384                 short_channel_id: 13,
385                 timestamp: 1,
386                 flags: 0,
387                 cltv_expiry_delta: (13 << 4) | 1,
388                 htlc_minimum_msat: 0,
389                 htlc_maximum_msat: MAX_VALUE_MSAT,
390                 fee_base_msat: 0,
391                 fee_proportional_millionths: 2000000,
392                 excess_data: Vec::new()
393         });
394         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
395                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
396                 short_channel_id: 13,
397                 timestamp: 1,
398                 flags: 1,
399                 cltv_expiry_delta: (13 << 4) | 2,
400                 htlc_minimum_msat: 0,
401                 htlc_maximum_msat: MAX_VALUE_MSAT,
402                 fee_base_msat: 0,
403                 fee_proportional_millionths: 0,
404                 excess_data: Vec::new()
405         });
406
407         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
408
409         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
410         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
411                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
412                 short_channel_id: 6,
413                 timestamp: 1,
414                 flags: 0,
415                 cltv_expiry_delta: (6 << 4) | 1,
416                 htlc_minimum_msat: 0,
417                 htlc_maximum_msat: MAX_VALUE_MSAT,
418                 fee_base_msat: 0,
419                 fee_proportional_millionths: 0,
420                 excess_data: Vec::new()
421         });
422         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
423                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
424                 short_channel_id: 6,
425                 timestamp: 1,
426                 flags: 1,
427                 cltv_expiry_delta: (6 << 4) | 2,
428                 htlc_minimum_msat: 0,
429                 htlc_maximum_msat: MAX_VALUE_MSAT,
430                 fee_base_msat: 0,
431                 fee_proportional_millionths: 0,
432                 excess_data: Vec::new(),
433         });
434
435         add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
436         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
437                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
438                 short_channel_id: 11,
439                 timestamp: 1,
440                 flags: 0,
441                 cltv_expiry_delta: (11 << 4) | 1,
442                 htlc_minimum_msat: 0,
443                 htlc_maximum_msat: MAX_VALUE_MSAT,
444                 fee_base_msat: 0,
445                 fee_proportional_millionths: 0,
446                 excess_data: Vec::new()
447         });
448         update_channel(&gossip_sync, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
449                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
450                 short_channel_id: 11,
451                 timestamp: 1,
452                 flags: 1,
453                 cltv_expiry_delta: (11 << 4) | 2,
454                 htlc_minimum_msat: 0,
455                 htlc_maximum_msat: MAX_VALUE_MSAT,
456                 fee_base_msat: 0,
457                 fee_proportional_millionths: 0,
458                 excess_data: Vec::new()
459         });
460
461         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(5)), 0);
462
463         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
464
465         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
466         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
467                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
468                 short_channel_id: 7,
469                 timestamp: 1,
470                 flags: 0,
471                 cltv_expiry_delta: (7 << 4) | 1,
472                 htlc_minimum_msat: 0,
473                 htlc_maximum_msat: MAX_VALUE_MSAT,
474                 fee_base_msat: 0,
475                 fee_proportional_millionths: 1000000,
476                 excess_data: Vec::new()
477         });
478         update_channel(&gossip_sync, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
479                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
480                 short_channel_id: 7,
481                 timestamp: 1,
482                 flags: 1,
483                 cltv_expiry_delta: (7 << 4) | 2,
484                 htlc_minimum_msat: 0,
485                 htlc_maximum_msat: MAX_VALUE_MSAT,
486                 fee_base_msat: 0,
487                 fee_proportional_millionths: 0,
488                 excess_data: Vec::new()
489         });
490
491         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[5], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
492
493         (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
494 }