Clean up `compute_fees` and add a saturating variant
[rust-lightning] / lightning / src / sync / debug_sync.rs
index b61d1cb55e8cff3143c686c4ad6fbc13427b47d9..9f7caa2c1804350818a5804f49fb0896c6d33f0f 100644 (file)
@@ -77,7 +77,7 @@ fn get_construction_location(backtrace: &Backtrace) -> String {
        // Find the first frame that is after `debug_sync` (or that is in our tests) and use
        // that as the mutex construction site. Note that the first few frames may be in
        // the `backtrace` crate, so we have to ignore those.
-       let sync_mutex_constr_regex = regex::Regex::new(r"lightning.*debug_sync.*new").unwrap();
+       let sync_mutex_constr_regex = regex::Regex::new(r"lightning.*debug_sync").unwrap();
        let mut found_debug_sync = false;
        for frame in backtrace.frames() {
                for symbol in frame.symbols() {
@@ -333,100 +333,3 @@ impl<T> RwLock<T> {
 }
 
 pub type FairRwLock<T> = RwLock<T>;
-
-mod tests {
-       use super::{RwLock, Mutex};
-
-       #[test]
-       #[should_panic]
-       #[cfg(not(feature = "backtrace"))]
-       fn recursive_lock_fail() {
-               let mutex = Mutex::new(());
-               let _a = mutex.lock().unwrap();
-               let _b = mutex.lock().unwrap();
-       }
-
-       #[test]
-       fn recursive_read() {
-               let lock = RwLock::new(());
-               let _a = lock.read().unwrap();
-               let _b = lock.read().unwrap();
-       }
-
-       #[test]
-       #[should_panic]
-       fn lockorder_fail() {
-               let a = Mutex::new(());
-               let b = Mutex::new(());
-               {
-                       let _a = a.lock().unwrap();
-                       let _b = b.lock().unwrap();
-               }
-               {
-                       let _b = b.lock().unwrap();
-                       let _a = a.lock().unwrap();
-               }
-       }
-
-       #[test]
-       #[should_panic]
-       fn write_lockorder_fail() {
-               let a = RwLock::new(());
-               let b = RwLock::new(());
-               {
-                       let _a = a.write().unwrap();
-                       let _b = b.write().unwrap();
-               }
-               {
-                       let _b = b.write().unwrap();
-                       let _a = a.write().unwrap();
-               }
-       }
-
-       #[test]
-       #[should_panic]
-       fn read_lockorder_fail() {
-               let a = RwLock::new(());
-               let b = RwLock::new(());
-               {
-                       let _a = a.read().unwrap();
-                       let _b = b.read().unwrap();
-               }
-               {
-                       let _b = b.read().unwrap();
-                       let _a = a.read().unwrap();
-               }
-       }
-
-       #[test]
-       fn read_recursive_no_lockorder() {
-               // Like the above, but note that no lockorder is implied when we recursively read-lock a
-               // RwLock, causing this to pass just fine.
-               let a = RwLock::new(());
-               let b = RwLock::new(());
-               let _outer = a.read().unwrap();
-               {
-                       let _a = a.read().unwrap();
-                       let _b = b.read().unwrap();
-               }
-               {
-                       let _b = b.read().unwrap();
-                       let _a = a.read().unwrap();
-               }
-       }
-
-       #[test]
-       #[should_panic]
-       fn read_write_lockorder_fail() {
-               let a = RwLock::new(());
-               let b = RwLock::new(());
-               {
-                       let _a = a.write().unwrap();
-                       let _b = b.read().unwrap();
-               }
-               {
-                       let _b = b.read().unwrap();
-                       let _a = a.write().unwrap();
-               }
-       }
-}