Put test utilities behind a feature flag.
[rust-lightning] / lightning / src / ln / channelmanager.rs
index 6b2f50e9704b0a16312eb9f10134dcee0f9b6882..b43c98c840392c7b983de276e0867ba5e3baf795 100644 (file)
@@ -16,6 +16,7 @@
 //! It does not manage routing logic (see routing::router::get_route for that) nor does it manage constructing
 //! on-chain transactions (it only monitors the chain to watch for any force-closes that might
 //! imply it needs to fail HTLCs/payments/channels it manages).
+//!
 
 use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::constants::genesis_block;
@@ -404,9 +405,9 @@ pub struct ChannelManager<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref,
        last_block_hash: Mutex<BlockHash>,
        secp_ctx: Secp256k1<secp256k1::All>,
 
-       #[cfg(test)]
+       #[cfg(any(test, feature = "_test_utils"))]
        pub(super) channel_state: Mutex<ChannelHolder<ChanSigner>>,
-       #[cfg(not(test))]
+       #[cfg(not(any(test, feature = "_test_utils")))]
        channel_state: Mutex<ChannelHolder<ChanSigner>>,
        our_network_key: SecretKey,
 
@@ -1126,7 +1127,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                                PendingHTLCStatus::Forward(PendingHTLCInfo {
                                        routing: PendingHTLCRouting::Forward {
                                                onion_packet: outgoing_packet,
-                                               short_channel_id: short_channel_id,
+                                               short_channel_id,
                                        },
                                        payment_hash: msg.payment_hash.clone(),
                                        incoming_shared_secret: shared_secret,
@@ -1221,7 +1222,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
 
                let unsigned = msgs::UnsignedChannelUpdate {
                        chain_hash: self.genesis_hash,
-                       short_channel_id: short_channel_id,
+                       short_channel_id,
                        timestamp: chan.get_update_time_counter(),
                        flags: (!were_node_one) as u8 | ((!chan.is_live() as u8) << 1),
                        cltv_expiry_delta: CLTV_EXPIRY_DELTA,
@@ -1447,7 +1448,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                let mut channel_state = self.channel_state.lock().unwrap();
                channel_state.pending_msg_events.push(events::MessageSendEvent::SendFundingCreated {
                        node_id: chan.get_counterparty_node_id(),
-                       msg: msg,
+                       msg,
                });
                match channel_state.by_id.entry(chan.channel_id()) {
                        hash_map::Entry::Occupied(_) => {
@@ -1745,14 +1746,14 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                                                                                }
                                                                        } else if total_value == data.total_msat {
                                                                                new_events.push(events::Event::PaymentReceived {
-                                                                                       payment_hash: payment_hash,
+                                                                                       payment_hash,
                                                                                        payment_secret: Some(data.payment_secret),
                                                                                        amt: total_value,
                                                                                });
                                                                        }
                                                                } else {
                                                                        new_events.push(events::Event::PaymentReceived {
-                                                                               payment_hash: payment_hash,
+                                                                               payment_hash,
                                                                                payment_secret: None,
                                                                                amt: amt_to_forward,
                                                                        });
@@ -2304,7 +2305,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                pending_events.push(events::Event::FundingGenerationReady {
                        temporary_channel_id: msg.temporary_channel_id,
                        channel_value_satoshis: value,
-                       output_script: output_script,
+                       output_script,
                        user_channel_id: user_id,
                });
                Ok(())
@@ -2384,7 +2385,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                };
                let mut pending_events = self.pending_events.lock().unwrap();
                pending_events.push(events::Event::FundingBroadcastSafe {
-                       funding_txo: funding_txo,
+                       funding_txo,
                        user_channel_id: user_id,
                });
                Ok(())