Merge pull request #502 from rloomba/rloomba/add_unregister_listener
[rust-lightning] / lightning / src / chain / chaininterface.rs
index ad08c817dcea362187fb223629b989810b5309fd..0aa681cf78d19397d6fed74291d874e088cde15a 100644 (file)
@@ -127,6 +127,7 @@ pub trait FeeEstimator: Sync + Send {
 pub const MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = 4000;
 
 /// Utility for tracking registered txn/outpoints and checking for matches
+#[cfg_attr(test, derive(PartialEq))]
 pub struct ChainWatchedUtil {
        watch_all: bool,
 
@@ -317,6 +318,17 @@ pub struct ChainWatchInterfaceUtil {
        logger: Arc<Logger>,
 }
 
+// We only expose PartialEq in test since its somewhat unclear exactly what it should do and we're
+// only comparing a subset of fields (essentially just checking that the set of things we're
+// watching is the same).
+#[cfg(test)]
+impl PartialEq for ChainWatchInterfaceUtil {
+       fn eq(&self, o: &Self) -> bool {
+               self.network == o.network &&
+               *self.watched.lock().unwrap() == *o.watched.lock().unwrap()
+       }
+}
+
 /// Register listener
 impl ChainWatchInterface for ChainWatchInterfaceUtil {
        fn install_watch_tx(&self, txid: &Sha256dHash, script_pub_key: &Script) {