]> git.bitcoin.ninja Git - rust-lightning/blob - lightning/src/routing/test_utils.rs
Merge pull request #2024 from TheBlueMatt/2023-02-6conf-pub-hints
[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, P2PGossipSync};
11 use crate::ln::features::{ChannelFeatures, NodeFeatures};
12 use crate::ln::msgs::{UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
13         NodeAnnouncement, UnsignedNodeAnnouncement, ChannelUpdate, UnsignedChannelUpdate, MAX_VALUE_MSAT};
14 use crate::util::test_utils;
15 use crate::util::ser::Writeable;
16
17 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
18 use bitcoin::hashes::Hash;
19 use bitcoin::network::constants::Network;
20 use bitcoin::blockdata::constants::genesis_block;
21
22 use hex;
23
24 use bitcoin::secp256k1::{PublicKey,SecretKey};
25 use bitcoin::secp256k1::{Secp256k1, All};
26
27 use crate::prelude::*;
28 use crate::sync::{self, Arc};
29
30 use crate::routing::gossip::NodeId;
31
32 // Using the same keys for LN and BTC ids
33 pub(super) fn add_channel(
34         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
35         secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
36 ) {
37         let node_id_1 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
38         let node_id_2 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_2_privkey));
39
40         let unsigned_announcement = UnsignedChannelAnnouncement {
41                 features,
42                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
43                 short_channel_id,
44                 node_id_1,
45                 node_id_2,
46                 bitcoin_key_1: node_id_1,
47                 bitcoin_key_2: node_id_2,
48                 excess_data: Vec::new(),
49         };
50
51         let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
52         let valid_announcement = ChannelAnnouncement {
53                 node_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_privkey),
54                 node_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
55                 bitcoin_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_privkey),
56                 bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
57                 contents: unsigned_announcement.clone(),
58         };
59         match gossip_sync.handle_channel_announcement(&valid_announcement) {
60                 Ok(res) => assert!(res),
61                 _ => panic!()
62         };
63 }
64
65 pub(super) fn add_or_update_node(
66         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
67         secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
68 ) {
69         let node_id = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_privkey));
70         let unsigned_announcement = UnsignedNodeAnnouncement {
71                 features,
72                 timestamp,
73                 node_id,
74                 rgb: [0; 3],
75                 alias: [0; 32],
76                 addresses: Vec::new(),
77                 excess_address_data: Vec::new(),
78                 excess_data: Vec::new(),
79         };
80         let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
81         let valid_announcement = NodeAnnouncement {
82                 signature: secp_ctx.sign_ecdsa(&msghash, node_privkey),
83                 contents: unsigned_announcement.clone()
84         };
85
86         match gossip_sync.handle_node_announcement(&valid_announcement) {
87                 Ok(_) => (),
88                 Err(_) => panic!()
89         };
90 }
91
92 pub(super) fn update_channel(
93         gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
94         secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
95 ) {
96         let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
97         let valid_channel_update = ChannelUpdate {
98                 signature: secp_ctx.sign_ecdsa(&msghash, node_privkey),
99                 contents: update.clone()
100         };
101
102         match gossip_sync.handle_channel_update(&valid_channel_update) {
103                 Ok(res) => assert!(res),
104                 Err(_) => panic!()
105         };
106 }
107
108 pub(super) fn get_nodes(secp_ctx: &Secp256k1<All>) -> (SecretKey, PublicKey, Vec<SecretKey>, Vec<PublicKey>) {
109         let privkeys: Vec<SecretKey> = (2..22).map(|i| {
110                 SecretKey::from_slice(&hex::decode(format!("{:02x}", i).repeat(32)).unwrap()[..]).unwrap()
111         }).collect();
112
113         let pubkeys = privkeys.iter().map(|secret| PublicKey::from_secret_key(&secp_ctx, secret)).collect();
114
115         let our_privkey = SecretKey::from_slice(&hex::decode("01".repeat(32)).unwrap()[..]).unwrap();
116         let our_id = PublicKey::from_secret_key(&secp_ctx, &our_privkey);
117
118         (our_privkey, our_id, privkeys, pubkeys)
119 }
120
121 pub(super) fn id_to_feature_flags(id: u8) -> Vec<u8> {
122         // Set the feature flags to the id'th odd (ie non-required) feature bit so that we can
123         // test for it later.
124         let idx = (id - 1) * 2 + 1;
125         if idx > 8*3 {
126                 vec![1 << (idx - 8*3), 0, 0, 0]
127         } else if idx > 8*2 {
128                 vec![1 << (idx - 8*2), 0, 0]
129         } else if idx > 8*1 {
130                 vec![1 << (idx - 8*1), 0]
131         } else {
132                 vec![1 << idx]
133         }
134 }
135
136 pub(super) fn build_line_graph() -> (
137         Secp256k1<All>, sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
138         P2PGossipSync<sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>>,
139         sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>,
140 ) {
141         let secp_ctx = Secp256k1::new();
142         let logger = Arc::new(test_utils::TestLogger::new());
143         let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
144         let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger)));
145         let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
146
147         // Build network from our_id to node 19:
148         // our_id -1(1)2- node0 -1(2)2- node1 - ... - node19
149         let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
150
151         for (idx, (cur_privkey, next_privkey)) in core::iter::once(&our_privkey)
152                 .chain(privkeys.iter()).zip(privkeys.iter()).enumerate() {
153                         let cur_short_channel_id = (idx as u64) + 1;
154                         add_channel(&gossip_sync, &secp_ctx, &cur_privkey, &next_privkey,
155                                 ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), cur_short_channel_id);
156                         update_channel(&gossip_sync, &secp_ctx, &cur_privkey, UnsignedChannelUpdate {
157                                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
158                                 short_channel_id: cur_short_channel_id,
159                                 timestamp: idx as u32,
160                                 flags: 0,
161                                 cltv_expiry_delta: 0,
162                                 htlc_minimum_msat: 0,
163                                 htlc_maximum_msat: MAX_VALUE_MSAT,
164                                 fee_base_msat: 0,
165                                 fee_proportional_millionths: 0,
166                                 excess_data: Vec::new()
167                         });
168                         update_channel(&gossip_sync, &secp_ctx, &next_privkey, UnsignedChannelUpdate {
169                                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
170                                 short_channel_id: cur_short_channel_id,
171                                 timestamp: (idx as u32)+1,
172                                 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: genesis_block(Network::Testnet).header.block_hash(),
263                 short_channel_id: 1,
264                 timestamp: 1,
265                 flags: 1,
266                 cltv_expiry_delta: 0,
267                 htlc_minimum_msat: 0,
268                 htlc_maximum_msat: MAX_VALUE_MSAT,
269                 fee_base_msat: 0,
270                 fee_proportional_millionths: 0,
271                 excess_data: Vec::new()
272         });
273
274         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[0], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
275
276         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
277         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
278                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
279                 short_channel_id: 2,
280                 timestamp: 1,
281                 flags: 0,
282                 cltv_expiry_delta: (5 << 4) | 3,
283                 htlc_minimum_msat: 0,
284                 htlc_maximum_msat: MAX_VALUE_MSAT,
285                 fee_base_msat: u32::max_value(),
286                 fee_proportional_millionths: u32::max_value(),
287                 excess_data: Vec::new()
288         });
289         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
290                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
291                 short_channel_id: 2,
292                 timestamp: 1,
293                 flags: 1,
294                 cltv_expiry_delta: 0,
295                 htlc_minimum_msat: 0,
296                 htlc_maximum_msat: MAX_VALUE_MSAT,
297                 fee_base_msat: 0,
298                 fee_proportional_millionths: 0,
299                 excess_data: Vec::new()
300         });
301
302         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
303
304         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
305         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
306                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
307                 short_channel_id: 12,
308                 timestamp: 1,
309                 flags: 0,
310                 cltv_expiry_delta: (5 << 4) | 3,
311                 htlc_minimum_msat: 0,
312                 htlc_maximum_msat: MAX_VALUE_MSAT,
313                 fee_base_msat: u32::max_value(),
314                 fee_proportional_millionths: u32::max_value(),
315                 excess_data: Vec::new()
316         });
317         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
318                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
319                 short_channel_id: 12,
320                 timestamp: 1,
321                 flags: 1,
322                 cltv_expiry_delta: 0,
323                 htlc_minimum_msat: 0,
324                 htlc_maximum_msat: MAX_VALUE_MSAT,
325                 fee_base_msat: 0,
326                 fee_proportional_millionths: 0,
327                 excess_data: Vec::new()
328         });
329
330         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[7], NodeFeatures::from_le_bytes(id_to_feature_flags(8)), 0);
331
332         add_channel(&gossip_sync, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
333         update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
334                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
335                 short_channel_id: 3,
336                 timestamp: 1,
337                 flags: 0,
338                 cltv_expiry_delta: (3 << 4) | 1,
339                 htlc_minimum_msat: 0,
340                 htlc_maximum_msat: MAX_VALUE_MSAT,
341                 fee_base_msat: 0,
342                 fee_proportional_millionths: 0,
343                 excess_data: Vec::new()
344         });
345         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
346                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
347                 short_channel_id: 3,
348                 timestamp: 1,
349                 flags: 1,
350                 cltv_expiry_delta: (3 << 4) | 2,
351                 htlc_minimum_msat: 0,
352                 htlc_maximum_msat: MAX_VALUE_MSAT,
353                 fee_base_msat: 100,
354                 fee_proportional_millionths: 0,
355                 excess_data: Vec::new()
356         });
357
358         add_channel(&gossip_sync, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
359         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
360                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
361                 short_channel_id: 4,
362                 timestamp: 1,
363                 flags: 0,
364                 cltv_expiry_delta: (4 << 4) | 1,
365                 htlc_minimum_msat: 0,
366                 htlc_maximum_msat: MAX_VALUE_MSAT,
367                 fee_base_msat: 0,
368                 fee_proportional_millionths: 1000000,
369                 excess_data: Vec::new()
370         });
371         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
372                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
373                 short_channel_id: 4,
374                 timestamp: 1,
375                 flags: 1,
376                 cltv_expiry_delta: (4 << 4) | 2,
377                 htlc_minimum_msat: 0,
378                 htlc_maximum_msat: MAX_VALUE_MSAT,
379                 fee_base_msat: 0,
380                 fee_proportional_millionths: 0,
381                 excess_data: Vec::new()
382         });
383
384         add_channel(&gossip_sync, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
385         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
386                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
387                 short_channel_id: 13,
388                 timestamp: 1,
389                 flags: 0,
390                 cltv_expiry_delta: (13 << 4) | 1,
391                 htlc_minimum_msat: 0,
392                 htlc_maximum_msat: MAX_VALUE_MSAT,
393                 fee_base_msat: 0,
394                 fee_proportional_millionths: 2000000,
395                 excess_data: Vec::new()
396         });
397         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
398                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
399                 short_channel_id: 13,
400                 timestamp: 1,
401                 flags: 1,
402                 cltv_expiry_delta: (13 << 4) | 2,
403                 htlc_minimum_msat: 0,
404                 htlc_maximum_msat: MAX_VALUE_MSAT,
405                 fee_base_msat: 0,
406                 fee_proportional_millionths: 0,
407                 excess_data: Vec::new()
408         });
409
410         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
411
412         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
413         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
414                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
415                 short_channel_id: 6,
416                 timestamp: 1,
417                 flags: 0,
418                 cltv_expiry_delta: (6 << 4) | 1,
419                 htlc_minimum_msat: 0,
420                 htlc_maximum_msat: MAX_VALUE_MSAT,
421                 fee_base_msat: 0,
422                 fee_proportional_millionths: 0,
423                 excess_data: Vec::new()
424         });
425         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
426                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
427                 short_channel_id: 6,
428                 timestamp: 1,
429                 flags: 1,
430                 cltv_expiry_delta: (6 << 4) | 2,
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
438         add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
439         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
440                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
441                 short_channel_id: 11,
442                 timestamp: 1,
443                 flags: 0,
444                 cltv_expiry_delta: (11 << 4) | 1,
445                 htlc_minimum_msat: 0,
446                 htlc_maximum_msat: MAX_VALUE_MSAT,
447                 fee_base_msat: 0,
448                 fee_proportional_millionths: 0,
449                 excess_data: Vec::new()
450         });
451         update_channel(&gossip_sync, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
452                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
453                 short_channel_id: 11,
454                 timestamp: 1,
455                 flags: 1,
456                 cltv_expiry_delta: (11 << 4) | 2,
457                 htlc_minimum_msat: 0,
458                 htlc_maximum_msat: MAX_VALUE_MSAT,
459                 fee_base_msat: 0,
460                 fee_proportional_millionths: 0,
461                 excess_data: Vec::new()
462         });
463
464         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(5)), 0);
465
466         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
467
468         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
469         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
470                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
471                 short_channel_id: 7,
472                 timestamp: 1,
473                 flags: 0,
474                 cltv_expiry_delta: (7 << 4) | 1,
475                 htlc_minimum_msat: 0,
476                 htlc_maximum_msat: MAX_VALUE_MSAT,
477                 fee_base_msat: 0,
478                 fee_proportional_millionths: 1000000,
479                 excess_data: Vec::new()
480         });
481         update_channel(&gossip_sync, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
482                 chain_hash: genesis_block(Network::Testnet).header.block_hash(),
483                 short_channel_id: 7,
484                 timestamp: 1,
485                 flags: 1,
486                 cltv_expiry_delta: (7 << 4) | 2,
487                 htlc_minimum_msat: 0,
488                 htlc_maximum_msat: MAX_VALUE_MSAT,
489                 fee_base_msat: 0,
490                 fee_proportional_millionths: 0,
491                 excess_data: Vec::new()
492         });
493
494         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[5], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
495
496         (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
497 }