Merge pull request #968 from TheBlueMatt/2021-06-no-invoice-dylib
[rust-lightning] / lightning / src / util / test_utils.rs
index a1438f3c6ea92a88213c5dff9c8656d431f69ec1..b4d274f683cb5b414b9a174e781feb978600e815 100644 (file)
@@ -42,7 +42,6 @@ use core::time::Duration;
 use std::sync::{Mutex, Arc};
 use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
 use core::{cmp, mem};
-use std::collections::{HashMap, HashSet, VecDeque};
 use chain::keysinterface::InMemorySigner;
 
 pub struct TestVecWriter(pub Vec<u8>);
@@ -206,6 +205,14 @@ pub struct TestBroadcaster {
 }
 impl chaininterface::BroadcasterInterface for TestBroadcaster {
        fn broadcast_transaction(&self, tx: &Transaction) {
+               assert!(tx.lock_time < 1_500_000_000);
+               if tx.lock_time > self.blocks.lock().unwrap().len() as u32 + 1 && tx.lock_time < 500_000_000 {
+                       for inp in tx.input.iter() {
+                               if inp.sequence != 0xffffffff {
+                                       panic!("We should never broadcast a transaction before its locktime ({})!", tx.lock_time);
+                               }
+                       }
+               }
                self.txn_broadcasted.lock().unwrap().push(tx.clone());
        }
 }