]> git.bitcoin.ninja Git - rust-lightning/blob - lightning/src/routing/test_utils.rs
Bump rust-bitcoin to v0.30.2
[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::{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::blockdata::constants::ChainHash;
18 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
19 use bitcoin::hashes::Hash;
20 use bitcoin::hashes::hex::FromHex;
21 use bitcoin::network::constants::Network;
22 use bitcoin::secp256k1::{PublicKey,SecretKey};
23 use bitcoin::secp256k1::{Secp256k1, All};
24
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(super) 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(super) 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::new(),
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(super) 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                                 flags: 0,
159                                 cltv_expiry_delta: 0,
160                                 htlc_minimum_msat: 0,
161                                 htlc_maximum_msat: MAX_VALUE_MSAT,
162                                 fee_base_msat: 0,
163                                 fee_proportional_millionths: 0,
164                                 excess_data: Vec::new()
165                         });
166                         update_channel(&gossip_sync, &secp_ctx, &next_privkey, UnsignedChannelUpdate {
167                                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
168                                 short_channel_id: cur_short_channel_id,
169                                 timestamp: (idx as u32)+1,
170                                 flags: 1,
171                                 cltv_expiry_delta: 0,
172                                 htlc_minimum_msat: 0,
173                                 htlc_maximum_msat: MAX_VALUE_MSAT,
174                                 fee_base_msat: 0,
175                                 fee_proportional_millionths: 0,
176                                 excess_data: Vec::new()
177                         });
178                         add_or_update_node(&gossip_sync, &secp_ctx, &next_privkey,
179                                 NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
180                 }
181
182         (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
183 }
184
185 pub(super) fn build_graph() -> (
186         Secp256k1<All>,
187         sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
188         P2PGossipSync<sync::Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, sync::Arc<test_utils::TestChainSource>, sync::Arc<test_utils::TestLogger>>,
189         sync::Arc<test_utils::TestChainSource>,
190         sync::Arc<test_utils::TestLogger>,
191 ) {
192         let secp_ctx = Secp256k1::new();
193         let logger = Arc::new(test_utils::TestLogger::new());
194         let chain_monitor = Arc::new(test_utils::TestChainSource::new(Network::Testnet));
195         let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, Arc::clone(&logger)));
196         let gossip_sync = P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger));
197         // Build network from our_id to node6:
198         //
199         //        -1(1)2-  node0  -1(3)2-
200         //       /                       \
201         // our_id -1(12)2- node7 -1(13)2--- node2
202         //       \                       /
203         //        -1(2)2-  node1  -1(4)2-
204         //
205         //
206         // chan1  1-to-2: disabled
207         // chan1  2-to-1: enabled, 0 fee
208         //
209         // chan2  1-to-2: enabled, ignored fee
210         // chan2  2-to-1: enabled, 0 fee
211         //
212         // chan3  1-to-2: enabled, 0 fee
213         // chan3  2-to-1: enabled, 100 msat fee
214         //
215         // chan4  1-to-2: enabled, 100% fee
216         // chan4  2-to-1: enabled, 0 fee
217         //
218         // chan12 1-to-2: enabled, ignored fee
219         // chan12 2-to-1: enabled, 0 fee
220         //
221         // chan13 1-to-2: enabled, 200% fee
222         // chan13 2-to-1: enabled, 0 fee
223         //
224         //
225         //       -1(5)2- node3 -1(8)2--
226         //       |         2          |
227         //       |       (11)         |
228         //      /          1           \
229         // node2--1(6)2- node4 -1(9)2--- node6 (not in global route map)
230         //      \                      /
231         //       -1(7)2- node5 -1(10)2-
232         //
233         // Channels 5, 8, 9 and 10 are private channels.
234         //
235         // chan5  1-to-2: enabled, 100 msat fee
236         // chan5  2-to-1: enabled, 0 fee
237         //
238         // chan6  1-to-2: enabled, 0 fee
239         // chan6  2-to-1: enabled, 0 fee
240         //
241         // chan7  1-to-2: enabled, 100% fee
242         // chan7  2-to-1: enabled, 0 fee
243         //
244         // chan8  1-to-2: enabled, variable fee (0 then 1000 msat)
245         // chan8  2-to-1: enabled, 0 fee
246         //
247         // chan9  1-to-2: enabled, 1001 msat fee
248         // chan9  2-to-1: enabled, 0 fee
249         //
250         // chan10 1-to-2: enabled, 0 fee
251         // chan10 2-to-1: enabled, 0 fee
252         //
253         // chan11 1-to-2: enabled, 0 fee
254         // chan11 2-to-1: enabled, 0 fee
255
256         let (our_privkey, _, privkeys, _) = get_nodes(&secp_ctx);
257
258         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[0], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
259         update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
260                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
261                 short_channel_id: 1,
262                 timestamp: 1,
263                 flags: 1,
264                 cltv_expiry_delta: 0,
265                 htlc_minimum_msat: 0,
266                 htlc_maximum_msat: MAX_VALUE_MSAT,
267                 fee_base_msat: 0,
268                 fee_proportional_millionths: 0,
269                 excess_data: Vec::new()
270         });
271
272         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[0], NodeFeatures::from_le_bytes(id_to_feature_flags(1)), 0);
273
274         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
275         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
276                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
277                 short_channel_id: 2,
278                 timestamp: 1,
279                 flags: 0,
280                 cltv_expiry_delta: (5 << 4) | 3,
281                 htlc_minimum_msat: 0,
282                 htlc_maximum_msat: MAX_VALUE_MSAT,
283                 fee_base_msat: u32::max_value(),
284                 fee_proportional_millionths: u32::max_value(),
285                 excess_data: Vec::new()
286         });
287         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
288                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
289                 short_channel_id: 2,
290                 timestamp: 1,
291                 flags: 1,
292                 cltv_expiry_delta: 0,
293                 htlc_minimum_msat: 0,
294                 htlc_maximum_msat: MAX_VALUE_MSAT,
295                 fee_base_msat: 0,
296                 fee_proportional_millionths: 0,
297                 excess_data: Vec::new()
298         });
299
300         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[1], NodeFeatures::from_le_bytes(id_to_feature_flags(2)), 0);
301
302         add_channel(&gossip_sync, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
303         update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
304                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
305                 short_channel_id: 12,
306                 timestamp: 1,
307                 flags: 0,
308                 cltv_expiry_delta: (5 << 4) | 3,
309                 htlc_minimum_msat: 0,
310                 htlc_maximum_msat: MAX_VALUE_MSAT,
311                 fee_base_msat: u32::max_value(),
312                 fee_proportional_millionths: u32::max_value(),
313                 excess_data: Vec::new()
314         });
315         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
316                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
317                 short_channel_id: 12,
318                 timestamp: 1,
319                 flags: 1,
320                 cltv_expiry_delta: 0,
321                 htlc_minimum_msat: 0,
322                 htlc_maximum_msat: MAX_VALUE_MSAT,
323                 fee_base_msat: 0,
324                 fee_proportional_millionths: 0,
325                 excess_data: Vec::new()
326         });
327
328         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[7], NodeFeatures::from_le_bytes(id_to_feature_flags(8)), 0);
329
330         add_channel(&gossip_sync, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
331         update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
332                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
333                 short_channel_id: 3,
334                 timestamp: 1,
335                 flags: 0,
336                 cltv_expiry_delta: (3 << 4) | 1,
337                 htlc_minimum_msat: 0,
338                 htlc_maximum_msat: MAX_VALUE_MSAT,
339                 fee_base_msat: 0,
340                 fee_proportional_millionths: 0,
341                 excess_data: Vec::new()
342         });
343         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
344                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
345                 short_channel_id: 3,
346                 timestamp: 1,
347                 flags: 1,
348                 cltv_expiry_delta: (3 << 4) | 2,
349                 htlc_minimum_msat: 0,
350                 htlc_maximum_msat: MAX_VALUE_MSAT,
351                 fee_base_msat: 100,
352                 fee_proportional_millionths: 0,
353                 excess_data: Vec::new()
354         });
355
356         add_channel(&gossip_sync, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
357         update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
358                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
359                 short_channel_id: 4,
360                 timestamp: 1,
361                 flags: 0,
362                 cltv_expiry_delta: (4 << 4) | 1,
363                 htlc_minimum_msat: 0,
364                 htlc_maximum_msat: MAX_VALUE_MSAT,
365                 fee_base_msat: 0,
366                 fee_proportional_millionths: 1000000,
367                 excess_data: Vec::new()
368         });
369         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
370                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
371                 short_channel_id: 4,
372                 timestamp: 1,
373                 flags: 1,
374                 cltv_expiry_delta: (4 << 4) | 2,
375                 htlc_minimum_msat: 0,
376                 htlc_maximum_msat: MAX_VALUE_MSAT,
377                 fee_base_msat: 0,
378                 fee_proportional_millionths: 0,
379                 excess_data: Vec::new()
380         });
381
382         add_channel(&gossip_sync, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
383         update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
384                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
385                 short_channel_id: 13,
386                 timestamp: 1,
387                 flags: 0,
388                 cltv_expiry_delta: (13 << 4) | 1,
389                 htlc_minimum_msat: 0,
390                 htlc_maximum_msat: MAX_VALUE_MSAT,
391                 fee_base_msat: 0,
392                 fee_proportional_millionths: 2000000,
393                 excess_data: Vec::new()
394         });
395         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
396                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
397                 short_channel_id: 13,
398                 timestamp: 1,
399                 flags: 1,
400                 cltv_expiry_delta: (13 << 4) | 2,
401                 htlc_minimum_msat: 0,
402                 htlc_maximum_msat: MAX_VALUE_MSAT,
403                 fee_base_msat: 0,
404                 fee_proportional_millionths: 0,
405                 excess_data: Vec::new()
406         });
407
408         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[2], NodeFeatures::from_le_bytes(id_to_feature_flags(3)), 0);
409
410         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
411         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
412                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
413                 short_channel_id: 6,
414                 timestamp: 1,
415                 flags: 0,
416                 cltv_expiry_delta: (6 << 4) | 1,
417                 htlc_minimum_msat: 0,
418                 htlc_maximum_msat: MAX_VALUE_MSAT,
419                 fee_base_msat: 0,
420                 fee_proportional_millionths: 0,
421                 excess_data: Vec::new()
422         });
423         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
424                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
425                 short_channel_id: 6,
426                 timestamp: 1,
427                 flags: 1,
428                 cltv_expiry_delta: (6 << 4) | 2,
429                 htlc_minimum_msat: 0,
430                 htlc_maximum_msat: MAX_VALUE_MSAT,
431                 fee_base_msat: 0,
432                 fee_proportional_millionths: 0,
433                 excess_data: Vec::new(),
434         });
435
436         add_channel(&gossip_sync, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
437         update_channel(&gossip_sync, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
438                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
439                 short_channel_id: 11,
440                 timestamp: 1,
441                 flags: 0,
442                 cltv_expiry_delta: (11 << 4) | 1,
443                 htlc_minimum_msat: 0,
444                 htlc_maximum_msat: MAX_VALUE_MSAT,
445                 fee_base_msat: 0,
446                 fee_proportional_millionths: 0,
447                 excess_data: Vec::new()
448         });
449         update_channel(&gossip_sync, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
450                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
451                 short_channel_id: 11,
452                 timestamp: 1,
453                 flags: 1,
454                 cltv_expiry_delta: (11 << 4) | 2,
455                 htlc_minimum_msat: 0,
456                 htlc_maximum_msat: MAX_VALUE_MSAT,
457                 fee_base_msat: 0,
458                 fee_proportional_millionths: 0,
459                 excess_data: Vec::new()
460         });
461
462         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[4], NodeFeatures::from_le_bytes(id_to_feature_flags(5)), 0);
463
464         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[3], NodeFeatures::from_le_bytes(id_to_feature_flags(4)), 0);
465
466         add_channel(&gossip_sync, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
467         update_channel(&gossip_sync, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
468                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
469                 short_channel_id: 7,
470                 timestamp: 1,
471                 flags: 0,
472                 cltv_expiry_delta: (7 << 4) | 1,
473                 htlc_minimum_msat: 0,
474                 htlc_maximum_msat: MAX_VALUE_MSAT,
475                 fee_base_msat: 0,
476                 fee_proportional_millionths: 1000000,
477                 excess_data: Vec::new()
478         });
479         update_channel(&gossip_sync, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
480                 chain_hash: ChainHash::using_genesis_block(Network::Testnet),
481                 short_channel_id: 7,
482                 timestamp: 1,
483                 flags: 1,
484                 cltv_expiry_delta: (7 << 4) | 2,
485                 htlc_minimum_msat: 0,
486                 htlc_maximum_msat: MAX_VALUE_MSAT,
487                 fee_base_msat: 0,
488                 fee_proportional_millionths: 0,
489                 excess_data: Vec::new()
490         });
491
492         add_or_update_node(&gossip_sync, &secp_ctx, &privkeys[5], NodeFeatures::from_le_bytes(id_to_feature_flags(6)), 0);
493
494         (secp_ctx, network_graph, gossip_sync, chain_monitor, logger)
495 }