Demonstrate mutating functions which are not fully test-covered
[rust-lightning] / lightning / src / ln / channel.rs
index c9eebf41eb4706b3a7d39c10600c92e7c8e8949e..65fb9919760e94e7fd65e07fb31b02dcc2cb72e9 100644 (file)
@@ -35,6 +35,9 @@ use std::default::Default;
 use std::{cmp,mem,fmt};
 use std::ops::Deref;
 
+#[cfg(all(test, feature = "mutation_testing"))]
+use mutagen::mutate;
+
 #[cfg(test)]
 pub struct ChannelValueStat {
        pub value_to_self_msat: u64,
@@ -2357,6 +2360,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                }
        }
 
+       #[cfg_attr(all(test, feature = "mutation_testing"), mutate)]
        /// Removes any uncommitted HTLCs, to be used on peer disconnection, including any pending
        /// HTLCs that we intended to add but haven't as we were waiting on a remote revoke.
        /// Returns the set of PendingHTLCStatuses from remote uncommitted HTLCs (which we're
@@ -2443,6 +2447,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                self.channel_state |= ChannelState::MonitorUpdateFailed as u32;
        }
 
+       #[cfg_attr(all(test, feature = "mutation_testing"), mutate)]
        /// Indicates that the latest ChannelMonitor update has been committed by the client
        /// successfully and we should restore normal operation. Returns messages which should be sent
        /// to the remote side.
@@ -2513,6 +2518,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                Ok(())
        }
 
+       #[cfg_attr(all(test, feature = "mutation_testing"), mutate)]
        fn get_last_revoke_and_ack(&self) -> msgs::RevokeAndACK {
                let next_per_commitment_point = PublicKey::from_secret_key(&self.secp_ctx, &self.build_local_commitment_secret(self.cur_local_commitment_transaction_number));
                let per_commitment_secret = chan_utils::build_commitment_secret(self.local_keys.commitment_seed(), self.cur_local_commitment_transaction_number + 2);