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