5394dd313b06f8bb955aa07a10fabad2b41dda5f
[rust-lightning] / fuzz / src / full_stack.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 //! Test that no series of bytes received over the wire/connections created/payments sent can
11 //! result in a crash. We do this by standing up a node and then reading bytes from input to denote
12 //! actions such as creating new inbound/outbound connections, bytes to be read from a connection,
13 //! or payments to send/ways to handle events generated.
14 //! This test has been very useful, though due to its complexity good starting inputs are critical.
15
16 use bitcoin::amount::Amount;
17 use bitcoin::blockdata::constants::genesis_block;
18 use bitcoin::blockdata::transaction::{Transaction, TxOut};
19 use bitcoin::blockdata::script::{Builder, ScriptBuf};
20 use bitcoin::blockdata::opcodes;
21 use bitcoin::blockdata::locktime::absolute::LockTime;
22 use bitcoin::consensus::encode::deserialize;
23 use bitcoin::network::Network;
24 use bitcoin::transaction::Version;
25
26 use bitcoin::WPubkeyHash;
27 use bitcoin::hashes::hex::FromHex;
28 use bitcoin::hashes::Hash as _;
29 use bitcoin::hashes::sha256::Hash as Sha256;
30 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
31 use bitcoin::hash_types::{Txid, BlockHash};
32
33 use lightning::blinded_path::BlindedPath;
34 use lightning::blinded_path::payment::ReceiveTlvs;
35 use lightning::chain;
36 use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen};
37 use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
38 use lightning::chain::chainmonitor;
39 use lightning::chain::transaction::OutPoint;
40 use lightning::sign::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
41 use lightning::events::Event;
42 use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};
43 use lightning::ln::channel_state::ChannelDetails;
44 use lightning::ln::channelmanager::{ChainParameters, ChannelManager, PaymentId, RecipientOnionFields, Retry, InterceptId};
45 use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
46 use lightning::ln::msgs::{self, DecodeError};
47 use lightning::ln::script::ShutdownScript;
48 use lightning::ln::functional_test_utils::*;
49 use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice};
50 use lightning::offers::invoice_request::UnsignedInvoiceRequest;
51 use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath};
52 use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
53 use lightning::routing::utxo::UtxoLookup;
54 use lightning::routing::router::{InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router};
55 use lightning::util::config::{ChannelConfig, UserConfig};
56 use lightning::util::hash_tables::*;
57 use lightning::util::errors::APIError;
58 use lightning::util::test_channel_signer::{TestChannelSigner, EnforcementState};
59 use lightning::util::logger::Logger;
60 use lightning::util::ser::{Readable, ReadableArgs, Writeable};
61
62 use crate::utils::test_logger;
63 use crate::utils::test_persister::TestPersister;
64
65 use bitcoin::secp256k1::{Message, PublicKey, SecretKey, Scalar, Secp256k1, self};
66 use bitcoin::secp256k1::ecdh::SharedSecret;
67 use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
68 use bitcoin::secp256k1::schnorr;
69
70 use std::cell::RefCell;
71 use std::convert::TryInto;
72 use std::cmp;
73 use std::sync::{Arc, Mutex};
74 use std::sync::atomic::{AtomicU64,AtomicUsize,AtomicBool,Ordering};
75 use bech32::u5;
76
77 #[inline]
78 #[rustfmt::skip]
79 pub fn slice_to_be16(v: &[u8]) -> u16 {
80         ((v[0] as u16) << 8*1) |
81         ((v[1] as u16) << 8*0)
82 }
83
84 #[inline]
85 pub fn be16_to_array(u: u16) -> [u8; 2] {
86         let mut v = [0; 2];
87         v[0] = ((u >> 8*1) & 0xff) as u8;
88         v[1] = ((u >> 8*0) & 0xff) as u8;
89         v
90 }
91
92 #[inline]
93 #[rustfmt::skip]
94 pub fn slice_to_be24(v: &[u8]) -> u32 {
95         ((v[0] as u32) << 8*2) |
96         ((v[1] as u32) << 8*1) |
97         ((v[2] as u32) << 8*0)
98 }
99
100 struct InputData {
101         data: Vec<u8>,
102         read_pos: AtomicUsize,
103         halt_fee_est_reads: AtomicBool,
104 }
105 impl InputData {
106         fn get_slice(&self, len: usize) -> Option<&[u8]> {
107                 let old_pos = self.read_pos.fetch_add(len, Ordering::AcqRel);
108                 if self.data.len() < old_pos + len {
109                         return None;
110                 }
111                 Some(&self.data[old_pos..old_pos + len])
112         }
113 }
114 impl std::io::Read for &InputData {
115         fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
116                 if let Some(sl) = self.get_slice(buf.len()) {
117                         buf.copy_from_slice(sl);
118                         Ok(buf.len())
119                 } else {
120                         Ok(0)
121                 }
122         }
123 }
124
125 struct FuzzEstimator {
126         input: Arc<InputData>,
127 }
128 impl FeeEstimator for FuzzEstimator {
129         fn get_est_sat_per_1000_weight(&self, _: ConfirmationTarget) -> u32 {
130                 if self.input.halt_fee_est_reads.load(Ordering::Acquire) {
131                         return 253;
132                 }
133                 //TODO: We should actually be testing at least much more than 64k...
134                 match self.input.get_slice(2) {
135                         Some(slice) => cmp::max(slice_to_be16(slice) as u32, 253),
136                         None => 253
137                 }
138         }
139 }
140
141 struct FuzzRouter {}
142
143 impl Router for FuzzRouter {
144         fn find_route(
145                 &self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>,
146                 _inflight_htlcs: InFlightHtlcs
147         ) -> Result<Route, msgs::LightningError> {
148                 Err(msgs::LightningError {
149                         err: String::from("Not implemented"),
150                         action: msgs::ErrorAction::IgnoreError
151                 })
152         }
153
154         fn create_blinded_payment_paths<T: secp256k1::Signing + secp256k1::Verification>(
155                 &self, _recipient: PublicKey, _first_hops: Vec<ChannelDetails>, _tlvs: ReceiveTlvs,
156                 _amount_msats: u64, _secp_ctx: &Secp256k1<T>,
157         ) -> Result<Vec<(BlindedPayInfo, BlindedPath)>, ()> {
158                 unreachable!()
159         }
160 }
161
162 impl MessageRouter for FuzzRouter {
163         fn find_path(
164                 &self, _sender: PublicKey, _peers: Vec<PublicKey>, _destination: Destination
165         ) -> Result<OnionMessagePath, ()> {
166                 unreachable!()
167         }
168
169         fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
170                 &self, _recipient: PublicKey, _peers: Vec<PublicKey>, _secp_ctx: &Secp256k1<T>,
171         ) -> Result<Vec<BlindedPath>, ()> {
172                 unreachable!()
173         }
174 }
175
176 struct TestBroadcaster {
177         txn_broadcasted: Mutex<Vec<Transaction>>,
178 }
179 impl BroadcasterInterface for TestBroadcaster {
180         fn broadcast_transactions(&self, txs: &[&Transaction]) {
181                 let owned_txs: Vec<Transaction> = txs.iter().map(|tx| (*tx).clone()).collect();
182                 self.txn_broadcasted.lock().unwrap().extend(owned_txs);
183         }
184 }
185
186 #[derive(Clone)]
187 struct Peer<'a> {
188         id: u8,
189         peers_connected: &'a RefCell<[bool; 256]>,
190 }
191 impl<'a> SocketDescriptor for Peer<'a> {
192         fn send_data(&mut self, data: &[u8], _resume_read: bool) -> usize {
193                 data.len()
194         }
195         fn disconnect_socket(&mut self) {
196                 assert!(self.peers_connected.borrow()[self.id as usize]);
197                 self.peers_connected.borrow_mut()[self.id as usize] = false;
198         }
199 }
200 impl<'a> PartialEq for Peer<'a> {
201         fn eq(&self, other: &Self) -> bool {
202                 self.id == other.id
203         }
204 }
205 impl<'a> Eq for Peer<'a> {}
206 impl<'a> std::hash::Hash for Peer<'a> {
207         fn hash<H : std::hash::Hasher>(&self, h: &mut H) {
208                 self.id.hash(h)
209         }
210 }
211
212 type ChannelMan<'a> = ChannelManager<
213         Arc<chainmonitor::ChainMonitor<TestChannelSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
214         Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<KeyProvider>, Arc<KeyProvider>, Arc<FuzzEstimator>, &'a FuzzRouter, Arc<dyn Logger>>;
215 type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan<'a>>, Arc<P2PGossipSync<Arc<NetworkGraph<Arc<dyn Logger>>>, Arc<dyn UtxoLookup>, Arc<dyn Logger>>>, IgnoringMessageHandler, Arc<dyn Logger>, IgnoringMessageHandler, Arc<KeyProvider>>;
216
217 struct MoneyLossDetector<'a> {
218         manager: Arc<ChannelMan<'a>>,
219         monitor: Arc<chainmonitor::ChainMonitor<TestChannelSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
220         handler: PeerMan<'a>,
221
222         peers: &'a RefCell<[bool; 256]>,
223         funding_txn: Vec<Transaction>,
224         txids_confirmed: HashMap<Txid, usize>,
225         header_hashes: Vec<(BlockHash, u32)>,
226         height: usize,
227         max_height: usize,
228         blocks_connected: u32,
229         error_message: String,
230 }
231 impl<'a> MoneyLossDetector<'a> {
232         pub fn new(peers: &'a RefCell<[bool; 256]>,
233                    manager: Arc<ChannelMan<'a>>,
234                    monitor: Arc<chainmonitor::ChainMonitor<TestChannelSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
235                    handler: PeerMan<'a>) -> Self {
236                 MoneyLossDetector {
237                         manager,
238                         monitor,
239                         handler,
240
241                         peers,
242                         funding_txn: Vec::new(),
243                         txids_confirmed: new_hash_map(),
244                         header_hashes: vec![(genesis_block(Network::Bitcoin).block_hash(), 0)],
245                         height: 0,
246                         max_height: 0,
247                         blocks_connected: 0,
248                         error_message: "Channel force-closed".to_string(),
249                 }
250         }
251
252         fn connect_block(&mut self, all_txn: &[Transaction]) {
253                 let mut txdata = Vec::with_capacity(all_txn.len());
254                 for (idx, tx) in all_txn.iter().enumerate() {
255                         let txid = tx.txid();
256                         self.txids_confirmed.entry(txid).or_insert_with(|| {
257                                 txdata.push((idx + 1, tx));
258                                 self.height
259                         });
260                 }
261
262                 self.blocks_connected += 1;
263                 let header = create_dummy_header(self.header_hashes[self.height].0, self.blocks_connected);
264                 self.height += 1;
265                 self.manager.transactions_confirmed(&header, &txdata, self.height as u32);
266                 self.manager.best_block_updated(&header, self.height as u32);
267                 (*self.monitor).transactions_confirmed(&header, &txdata, self.height as u32);
268                 (*self.monitor).best_block_updated(&header, self.height as u32);
269                 if self.header_hashes.len() > self.height {
270                         self.header_hashes[self.height] = (header.block_hash(), self.blocks_connected);
271                 } else {
272                         assert_eq!(self.header_hashes.len(), self.height);
273                         self.header_hashes.push((header.block_hash(), self.blocks_connected));
274                 }
275                 self.max_height = cmp::max(self.height, self.max_height);
276         }
277
278         fn disconnect_block(&mut self) {
279                 if self.height > 0 && (self.max_height < 6 || self.height >= self.max_height - 6) {
280                         let header = create_dummy_header(self.header_hashes[self.height - 1].0, self.header_hashes[self.height].1);
281                         self.manager.block_disconnected(&header, self.height as u32);
282                         self.monitor.block_disconnected(&header, self.height as u32);
283                         self.height -= 1;
284                         let removal_height = self.height;
285                         self.txids_confirmed.retain(|_, height| {
286                                 removal_height != *height
287                         });
288                 }
289         }
290 }
291
292 impl<'a> Drop for MoneyLossDetector<'a> {
293         fn drop(&mut self) {
294                 if !::std::thread::panicking() {
295                         // Disconnect all peers
296                         for (idx, peer) in self.peers.borrow().iter().enumerate() {
297                                 if *peer {
298                                         self.handler.socket_disconnected(&Peer{id: idx as u8, peers_connected: &self.peers});
299                                 }
300                         }
301
302                         // Force all channels onto the chain (and time out claim txn)
303                         self.manager.force_close_all_channels_broadcasting_latest_txn(self.error_message.to_string());
304                 }
305         }
306 }
307
308 struct KeyProvider {
309         node_secret: SecretKey,
310         inbound_payment_key: KeyMaterial,
311         counter: AtomicU64,
312         signer_state: RefCell<HashMap<u8, (bool, Arc<Mutex<EnforcementState>>)>>
313 }
314
315 impl EntropySource for KeyProvider {
316         fn get_secure_random_bytes(&self) -> [u8; 32] {
317                 let ctr = self.counter.fetch_add(1, Ordering::Relaxed);
318                 #[rustfmt::skip]
319                 let random_bytes = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
320                         (ctr >> 8*7) as u8, (ctr >> 8*6) as u8, (ctr >> 8*5) as u8, (ctr >> 8*4) as u8,
321                         (ctr >> 8*3) as u8, (ctr >> 8*2) as u8, (ctr >> 8*1) as u8, 14, (ctr >> 8*0) as u8];
322                 random_bytes
323         }
324 }
325
326 impl NodeSigner for KeyProvider {
327         fn get_node_id(&self, recipient: Recipient) -> Result<PublicKey, ()> {
328                 let node_secret = match recipient {
329                         Recipient::Node => Ok(&self.node_secret),
330                         Recipient::PhantomNode => Err(())
331                 }?;
332                 Ok(PublicKey::from_secret_key(&Secp256k1::signing_only(), node_secret))
333         }
334
335         fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&Scalar>) -> Result<SharedSecret, ()> {
336                 let mut node_secret = match recipient {
337                         Recipient::Node => Ok(self.node_secret.clone()),
338                         Recipient::PhantomNode => Err(())
339                 }?;
340                 if let Some(tweak) = tweak {
341                         node_secret = node_secret.mul_tweak(tweak).map_err(|_| ())?;
342                 }
343                 Ok(SharedSecret::new(other_key, &node_secret))
344         }
345
346         fn get_inbound_payment_key_material(&self) -> KeyMaterial {
347                 self.inbound_payment_key.clone()
348         }
349
350         fn sign_invoice(&self, _hrp_bytes: &[u8], _invoice_data: &[u5], _recipient: Recipient) -> Result<RecoverableSignature, ()> {
351                 unreachable!()
352         }
353
354         fn sign_bolt12_invoice_request(
355                 &self, _invoice_request: &UnsignedInvoiceRequest
356         ) -> Result<schnorr::Signature, ()> {
357                 unreachable!()
358         }
359
360         fn sign_bolt12_invoice(
361                 &self, _invoice: &UnsignedBolt12Invoice,
362         ) -> Result<schnorr::Signature, ()> {
363                 unreachable!()
364         }
365
366         fn sign_gossip_message(&self, msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result<Signature, ()> {
367                 let msg_hash = Message::from_digest(Sha256dHash::hash(&msg.encode()[..]).to_byte_array());
368                 let secp_ctx = Secp256k1::signing_only();
369                 Ok(secp_ctx.sign_ecdsa(&msg_hash, &self.node_secret))
370         }
371 }
372
373 impl SignerProvider for KeyProvider {
374         type EcdsaSigner = TestChannelSigner;
375         #[cfg(taproot)]
376         type TaprootSigner = TestChannelSigner;
377
378         fn generate_channel_keys_id(&self, inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] {
379                 let ctr = self.counter.fetch_add(1, Ordering::Relaxed) as u8;
380                 self.signer_state.borrow_mut().insert(ctr, (inbound, Arc::new(Mutex::new(EnforcementState::new()))));
381                 [ctr; 32]
382         }
383
384         fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::EcdsaSigner {
385                 let secp_ctx = Secp256k1::signing_only();
386                 let ctr = channel_keys_id[0];
387                 let (inbound, state) = self.signer_state.borrow().get(&ctr).unwrap().clone();
388                 TestChannelSigner::new_with_revoked(if inbound {
389                         InMemorySigner::new(
390                                 &secp_ctx,
391                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ctr]).unwrap(),
392                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, ctr]).unwrap(),
393                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, ctr]).unwrap(),
394                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, ctr]).unwrap(),
395                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, ctr]).unwrap(),
396                                 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, ctr],
397                                 channel_value_satoshis,
398                                 channel_keys_id,
399                                 channel_keys_id,
400                         )
401                 } else {
402                         InMemorySigner::new(
403                                 &secp_ctx,
404                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, ctr]).unwrap(),
405                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, ctr]).unwrap(),
406                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, ctr]).unwrap(),
407                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, ctr]).unwrap(),
408                                 SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, ctr]).unwrap(),
409                                 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, ctr],
410                                 channel_value_satoshis,
411                                 channel_keys_id,
412                                 channel_keys_id,
413                         )
414                 }, state, false)
415         }
416
417         fn read_chan_signer(&self, mut data: &[u8]) -> Result<TestChannelSigner, DecodeError> {
418                 let inner: InMemorySigner = ReadableArgs::read(&mut data, self)?;
419                 let state = Arc::new(Mutex::new(EnforcementState::new()));
420
421                 Ok(TestChannelSigner::new_with_revoked(
422                         inner,
423                         state,
424                         false
425                 ))
426         }
427
428         fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
429                 let secp_ctx = Secp256k1::signing_only();
430                 let channel_monitor_claim_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
431                 let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
432                 Ok(Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(our_channel_monitor_claim_key_hash).into_script())
433         }
434
435         fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
436                 let secp_ctx = Secp256k1::signing_only();
437                 let secret_key = SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]).unwrap();
438                 let pubkey_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &secret_key).serialize());
439                 Ok(ShutdownScript::new_p2wpkh(&pubkey_hash))
440         }
441 }
442
443 #[inline]
444 pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
445         if data.len() < 32 { return; }
446
447         let our_network_key = match SecretKey::from_slice(&data[..32]) {
448                 Ok(key) => key,
449                 Err(_) => return,
450         };
451         data = &data[32..];
452
453         let config: UserConfig = if let Ok(config) = Readable::read(&mut data) { config } else { return; };
454
455         let input = Arc::new(InputData {
456                 data: data.to_vec(),
457                 read_pos: AtomicUsize::new(0),
458                 halt_fee_est_reads: AtomicBool::new(false),
459         });
460         let fee_est = Arc::new(FuzzEstimator {
461                 input: input.clone(),
462         });
463         let router = FuzzRouter {};
464
465         macro_rules! get_slice {
466                 ($len: expr) => {
467                         match input.get_slice($len as usize) {
468                                 Some(slice) => slice,
469                                 None => return,
470                         }
471                 }
472         }
473
474         macro_rules! get_bytes {
475                 ($len: expr) => { {
476                         let mut res = [0; $len];
477                         match input.get_slice($len as usize) {
478                                 Some(slice) => res.copy_from_slice(slice),
479                                 None => return,
480                         }
481                         res
482                 } }
483         }
484
485         macro_rules! get_pubkey {
486                 () => {
487                         match PublicKey::from_slice(get_slice!(33)) {
488                                 Ok(key) => key,
489                                 Err(_) => return,
490                         }
491                 }
492         }
493
494
495         let inbound_payment_key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42];
496
497         let broadcast = Arc::new(TestBroadcaster{ txn_broadcasted: Mutex::new(Vec::new()) });
498         let monitor = Arc::new(chainmonitor::ChainMonitor::new(None, broadcast.clone(), Arc::clone(&logger), fee_est.clone(),
499                 Arc::new(TestPersister { update_ret: Mutex::new(ChannelMonitorUpdateStatus::Completed) })));
500
501         let keys_manager = Arc::new(KeyProvider {
502                 node_secret: our_network_key.clone(),
503                 inbound_payment_key: KeyMaterial(inbound_payment_key.try_into().unwrap()),
504                 counter: AtomicU64::new(0),
505                 signer_state: RefCell::new(new_hash_map())
506         });
507         let network = Network::Bitcoin;
508         let best_block_timestamp = genesis_block(network).header.time;
509         let params = ChainParameters {
510                 network,
511                 best_block: BestBlock::from_network(network),
512         };
513         let channelmanager = Arc::new(ChannelManager::new(fee_est.clone(), monitor.clone(), broadcast.clone(), &router, Arc::clone(&logger), keys_manager.clone(), keys_manager.clone(), keys_manager.clone(), config, params, best_block_timestamp));
514         // Adding new calls to `EntropySource::get_secure_random_bytes` during startup can change all the
515         // keys subsequently generated in this test. Rather than regenerating all the messages manually,
516         // it's easier to just increment the counter here so the keys don't change.
517         keys_manager.counter.fetch_sub(3, Ordering::AcqRel);
518         let network_graph = Arc::new(NetworkGraph::new(network, Arc::clone(&logger)));
519         let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
520
521         let peers = RefCell::new([false; 256]);
522         let message_handler = MessageHandler {
523                 chan_handler: channelmanager.clone(),
524                 route_handler: gossip_sync.clone(),
525                 onion_message_handler: IgnoringMessageHandler {},
526                 custom_message_handler: IgnoringMessageHandler {},
527         };
528         let random_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0];
529         let peer_manager = PeerManager::new(message_handler, 0, &random_data, Arc::clone(&logger), keys_manager.clone());
530         let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), peer_manager);
531
532         let mut should_forward = false;
533         let mut payments_received: Vec<PaymentHash> = Vec::new();
534         let mut intercepted_htlcs: Vec<InterceptId> = Vec::new();
535         let mut payments_sent: u16 = 0;
536         let mut pending_funding_generation: Vec<(ChannelId, PublicKey, u64, ScriptBuf)> = Vec::new();
537         let mut pending_funding_signatures = new_hash_map();
538
539         loop {
540                 match get_slice!(1)[0] {
541                         0 => {
542                                 let mut new_id = 0;
543                                 for i in 1..256 {
544                                         if !peers.borrow()[i-1] {
545                                                 new_id = i;
546                                                 break;
547                                         }
548                                 }
549                                 if new_id == 0 { return; }
550                                 let peer = Peer{id: (new_id - 1) as u8, peers_connected: &peers};
551                                 loss_detector.handler.new_outbound_connection(get_pubkey!(), peer, None).unwrap();
552                                 peers.borrow_mut()[new_id - 1] = true;
553                         },
554                         1 => {
555                                 let mut new_id = 0;
556                                 for i in 1..256 {
557                                         if !peers.borrow()[i-1] {
558                                                 new_id = i;
559                                                 break;
560                                         }
561                                 }
562                                 if new_id == 0 { return; }
563                                 let peer = Peer{id: (new_id - 1) as u8, peers_connected: &peers};
564                                 loss_detector.handler.new_inbound_connection(peer, None).unwrap();
565                                 peers.borrow_mut()[new_id - 1] = true;
566                         },
567                         2 => {
568                                 let peer_id = get_slice!(1)[0];
569                                 if !peers.borrow()[peer_id as usize] { return; }
570                                 let peer = Peer{id: peer_id, peers_connected: &peers};
571                                 loss_detector.handler.socket_disconnected(&peer);
572                                 peers.borrow_mut()[peer_id as usize] = false;
573                         },
574                         3 => {
575                                 let peer_id = get_slice!(1)[0];
576                                 if !peers.borrow()[peer_id as usize] { return; }
577                                 let mut peer = Peer{id: peer_id, peers_connected: &peers};
578                                 match loss_detector.handler.read_event(&mut peer, get_slice!(get_slice!(1)[0])) {
579                                         Ok(res) => assert!(!res),
580                                         Err(_) => { peers.borrow_mut()[peer_id as usize] = false; }
581                                 }
582                         },
583                         4 => {
584                                 let final_value_msat = slice_to_be24(get_slice!(3)) as u64;
585                                 let payment_params = PaymentParameters::from_node_id(get_pubkey!(), 42);
586                                 let params = RouteParameters::from_payment_params_and_value(
587                                         payment_params, final_value_msat);
588                                 let mut payment_hash = PaymentHash([0; 32]);
589                                 payment_hash.0[0..2].copy_from_slice(&be16_to_array(payments_sent));
590                                 payment_hash.0 = Sha256::hash(&payment_hash.0[..]).to_byte_array();
591                                 payments_sent += 1;
592                                 let _ = channelmanager.send_payment(
593                                         payment_hash, RecipientOnionFields::spontaneous_empty(),
594                                         PaymentId(payment_hash.0), params, Retry::Attempts(2)
595                                 );
596                         },
597                         15 => {
598                                 let final_value_msat = slice_to_be24(get_slice!(3)) as u64;
599                                 let payment_params = PaymentParameters::from_node_id(get_pubkey!(), 42);
600                                 let params = RouteParameters::from_payment_params_and_value(
601                                         payment_params, final_value_msat);
602                                 let mut payment_hash = PaymentHash([0; 32]);
603                                 payment_hash.0[0..2].copy_from_slice(&be16_to_array(payments_sent));
604                                 payment_hash.0 = Sha256::hash(&payment_hash.0[..]).to_byte_array();
605                                 payments_sent += 1;
606                                 let mut payment_secret = PaymentSecret([0; 32]);
607                                 payment_secret.0[0..2].copy_from_slice(&be16_to_array(payments_sent));
608                                 payments_sent += 1;
609                                 let _ = channelmanager.send_payment(
610                                         payment_hash, RecipientOnionFields::secret_only(payment_secret),
611                                         PaymentId(payment_hash.0), params, Retry::Attempts(2)
612                                 );
613                         },
614                         17 => {
615                                 let final_value_msat = slice_to_be24(get_slice!(3)) as u64;
616                                 let payment_params = PaymentParameters::from_node_id(get_pubkey!(), 42);
617                                 let params = RouteParameters::from_payment_params_and_value(
618                                         payment_params, final_value_msat);
619                                 let _ = channelmanager.send_preflight_probes(params, None);
620                         },
621                         18 => {
622                                 let idx = u16::from_be_bytes(get_bytes!(2)) % cmp::max(payments_sent, 1);
623                                 let mut payment_id = PaymentId([0; 32]);
624                                 payment_id.0[0..2].copy_from_slice(&idx.to_be_bytes());
625                                 channelmanager.abandon_payment(payment_id);
626                         },
627                         5 => {
628                                 let peer_id = get_slice!(1)[0];
629                                 if !peers.borrow()[peer_id as usize] { return; }
630                                 let their_key = get_pubkey!();
631                                 let chan_value = slice_to_be24(get_slice!(3)) as u64;
632                                 let push_msat_value = slice_to_be24(get_slice!(3)) as u64;
633                                 if channelmanager.create_channel(their_key, chan_value, push_msat_value, 0, None, None).is_err() { return; }
634                         },
635                         6 => {
636                                 let mut channels = channelmanager.list_channels();
637                                 let channel_id = get_slice!(1)[0] as usize;
638                                 if channel_id >= channels.len() { return; }
639                                 channels.sort_by(|a, b| { a.channel_id.cmp(&b.channel_id) });
640                                 if channelmanager.close_channel(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id).is_err() { return; }
641                         },
642                         7 => {
643                                 if should_forward {
644                                         channelmanager.process_pending_htlc_forwards();
645                                         should_forward = false;
646                                 }
647                         },
648                         8 => {
649                                 for payment in payments_received.drain(..) {
650                                         // SHA256 is defined as XOR of all input bytes placed in the first byte, and 0s
651                                         // for the remaining bytes. Thus, if not all remaining bytes are 0s we cannot
652                                         // fulfill this HTLC, but if they are, we can just take the first byte and
653                                         // place that anywhere in our preimage.
654                                         if &payment.0[1..] != &[0; 31] {
655                                                 channelmanager.fail_htlc_backwards(&payment);
656                                         } else {
657                                                 let mut payment_preimage = PaymentPreimage([0; 32]);
658                                                 payment_preimage.0[0] = payment.0[0];
659                                                 channelmanager.claim_funds(payment_preimage);
660                                         }
661                                 }
662                         },
663                         16 => {
664                                 let payment_preimage = PaymentPreimage(keys_manager.get_secure_random_bytes());
665                                 let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).to_byte_array());
666                                 // Note that this may fail - our hashes may collide and we'll end up trying to
667                                 // double-register the same payment_hash.
668                                 let _ = channelmanager.create_inbound_payment_for_hash(payment_hash, None, 1, None);
669                         },
670                         9 => {
671                                 for payment in payments_received.drain(..) {
672                                         channelmanager.fail_htlc_backwards(&payment);
673                                 }
674                         },
675                         10 => {
676                                 let mut tx = Transaction { version: Version(0), lock_time: LockTime::ZERO, input: Vec::new(), output: Vec::new() };
677                                 let mut channels = Vec::new();
678                                 for funding_generation in pending_funding_generation.drain(..) {
679                                         let txout = TxOut {
680                                                 value: Amount::from_sat(funding_generation.2), script_pubkey: funding_generation.3,
681                                         };
682                                         if !tx.output.contains(&txout) {
683                                                 tx.output.push(txout);
684                                                 channels.push((funding_generation.0, funding_generation.1));
685                                         }
686                                 }
687                                 // Once we switch to V2 channel opens we should be able to drop this entirely as
688                                 // channel_ids no longer change when we set the funding tx.
689                                 'search_loop: loop {
690                                         if tx.version.0 > 0xff {
691                                                 break;
692                                         }
693                                         let funding_txid = tx.txid();
694                                         if loss_detector.txids_confirmed.get(&funding_txid).is_none() {
695                                                 let outpoint = OutPoint { txid: funding_txid, index: 0 };
696                                                 for chan in channelmanager.list_channels() {
697                                                         if chan.channel_id == ChannelId::v1_from_funding_outpoint(outpoint) {
698                                                                 tx.version = Version(tx.version.0 + 1);
699                                                                 continue 'search_loop;
700                                                         }
701                                                 }
702                                                 break;
703                                         }
704                                         tx.version = Version(tx.version.0 + 1);
705                                 }
706                                 if tx.version.0 <= 0xff && !channels.is_empty() {
707                                         let chans = channels.iter().map(|(a, b)| (a, b)).collect::<Vec<_>>();
708                                         if let Err(e) = channelmanager.batch_funding_transaction_generated(&chans, tx.clone()) {
709                                                 // It's possible the channel has been closed in the mean time, but any other
710                                                 // failure may be a bug.
711                                                 if let APIError::ChannelUnavailable { .. } = e { } else { panic!(); }
712                                         }
713                                         let funding_txid = tx.txid();
714                                         for idx in 0..tx.output.len() {
715                                                 let outpoint = OutPoint { txid: funding_txid, index: idx as u16 };
716                                                 pending_funding_signatures.insert(outpoint, tx.clone());
717                                         }
718                                 }
719                         },
720                         11 => {
721                                 let mut txn = broadcast.txn_broadcasted.lock().unwrap().split_off(0);
722                                 if !txn.is_empty() {
723                                         input.halt_fee_est_reads.store(true, Ordering::Release);
724                                         loss_detector.connect_block(&txn[..]);
725                                         for _ in 2..100 {
726                                                 loss_detector.connect_block(&[]);
727                                         }
728                                         input.halt_fee_est_reads.store(false, Ordering::Release);
729                                 }
730                                 for tx in txn.drain(..) {
731                                         loss_detector.funding_txn.push(tx);
732                                 }
733                         },
734                         12 => {
735                                 let txlen = u16::from_be_bytes(get_bytes!(2));
736                                 if txlen == 0 {
737                                         loss_detector.connect_block(&[]);
738                                 } else {
739                                         let txres: Result<Transaction, _> = deserialize(get_slice!(txlen));
740                                         if let Ok(tx) = txres {
741                                                 let mut output_val = Amount::ZERO;
742                                                 for out in tx.output.iter() {
743                                                         if out.value > Amount::MAX_MONEY { return; }
744                                                         output_val += out.value;
745                                                         if output_val > Amount::MAX_MONEY { return; }
746                                                 }
747                                                 loss_detector.connect_block(&[tx]);
748                                         } else {
749                                                 return;
750                                         }
751                                 }
752                         },
753                         13 => {
754                                 loss_detector.disconnect_block();
755                         },
756                         14 => {
757                                 let mut channels = channelmanager.list_channels();
758                                 let channel_id = get_slice!(1)[0] as usize;
759                                 let error_message = "Channel force-closed";
760                                 if channel_id >= channels.len() { return; }
761                                 channels.sort_by(|a, b| { a.channel_id.cmp(&b.channel_id) });
762                                 channelmanager.force_close_broadcasting_latest_txn(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id, error_message.to_string()).unwrap();
763                         },
764                         // 15, 16, 17, 18 is above
765                         19 => {
766                                 let mut list = loss_detector.handler.list_peers();
767                                 list.sort_by_key(|v| v.counterparty_node_id);
768                                 if let Some(peer_details) = list.get(0) {
769                                         loss_detector.handler.disconnect_by_node_id(peer_details.counterparty_node_id);
770                                 }
771                         },
772                         20 => loss_detector.handler.disconnect_all_peers(),
773                         21 => loss_detector.handler.timer_tick_occurred(),
774                         22 =>
775                                 loss_detector.handler.broadcast_node_announcement([42; 3], [43; 32], Vec::new()),
776                         32 => channelmanager.timer_tick_occurred(),
777                         33 => {
778                                 for id in intercepted_htlcs.drain(..) {
779                                         channelmanager.fail_intercepted_htlc(id).unwrap();
780                                 }
781                         }
782                         34 => {
783                                 let amt = u64::from_be_bytes(get_bytes!(8));
784                                 let chans = channelmanager.list_channels();
785                                 for id in intercepted_htlcs.drain(..) {
786                                         if chans.is_empty() {
787                                                 channelmanager.fail_intercepted_htlc(id).unwrap();
788                                         } else {
789                                                 let chan = &chans[amt as usize % chans.len()];
790                                                 channelmanager.forward_intercepted_htlc(id, &chan.channel_id, chan.counterparty.node_id, amt).unwrap();
791                                         }
792                                 }
793                         }
794                         35 => {
795                                 let config: ChannelConfig =
796                                         if let Ok(c) = Readable::read(&mut &*input) { c } else { return; };
797                                 let chans = channelmanager.list_channels();
798                                 if let Some(chan) = chans.get(0) {
799                                         let _ = channelmanager.update_channel_config(
800                                                 &chan.counterparty.node_id, &[chan.channel_id], &config
801                                         );
802                                 }
803                         }
804                         _ => return,
805                 }
806                 loss_detector.handler.process_events();
807                 for event in loss_detector.manager.get_and_clear_pending_events() {
808                         match event {
809                                 Event::FundingGenerationReady { temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, .. } => {
810                                         pending_funding_generation.push((temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script));
811                                 },
812                                 Event::PaymentClaimable { payment_hash, .. } => {
813                                         //TODO: enhance by fetching random amounts from fuzz input?
814                                         payments_received.push(payment_hash);
815                                 },
816                                 Event::PendingHTLCsForwardable {..} => {
817                                         should_forward = true;
818                                 },
819                                 Event::HTLCIntercepted { intercept_id, .. } => {
820                                         if !intercepted_htlcs.contains(&intercept_id) {
821                                                 intercepted_htlcs.push(intercept_id);
822                                         }
823                                 },
824                                 _ => {},
825                         }
826                 }
827         }
828 }
829
830 pub fn full_stack_test<Out: test_logger::Output>(data: &[u8], out: Out) {
831         let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new("".to_owned(), out));
832         do_test(data, &logger);
833 }
834
835 #[no_mangle]
836 pub extern "C" fn full_stack_run(data: *const u8, datalen: usize) {
837         let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new("".to_owned(), test_logger::DevNull {}));
838         do_test(unsafe { std::slice::from_raw_parts(data, datalen) }, &logger);
839 }
840
841 #[cfg(test)]
842 mod tests {
843         use bitcoin::hashes::hex::FromHex;
844         use lightning::util::logger::{Logger, Record};
845         use std::collections::HashMap;
846         use std::sync::{Arc, Mutex};
847
848         struct TrackingLogger {
849                 /// (module, message) -> count
850                 pub lines: Mutex<HashMap<(String, String), usize>>,
851         }
852         impl Logger for TrackingLogger {
853                 fn log(&self, record: Record) {
854                         *self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
855                         println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
856                 }
857         }
858
859         fn ext_from_hex(hex_with_spaces: &str, out: &mut Vec<u8>) {
860                 for hex in hex_with_spaces.split(" ") {
861                         out.append(&mut <Vec<u8>>::from_hex(hex).unwrap());
862                 }
863         }
864
865         #[test]
866         fn test_no_existing_test_breakage() {
867                 // To avoid accidentally causing all existing fuzz test cases to be useless by making minor
868                 // changes (such as requesting feerate info in a new place), we run a pretty full
869                 // step-through with two peers and HTLC forwarding here. Obviously this is pretty finicky,
870                 // so this should be updated pretty liberally, but at least we'll know when changes occur.
871                 // If nothing else, this test serves as a pretty great initial full_stack_target seed.
872
873                 // Following BOLT 8, lightning message on the wire are: 2-byte encrypted message length +
874                 // 16-byte MAC of the encrypted message length + encrypted Lightning message + 16-byte MAC
875                 // of the Lightning message
876                 // I.e 2nd inbound read, len 18 : 0006 (encrypted message length) + 03000000000000000000000000000000 (MAC of the encrypted message length)
877                 // Len 22 : 0010 00000000 (encrypted lightning message) + 03000000000000000000000000000000 (MAC of the Lightning message)
878
879                 // Writing new code generating transactions and see a new failure ? Don't forget to add input for the FuzzEstimator !
880
881                 let mut test = Vec::new();
882                 // our network key
883                 ext_from_hex("0100000000000000000000000000000000000000000000000000000000000000", &mut test);
884                 // config
885                 ext_from_hex("0000000000900000000000000000640001000000000001ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000", &mut test);
886
887                 // new outbound connection with id 0
888                 ext_from_hex("00", &mut test);
889                 // peer's pubkey
890                 ext_from_hex("030000000000000000000000000000000000000000000000000000000000000002", &mut test);
891                 // inbound read from peer id 0 of len 50
892                 ext_from_hex("030032", &mut test);
893                 // noise act two (0||pubkey||mac)
894                 ext_from_hex("00 030000000000000000000000000000000000000000000000000000000000000002 03000000000000000000000000000000", &mut test);
895
896                 // inbound read from peer id 0 of len 18
897                 ext_from_hex("030012", &mut test);
898                 // message header indicating message length 16
899                 ext_from_hex("0010 03000000000000000000000000000000", &mut test);
900                 // inbound read from peer id 0 of len 32
901                 ext_from_hex("030020", &mut test);
902                 // init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
903                 ext_from_hex("0010 00021aaa 0008aaa20aaa2a0a9aaa 03000000000000000000000000000000", &mut test);
904
905                 // inbound read from peer id 0 of len 18
906                 ext_from_hex("030012", &mut test);
907                 // message header indicating message length 327
908                 ext_from_hex("0147 03000000000000000000000000000000", &mut test);
909                 // inbound read from peer id 0 of len 254
910                 ext_from_hex("0300fe", &mut test);
911                 // beginning of open_channel message
912                 ext_from_hex("0020 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679 000000000000c350 0000000000000000 0000000000000162 ffffffffffffffff 0000000000000222 0000000000000000 000000fd 0006 01e3 030000000000000000000000000000000000000000000000000000000000000001 030000000000000000000000000000000000000000000000000000000000000002 030000000000000000000000000000000000000000000000000000000000000003 030000000000000000000000000000000000000000000000000000000000000004", &mut test);
913                 // inbound read from peer id 0 of len 89
914                 ext_from_hex("030059", &mut test);
915                 // rest of open_channel and mac
916                 ext_from_hex("030000000000000000000000000000000000000000000000000000000000000005 020900000000000000000000000000000000000000000000000000000000000000 01 0000 01021000 03000000000000000000000000000000", &mut test);
917
918                 // One feerate request returning min feerate, which our open_channel also uses (ingested by FuzzEstimator)
919                 ext_from_hex("00fd", &mut test);
920                 // client should now respond with accept_channel (CHECK 1: type 33 to peer 03000000)
921
922                 // inbound read from peer id 0 of len 18
923                 ext_from_hex("030012", &mut test);
924                 // message header indicating message length 132
925                 ext_from_hex("0084 03000000000000000000000000000000", &mut test);
926                 // inbound read from peer id 0 of len 148
927                 ext_from_hex("030094", &mut test);
928                 // funding_created and mac
929                 ext_from_hex("0022 ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679 3d00000000000000000000000000000000000000000000000000000000000000 0000 00000000000000000000000000000000000000000000000000000000000000210100000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
930                 // client should now respond with funding_signed (CHECK 2: type 35 to peer 03000000)
931
932                 // connect a block with one transaction of len 94
933                 ext_from_hex("0c005e", &mut test);
934                 // the funding transaction
935                 ext_from_hex("020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0150c3000000000000220020ae0000000000000000000000000000000000000000000000000000000000000000000000", &mut test);
936                 // Two feerate requests during block connection
937                 ext_from_hex("00fd00fd", &mut test);
938                 // connect a block with no transactions, one per line
939                 ext_from_hex("0c0000", &mut test);
940                 // Two feerate requests during block connection
941                 ext_from_hex("00fd00fd", &mut test);
942                 ext_from_hex("0c0000", &mut test);
943                 // Two feerate requests during block connection
944                 ext_from_hex("00fd00fd", &mut test);
945                 ext_from_hex("0c0000", &mut test);
946                 // Two feerate requests during block connection
947                 ext_from_hex("00fd00fd", &mut test);
948                 ext_from_hex("0c0000", &mut test);
949                 // Two feerate requests during block connection
950                 ext_from_hex("00fd00fd", &mut test);
951                 ext_from_hex("0c0000", &mut test);
952                 // Two feerate requests during block connection
953                 ext_from_hex("00fd00fd", &mut test);
954                 ext_from_hex("0c0000", &mut test);
955                 // Two feerate requests during block connection
956                 ext_from_hex("00fd00fd", &mut test);
957                 ext_from_hex("0c0000", &mut test);
958                 // Two feerate requests during block connection
959                 ext_from_hex("00fd00fd", &mut test);
960                 ext_from_hex("0c0000", &mut test);
961                 // Two feerate requests during block connection
962                 ext_from_hex("00fd00fd", &mut test);
963                 ext_from_hex("0c0000", &mut test);
964                 // Two feerate requests during block connection
965                 ext_from_hex("00fd00fd", &mut test);
966                 ext_from_hex("0c0000", &mut test);
967                 // Two feerate requests during block connection
968                 ext_from_hex("00fd00fd", &mut test);
969                 ext_from_hex("0c0000", &mut test);
970                 // Two feerate requests during block connection
971                 ext_from_hex("00fd00fd", &mut test);
972                 ext_from_hex("0c0000", &mut test);
973                 // Two feerate requests during block connection
974                 ext_from_hex("00fd00fd", &mut test);
975                 // by now client should have sent a channel_ready (CHECK 3: SendChannelReady to 03000000 for chan 3d000000)
976
977                 // inbound read from peer id 0 of len 18
978                 ext_from_hex("030012", &mut test);
979                 // message header indicating message length 67
980                 ext_from_hex("0043 03000000000000000000000000000000", &mut test);
981                 // inbound read from peer id 0 of len 83
982                 ext_from_hex("030053", &mut test);
983                 // channel_ready and mac
984                 ext_from_hex("0024 3d00000000000000000000000000000000000000000000000000000000000000 020800000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
985
986                 // new inbound connection with id 1
987                 ext_from_hex("01", &mut test);
988                 // inbound read from peer id 1 of len 50
989                 ext_from_hex("030132", &mut test);
990                 // inbound noise act 1
991                 ext_from_hex("0003000000000000000000000000000000000000000000000000000000000000000703000000000000000000000000000000", &mut test);
992                 // inbound read from peer id 1 of len 66
993                 ext_from_hex("030142", &mut test);
994                 // inbound noise act 3
995                 ext_from_hex("000302000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003000000000000000000000000000000", &mut test);
996
997                 // inbound read from peer id 1 of len 18
998                 ext_from_hex("030112", &mut test);
999                 // message header indicating message length 16
1000                 ext_from_hex("0010 01000000000000000000000000000000", &mut test);
1001                 // inbound read from peer id 1 of len 32
1002                 ext_from_hex("030120", &mut test);
1003                 // init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
1004                 ext_from_hex("0010 00021aaa 0008aaa20aaa2a0a9aaa 01000000000000000000000000000000", &mut test);
1005
1006                 // create outbound channel to peer 1 for 50k sat
1007                 ext_from_hex("05 01 030200000000000000000000000000000000000000000000000000000000000000 00c350 0003e8", &mut test);
1008                 // One feerate requests (all returning min feerate) (gonna be ingested by FuzzEstimator)
1009                 ext_from_hex("00fd", &mut test);
1010
1011                 // inbound read from peer id 1 of len 18
1012                 ext_from_hex("030112", &mut test);
1013                 // message header indicating message length 274
1014                 ext_from_hex("0112 01000000000000000000000000000000", &mut test);
1015                 // inbound read from peer id 1 of len 255
1016                 ext_from_hex("0301ff", &mut test);
1017                 // beginning of accept_channel
1018                 ext_from_hex("0021 0000000000000000000000000000000000000000000000000000000000000e05 0000000000000162 00000000004c4b40 00000000000003e8 00000000000003e8 00000002 03f0 0005 030000000000000000000000000000000000000000000000000000000000000100 030000000000000000000000000000000000000000000000000000000000000200 030000000000000000000000000000000000000000000000000000000000000300 030000000000000000000000000000000000000000000000000000000000000400 030000000000000000000000000000000000000000000000000000000000000500 02660000000000000000000000000000", &mut test);
1019                 // inbound read from peer id 1 of len 35
1020                 ext_from_hex("030123", &mut test);
1021                 // rest of accept_channel and mac
1022                 ext_from_hex("0000000000000000000000000000000000 0000 01000000000000000000000000000000", &mut test);
1023
1024                 // create the funding transaction (client should send funding_created now)
1025                 ext_from_hex("0a", &mut test);
1026                 // Two feerate requests to check the dust exposure on the initial commitment tx
1027                 ext_from_hex("00fd00fd", &mut test);
1028
1029                 // inbound read from peer id 1 of len 18
1030                 ext_from_hex("030112", &mut test);
1031                 // message header indicating message length 98
1032                 ext_from_hex("0062 01000000000000000000000000000000", &mut test);
1033                 // inbound read from peer id 1 of len 114
1034                 ext_from_hex("030172", &mut test);
1035                 // funding_signed message and mac
1036                 ext_from_hex("0023 3a00000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000007c0001000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1037
1038                 // broadcast funding transaction
1039                 ext_from_hex("0b", &mut test);
1040                 // by now client should have sent a channel_ready (CHECK 4: SendChannelReady to 03020000 for chan 3f000000)
1041
1042                 // inbound read from peer id 1 of len 18
1043                 ext_from_hex("030112", &mut test);
1044                 // message header indicating message length 67
1045                 ext_from_hex("0043 01000000000000000000000000000000", &mut test);
1046                 // inbound read from peer id 1 of len 83
1047                 ext_from_hex("030153", &mut test);
1048                 // channel_ready and mac
1049                 ext_from_hex("0024 3a00000000000000000000000000000000000000000000000000000000000000 026700000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1050
1051                 // inbound read from peer id 0 of len 18
1052                 ext_from_hex("030012", &mut test);
1053                 // message header indicating message length 1452
1054                 ext_from_hex("05ac 03000000000000000000000000000000", &mut test);
1055                 // inbound read from peer id 0 of len 255
1056                 ext_from_hex("0300ff", &mut test);
1057                 // beginning of update_add_htlc from 0 to 1 via client
1058                 ext_from_hex("0080 3d00000000000000000000000000000000000000000000000000000000000000 0000000000000000 0000000000003e80 ff00000000000000000000000000000000000000000000000000000000000000 000003f0 00 030000000000000000000000000000000000000000000000000000000000000555 11 020203e8 0401a0 060800000e0000010000 0a00000000000000000000000000000000000000000000000000000000000000 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1059                 // inbound read from peer id 0 of len 255
1060                 ext_from_hex("0300ff", &mut test);
1061                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1062                 // inbound read from peer id 0 of len 255
1063                 ext_from_hex("0300ff", &mut test);
1064                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1065                 // inbound read from peer id 0 of len 255
1066                 ext_from_hex("0300ff", &mut test);
1067                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1068                 // inbound read from peer id 0 of len 255
1069                 ext_from_hex("0300ff", &mut test);
1070                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1071                 // inbound read from peer id 0 of len 193
1072                 ext_from_hex("0300c1", &mut test);
1073                 // end of update_add_htlc from 0 to 1 via client and mac
1074                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ab00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1075
1076                 // Two feerate requests to check dust exposure
1077                 ext_from_hex("00fd00fd", &mut test);
1078
1079                 // inbound read from peer id 0 of len 18
1080                 ext_from_hex("030012", &mut test);
1081                 // message header indicating message length 100
1082                 ext_from_hex("0064 03000000000000000000000000000000", &mut test);
1083                 // inbound read from peer id 0 of len 116
1084                 ext_from_hex("030074", &mut test);
1085                 // commitment_signed and mac
1086                 ext_from_hex("0084 3d00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000300100000000000000000000000000000000000000000000000000000000000000 0000 03000000000000000000000000000000", &mut test);
1087                 // client should now respond with revoke_and_ack and commitment_signed (CHECK 5/6: types 133 and 132 to peer 03000000)
1088
1089                 // inbound read from peer id 0 of len 18
1090                 ext_from_hex("030012", &mut test);
1091                 // message header indicating message length 99
1092                 ext_from_hex("0063 03000000000000000000000000000000", &mut test);
1093                 // inbound read from peer id 0 of len 115
1094                 ext_from_hex("030073", &mut test);
1095                 // revoke_and_ack and mac
1096                 ext_from_hex("0085 3d00000000000000000000000000000000000000000000000000000000000000 0900000000000000000000000000000000000000000000000000000000000000 020b00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1097
1098                 // process the now-pending HTLC forward
1099                 ext_from_hex("07", &mut test);
1100                 // Two feerate requests to check dust exposure
1101                 ext_from_hex("00fd00fd", &mut test);
1102                 // client now sends id 1 update_add_htlc and commitment_signed (CHECK 7: UpdateHTLCs event for node 03020000 with 1 HTLCs for channel 3f000000)
1103
1104                 // we respond with commitment_signed then revoke_and_ack (a weird, but valid, order)
1105                 // inbound read from peer id 1 of len 18
1106                 ext_from_hex("030112", &mut test);
1107                 // message header indicating message length 100
1108                 ext_from_hex("0064 01000000000000000000000000000000", &mut test);
1109                 // inbound read from peer id 1 of len 116
1110                 ext_from_hex("030174", &mut test);
1111                 // commitment_signed and mac
1112                 ext_from_hex("0084 3a00000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000006a0001000000000000000000000000000000000000000000000000000000000000 0000 01000000000000000000000000000000", &mut test);
1113                 //
1114                 // inbound read from peer id 1 of len 18
1115                 ext_from_hex("030112", &mut test);
1116                 // message header indicating message length 99
1117                 ext_from_hex("0063 01000000000000000000000000000000", &mut test);
1118                 // inbound read from peer id 1 of len 115
1119                 ext_from_hex("030173", &mut test);
1120                 // revoke_and_ack and mac
1121                 ext_from_hex("0085 3a00000000000000000000000000000000000000000000000000000000000000 6600000000000000000000000000000000000000000000000000000000000000 026400000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1122                 //
1123                 // inbound read from peer id 1 of len 18
1124                 ext_from_hex("030112", &mut test);
1125                 // message header indicating message length 74
1126                 ext_from_hex("004a 01000000000000000000000000000000", &mut test);
1127                 // inbound read from peer id 1 of len 90
1128                 ext_from_hex("03015a", &mut test);
1129                 // update_fulfill_htlc and mac
1130                 ext_from_hex("0082 3a00000000000000000000000000000000000000000000000000000000000000 0000000000000000 ff00888888888888888888888888888888888888888888888888888888888888 01000000000000000000000000000000", &mut test);
1131                 // client should immediately claim the pending HTLC from peer 0 (CHECK 8: SendFulfillHTLCs for node 03000000 with preimage ff00888888 for channel 3d000000)
1132
1133                 // inbound read from peer id 1 of len 18
1134                 ext_from_hex("030112", &mut test);
1135                 // message header indicating message length 100
1136                 ext_from_hex("0064 01000000000000000000000000000000", &mut test);
1137                 // inbound read from peer id 1 of len 116
1138                 ext_from_hex("030174", &mut test);
1139                 // commitment_signed and mac
1140                 ext_from_hex("0084 3a00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000100001000000000000000000000000000000000000000000000000000000000000 0000 01000000000000000000000000000000", &mut test);
1141
1142                 // inbound read from peer id 1 of len 18
1143                 ext_from_hex("030112", &mut test);
1144                 // message header indicating message length 99
1145                 ext_from_hex("0063 01000000000000000000000000000000", &mut test);
1146                 // inbound read from peer id 1 of len 115
1147                 ext_from_hex("030173", &mut test);
1148                 // revoke_and_ack and mac
1149                 ext_from_hex("0085 3a00000000000000000000000000000000000000000000000000000000000000 6700000000000000000000000000000000000000000000000000000000000000 026500000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1150
1151                 // before responding to the commitment_signed generated above, send a new HTLC
1152                 // inbound read from peer id 0 of len 18
1153                 ext_from_hex("030012", &mut test);
1154                 // message header indicating message length 1452
1155                 ext_from_hex("05ac 03000000000000000000000000000000", &mut test);
1156                 // inbound read from peer id 0 of len 255
1157                 ext_from_hex("0300ff", &mut test);
1158                 // beginning of update_add_htlc from 0 to 1 via client
1159                 ext_from_hex("0080 3d00000000000000000000000000000000000000000000000000000000000000 0000000000000001 0000000000003e80 ff00000000000000000000000000000000000000000000000000000000000000 000003f0 00 030000000000000000000000000000000000000000000000000000000000000555 11 020203e8 0401a0 060800000e0000010000 0a00000000000000000000000000000000000000000000000000000000000000 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1160                 // inbound read from peer id 0 of len 255
1161                 ext_from_hex("0300ff", &mut test);
1162                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1163                 // inbound read from peer id 0 of len 255
1164                 ext_from_hex("0300ff", &mut test);
1165                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1166                 // inbound read from peer id 0 of len 255
1167                 ext_from_hex("0300ff", &mut test);
1168                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1169                 // inbound read from peer id 0 of len 255
1170                 ext_from_hex("0300ff", &mut test);
1171                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1172                 // inbound read from peer id 0 of len 193
1173                 ext_from_hex("0300c1", &mut test);
1174                 // end of update_add_htlc from 0 to 1 via client and mac
1175                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ab00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1176
1177                 // Two feerate requests to check dust exposure
1178                 ext_from_hex("00fd00fd", &mut test);
1179
1180                 // now respond to the update_fulfill_htlc+commitment_signed messages the client sent to peer 0
1181                 // inbound read from peer id 0 of len 18
1182                 ext_from_hex("030012", &mut test);
1183                 // message header indicating message length 99
1184                 ext_from_hex("0063 03000000000000000000000000000000", &mut test);
1185                 // inbound read from peer id 0 of len 115
1186                 ext_from_hex("030073", &mut test);
1187                 // revoke_and_ack and mac
1188                 ext_from_hex("0085 3d00000000000000000000000000000000000000000000000000000000000000 0800000000000000000000000000000000000000000000000000000000000000 020a00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1189                 // client should now respond with revoke_and_ack and commitment_signed (CHECK 5/6 duplicates)
1190
1191                 // inbound read from peer id 0 of len 18
1192                 ext_from_hex("030012", &mut test);
1193                 // message header indicating message length 100
1194                 ext_from_hex("0064 03000000000000000000000000000000", &mut test);
1195                 // inbound read from peer id 0 of len 116
1196                 ext_from_hex("030074", &mut test);
1197                 // commitment_signed and mac
1198                 ext_from_hex("0084 3d00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000c30100000000000000000000000000000000000000000000000000000000000000 0000 03000000000000000000000000000000", &mut test);
1199
1200                 // inbound read from peer id 0 of len 18
1201                 ext_from_hex("030012", &mut test);
1202                 // message header indicating message length 99
1203                 ext_from_hex("0063 03000000000000000000000000000000", &mut test);
1204                 // inbound read from peer id 0 of len 115
1205                 ext_from_hex("030073", &mut test);
1206                 // revoke_and_ack and mac
1207                 ext_from_hex("0085 3d00000000000000000000000000000000000000000000000000000000000000 0b00000000000000000000000000000000000000000000000000000000000000 020d00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1208
1209                 // process the now-pending HTLC forward
1210                 ext_from_hex("07", &mut test);
1211
1212                 // Two feerate requests to check dust exposure
1213                 ext_from_hex("00fd00fd", &mut test);
1214
1215                 // client now sends id 1 update_add_htlc and commitment_signed (CHECK 7 duplicate)
1216                 // we respond with revoke_and_ack, then commitment_signed, then update_fail_htlc
1217
1218                 // inbound read from peer id 1 of len 18
1219                 ext_from_hex("030112", &mut test);
1220                 // message header indicating message length 100
1221                 ext_from_hex("0064 01000000000000000000000000000000", &mut test);
1222                 // inbound read from peer id 1 of len 116
1223                 ext_from_hex("030174", &mut test);
1224                 // commitment_signed and mac
1225                 ext_from_hex("0084 3a00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000390001000000000000000000000000000000000000000000000000000000000000 0000 01000000000000000000000000000000", &mut test);
1226
1227                 // inbound read from peer id 1 of len 18
1228                 ext_from_hex("030112", &mut test);
1229                 // message header indicating message length 99
1230                 ext_from_hex("0063 01000000000000000000000000000000", &mut test);
1231                 // inbound read from peer id 1 of len 115
1232                 ext_from_hex("030173", &mut test);
1233                 // revoke_and_ack and mac
1234                 ext_from_hex("0085 3a00000000000000000000000000000000000000000000000000000000000000 6400000000000000000000000000000000000000000000000000000000000000 027000000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1235
1236                 // inbound read from peer id 1 of len 18
1237                 ext_from_hex("030112", &mut test);
1238                 // message header indicating message length 44
1239                 ext_from_hex("002c 01000000000000000000000000000000", &mut test);
1240                 // inbound read from peer id 1 of len 60
1241                 ext_from_hex("03013c", &mut test);
1242                 // update_fail_htlc and mac
1243                 ext_from_hex("0083 3a00000000000000000000000000000000000000000000000000000000000000 0000000000000001 0000 01000000000000000000000000000000", &mut test);
1244
1245                 // inbound read from peer id 1 of len 18
1246                 ext_from_hex("030112", &mut test);
1247                 // message header indicating message length 100
1248                 ext_from_hex("0064 01000000000000000000000000000000", &mut test);
1249                 // inbound read from peer id 1 of len 116
1250                 ext_from_hex("030174", &mut test);
1251                 // commitment_signed and mac
1252                 ext_from_hex("0084 3a00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000390001000000000000000000000000000000000000000000000000000000000000 0000 01000000000000000000000000000000", &mut test);
1253
1254                 // inbound read from peer id 1 of len 18
1255                 ext_from_hex("030112", &mut test);
1256                 // message header indicating message length 99
1257                 ext_from_hex("0063 01000000000000000000000000000000", &mut test);
1258                 // inbound read from peer id 1 of len 115
1259                 ext_from_hex("030173", &mut test);
1260                 // revoke_and_ack and mac
1261                 ext_from_hex("0085 3a00000000000000000000000000000000000000000000000000000000000000 6500000000000000000000000000000000000000000000000000000000000000 027100000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000", &mut test);
1262
1263                 // process the now-pending HTLC forward
1264                 ext_from_hex("07", &mut test);
1265                 // client now sends id 0 update_fail_htlc and commitment_signed (CHECK 9)
1266                 // now respond to the update_fail_htlc+commitment_signed messages the client sent to peer 0
1267
1268                 // inbound read from peer id 0 of len 18
1269                 ext_from_hex("030012", &mut test);
1270                 // message header indicating message length 99
1271                 ext_from_hex("0063 03000000000000000000000000000000", &mut test);
1272                 // inbound read from peer id 0 of len 115
1273                 ext_from_hex("030073", &mut test);
1274                 // revoke_and_ack and mac
1275                 ext_from_hex("0085 3d00000000000000000000000000000000000000000000000000000000000000 0a00000000000000000000000000000000000000000000000000000000000000 020c00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1276
1277                 // inbound read from peer id 0 of len 18
1278                 ext_from_hex("030012", &mut test);
1279                 // message header indicating message length 100
1280                 ext_from_hex("0064 03000000000000000000000000000000", &mut test);
1281                 // inbound read from peer id 0 of len 116
1282                 ext_from_hex("030074", &mut test);
1283                 // commitment_signed and mac
1284                 ext_from_hex("0084 3d00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000320100000000000000000000000000000000000000000000000000000000000000 0000 03000000000000000000000000000000", &mut test);
1285                 // client should now respond with revoke_and_ack (CHECK 5 duplicate)
1286
1287                 // inbound read from peer id 0 of len 18
1288                 ext_from_hex("030012", &mut test);
1289                 // message header indicating message length 1452
1290                 ext_from_hex("05ac 03000000000000000000000000000000", &mut test);
1291                 // inbound read from peer id 0 of len 255
1292                 ext_from_hex("0300ff", &mut test);
1293                 // beginning of update_add_htlc from 0 to 1 via client
1294                 ext_from_hex("0080 3d00000000000000000000000000000000000000000000000000000000000000 0000000000000002 00000000000b0838 ff00000000000000000000000000000000000000000000000000000000000000 000003f0 00 030000000000000000000000000000000000000000000000000000000000000555 12 02030927c0 0401a0 060800000e0000010000 0a00000000000000000000000000000000000000000000000000000000000000 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1295                 // inbound read from peer id 0 of len 255
1296                 ext_from_hex("0300ff", &mut test);
1297                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1298                 // inbound read from peer id 0 of len 255
1299                 ext_from_hex("0300ff", &mut test);
1300                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1301                 // inbound read from peer id 0 of len 255
1302                 ext_from_hex("0300ff", &mut test);
1303                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1304                 // inbound read from peer id 0 of len 255
1305                 ext_from_hex("0300ff", &mut test);
1306                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", &mut test);
1307                 // inbound read from peer id 0 of len 193
1308                 ext_from_hex("0300c1", &mut test);
1309                 // end of update_add_htlc from 0 to 1 via client and mac
1310                 ext_from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 5300000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1311
1312                 // Two feerate requests to check dust exposure
1313                 ext_from_hex("00fd00fd", &mut test);
1314
1315                 // inbound read from peer id 0 of len 18
1316                 ext_from_hex("030012", &mut test);
1317                 // message header indicating message length 164
1318                 ext_from_hex("00a4 03000000000000000000000000000000", &mut test);
1319                 // inbound read from peer id 0 of len 180
1320                 ext_from_hex("0300b4", &mut test);
1321                 // commitment_signed and mac
1322                 ext_from_hex("0084 3d00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000750100000000000000000000000000000000000000000000000000000000000000 0001 00000000000000000000000000000000000000000000000000000000000000670500000000000000000000000000000000000000000000000000000000000006 03000000000000000000000000000000", &mut test);
1323                 // client should now respond with revoke_and_ack and commitment_signed (CHECK 5/6 duplicates)
1324
1325                 // inbound read from peer id 0 of len 18
1326                 ext_from_hex("030012", &mut test);
1327                 // message header indicating message length 99
1328                 ext_from_hex("0063 03000000000000000000000000000000", &mut test);
1329                 // inbound read from peer id 0 of len 115
1330                 ext_from_hex("030073", &mut test);
1331                 // revoke_and_ack and mac
1332                 ext_from_hex("0085 3d00000000000000000000000000000000000000000000000000000000000000 0d00000000000000000000000000000000000000000000000000000000000000 020f00000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1333
1334                 // process the now-pending HTLC forward
1335                 ext_from_hex("07", &mut test);
1336                 // Two feerate requests to check dust exposure
1337                 ext_from_hex("00fd00fd", &mut test);
1338                 // client now sends id 1 update_add_htlc and commitment_signed (CHECK 7 duplicate)
1339
1340                 // connect a block with one transaction of len 125
1341                 ext_from_hex("0c007d", &mut test);
1342                 // the commitment transaction for channel 3f00000000000000000000000000000000000000000000000000000000000000
1343                 ext_from_hex("02000000013a000000000000000000000000000000000000000000000000000000000000000000000000000000800258020000000000002200204b0000000000000000000000000000000000000000000000000000000000000014c0000000000000160014280000000000000000000000000000000000000005000020", &mut test);
1344                 // Two feerate requests during block connection
1345                 ext_from_hex("00fd00fd", &mut test);
1346                 //
1347                 // connect a block with one transaction of len 94
1348                 ext_from_hex("0c005e", &mut test);
1349                 // the HTLC timeout transaction
1350                 ext_from_hex("0200000001730000000000000000000000000000000000000000000000000000000000000000000000000000000001a701000000000000220020b20000000000000000000000000000000000000000000000000000000000000000000000", &mut test);
1351                 // Two feerate requests during block connection
1352                 ext_from_hex("00fd00fd", &mut test);
1353                 // connect a block with no transactions
1354                 ext_from_hex("0c0000", &mut test);
1355                 // Two feerate requests during block connection
1356                 ext_from_hex("00fd00fd", &mut test);
1357                 // connect a block with no transactions
1358                 ext_from_hex("0c0000", &mut test);
1359                 // Two feerate requests during block connection
1360                 ext_from_hex("00fd00fd", &mut test);
1361                 // connect a block with no transactions
1362                 ext_from_hex("0c0000", &mut test);
1363                 // Two feerate requests during block connection
1364                 ext_from_hex("00fd00fd", &mut test);
1365                 // connect a block with no transactions
1366                 ext_from_hex("0c0000", &mut test);
1367                 // Two feerate requests during block connection
1368                 ext_from_hex("00fd00fd", &mut test);
1369                 // connect a block with no transactions
1370                 ext_from_hex("0c0000", &mut test);
1371                 // Two feerate requests during block connection
1372                 ext_from_hex("00fd00fd", &mut test);
1373
1374                 // process the now-pending HTLC forward
1375                 ext_from_hex("07", &mut test);
1376                 // client now fails the HTLC backwards as it was unable to extract the payment preimage (CHECK 9 duplicate and CHECK 10)
1377
1378                 let logger = Arc::new(TrackingLogger { lines: Mutex::new(HashMap::new()) });
1379                 super::do_test(&test, &(Arc::clone(&logger) as Arc<dyn Logger>));
1380
1381                 let log_entries = logger.lines.lock().unwrap();
1382                 // 1
1383                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendAcceptChannel event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679".to_string())), Some(&1));
1384                 // 2
1385                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendFundingSigned event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1));
1386                 // 3
1387                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendChannelReady event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1));
1388                 // 4
1389                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendChannelReady event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 for channel 3a00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1));
1390                 // 5
1391                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendRevokeAndACK event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&4));
1392                 // 6
1393                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 with 0 adds, 0 fulfills, 0 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&3));
1394                 // 7
1395                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 with 1 adds, 0 fulfills, 0 fails for channel 3a00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&3));
1396                 // 8
1397                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 with 0 adds, 1 fulfills, 0 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1));
1398                 // 9
1399                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 with 0 adds, 0 fulfills, 1 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&2));
1400                 // 10
1401                 assert_eq!(log_entries.get(&("lightning::chain::channelmonitor".to_string(), "Input spending counterparty commitment tx (0000000000000000000000000000000000000000000000000000000000000073:0) in 0000000000000000000000000000000000000000000000000000000000000067 resolves outbound HTLC with payment hash ff00000000000000000000000000000000000000000000000000000000000000 with timeout".to_string())), Some(&1));
1402         }
1403
1404         #[test]
1405         fn test_gossip_exchange_breakage() {
1406                 // To avoid accidentally causing all existing fuzz test cases to be useless by making minor
1407                 // changes (such as requesting feerate info in a new place), we exchange some gossip
1408                 // messages. Obviously this is pretty finicky, so this should be updated pretty liberally,
1409                 // but at least we'll know when changes occur.
1410                 // This test serves as a pretty good full_stack_target seed.
1411
1412                 // What each byte represents is broken down below, and then everything is concatenated into
1413                 // one large test at the end (you want %s/ -.*//g %s/\n\| \|\t\|\///g).
1414
1415                 // Following BOLT 8, lightning message on the wire are: 2-byte encrypted message length +
1416                 // 16-byte MAC of the encrypted message length + encrypted Lightning message + 16-byte MAC
1417                 // of the Lightning message
1418                 // I.e 2nd inbound read, len 18 : 0006 (encrypted message length) + 03000000000000000000000000000000 (MAC of the encrypted message length)
1419                 // Len 22 : 0010 00000000 (encrypted lightning message) + 03000000000000000000000000000000 (MAC of the Lightning message)
1420
1421                 // Writing new code generating transactions and see a new failure ? Don't forget to add input for the FuzzEstimator !
1422
1423                 let mut test = Vec::new();
1424
1425                 // our network key
1426                 ext_from_hex("0100000000000000000000000000000000000000000000000000000000000000", &mut test);
1427                 // config
1428                 ext_from_hex("0000000000900000000000000000640001000000000001ffff0000000000000000ffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff000000ffffffff00ffff1a000400010000020400000000040200000a08ffffffffffffffff0001000000", &mut test);
1429
1430                 // new outbound connection with id 0
1431                 ext_from_hex("00", &mut test);
1432                 // peer's pubkey
1433                 ext_from_hex("030000000000000000000000000000000000000000000000000000000000000002", &mut test);
1434                 // inbound read from peer id 0 of len 50
1435                 ext_from_hex("030032", &mut test);
1436                 // noise act two (0||pubkey||mac)
1437                 ext_from_hex("00 030000000000000000000000000000000000000000000000000000000000000002 03000000000000000000000000000000", &mut test);
1438
1439                 // inbound read from peer id 0 of len 18
1440                 ext_from_hex("030012", &mut test);
1441                 // message header indicating message length 16
1442                 ext_from_hex("0010 03000000000000000000000000000000", &mut test);
1443                 // inbound read from peer id 0 of len 32
1444                 ext_from_hex("030020", &mut test);
1445                 // init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
1446                 ext_from_hex("0010 00021aaa 0008aaa20aaa2a0a9aaa 03000000000000000000000000000000", &mut test);
1447
1448                 // new inbound connection with id 1
1449                 ext_from_hex("01", &mut test);
1450                 // inbound read from peer id 1 of len 50
1451                 ext_from_hex("030132", &mut test);
1452                 // inbound noise act 1
1453                 ext_from_hex("0003000000000000000000000000000000000000000000000000000000000000000703000000000000000000000000000000", &mut test);
1454                 // inbound read from peer id 1 of len 66
1455                 ext_from_hex("030142", &mut test);
1456                 // inbound noise act 3
1457                 ext_from_hex("000302000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000003000000000000000000000000000000", &mut test);
1458
1459                 // inbound read from peer id 1 of len 18
1460                 ext_from_hex("030112", &mut test);
1461                 // message header indicating message length 16
1462                 ext_from_hex("0010 01000000000000000000000000000000", &mut test);
1463                 // inbound read from peer id 1 of len 32
1464                 ext_from_hex("030120", &mut test);
1465                 // init message (type 16) with static_remotekey required, no channel_type/anchors/taproot, and other bits optional and mac
1466                 ext_from_hex("0010 00021aaa 0008aaa20aaa2a0a9aaa 01000000000000000000000000000000", &mut test);
1467
1468                 // inbound read from peer id 0 of len 18
1469                 ext_from_hex("030012", &mut test);
1470                 // message header indicating message length 432
1471                 ext_from_hex("01b0 03000000000000000000000000000000", &mut test);
1472                 // inbound read from peer id 0 of len 255
1473                 ext_from_hex("0300ff", &mut test);
1474                 // First part of channel_announcement (type 256)
1475                 ext_from_hex("0100 00000000000000000000000000000000000000000000000000000000000000b20303030303030303030303030303030303030303030303030303030303030303 00000000000000000000000000000000000000000000000000000000000000b20202020202020202020202020202020202020202020202020202020202020202 00000000000000000000000000000000000000000000000000000000000000b20303030303030303030303030303030303030303030303030303030303030303 00000000000000000000000000000000000000000000000000000000000000b20202020202020202020202020202020202020202020202020202020202", &mut test);
1476                 // inbound read from peer id 0 of len 193
1477                 ext_from_hex("0300c1", &mut test);
1478                 // Last part of channel_announcement and mac
1479                 ext_from_hex("020202 00006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000000000000000002a030303030303030303030303030303030303030303030303030303030303030303020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030303020202020202020202020202020202020202020202020202020202020202020202 03000000000000000000000000000000", &mut test);
1480
1481                 // inbound read from peer id 0 of len 18
1482                 ext_from_hex("030012", &mut test);
1483                 // message header indicating message length 138
1484                 ext_from_hex("008a 03000000000000000000000000000000", &mut test);
1485                 // inbound read from peer id 0 of len 154
1486                 ext_from_hex("03009a", &mut test);
1487                 // channel_update (type 258) and mac
1488                 ext_from_hex("0102 00000000000000000000000000000000000000000000000000000000000000a60303030303030303030303030303030303030303030303030303030303030303 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 000000000000002a0000002c01000028000000000000000000000000000000000000000005f5e100 03000000000000000000000000000000", &mut test);
1489
1490                 // inbound read from peer id 0 of len 18
1491                 ext_from_hex("030012", &mut test);
1492                 // message header indicating message length 142
1493                 ext_from_hex("008e 03000000000000000000000000000000", &mut test);
1494                 // inbound read from peer id 0 of len 158
1495                 ext_from_hex("03009e", &mut test);
1496                 // node_announcement (type 257) and mac
1497                 ext_from_hex("0101 00000000000000000000000000000000000000000000000000000000000000280303030303030303030303030303030303030303030303030303030303030303 00000000002b03030303030303030303030303030303030303030303030303030303030303030300000000000000000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000", &mut test);
1498
1499                 let logger = Arc::new(TrackingLogger { lines: Mutex::new(HashMap::new()) });
1500                 super::do_test(&test, &(Arc::clone(&logger) as Arc<dyn Logger>));
1501
1502                 let log_entries = logger.lines.lock().unwrap();
1503                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Sending message to all peers except Some(PublicKey(0000000000000000000000000000000000000000000000000000000000000002ff00000000000000000000000000000000000000000000000000000000000002)) or the announced channel's counterparties: ChannelAnnouncement { node_signature_1: 3026020200b202200303030303030303030303030303030303030303030303030303030303030303, node_signature_2: 3026020200b202200202020202020202020202020202020202020202020202020202020202020202, bitcoin_signature_1: 3026020200b202200303030303030303030303030303030303030303030303030303030303030303, bitcoin_signature_2: 3026020200b202200202020202020202020202020202020202020202020202020202020202020202, contents: UnsignedChannelAnnouncement { features: [], chain_hash: 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000, short_channel_id: 42, node_id_1: NodeId(030303030303030303030303030303030303030303030303030303030303030303), node_id_2: NodeId(020202020202020202020202020202020202020202020202020202020202020202), bitcoin_key_1: NodeId(030303030303030303030303030303030303030303030303030303030303030303), bitcoin_key_2: NodeId(020202020202020202020202020202020202020202020202020202020202020202), excess_data: [] } }".to_string())), Some(&1));
1504                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Sending message to all peers except Some(PublicKey(0000000000000000000000000000000000000000000000000000000000000002ff00000000000000000000000000000000000000000000000000000000000002)): ChannelUpdate { signature: 3026020200a602200303030303030303030303030303030303030303030303030303030303030303, contents: UnsignedChannelUpdate { chain_hash: 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000, short_channel_id: 42, timestamp: 44, flags: 0, cltv_expiry_delta: 40, htlc_minimum_msat: 0, htlc_maximum_msat: 100000000, fee_base_msat: 0, fee_proportional_millionths: 0, excess_data: [] } }".to_string())), Some(&1));
1505                 assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Sending message to all peers except Some(PublicKey(0000000000000000000000000000000000000000000000000000000000000002ff00000000000000000000000000000000000000000000000000000000000002)) or the announced node: NodeAnnouncement { signature: 302502012802200303030303030303030303030303030303030303030303030303030303030303, contents: UnsignedNodeAnnouncement { features: [], timestamp: 43, node_id: NodeId(030303030303030303030303030303030303030303030303030303030303030303), rgb: [0, 0, 0], alias: NodeAlias([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), addresses: [], excess_address_data: [], excess_data: [] } }".to_string())), Some(&1));
1506         }
1507 }