X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ftest_utils.rs;h=5be32a87f726d9fa486da514d237c96f3148b5e9;hb=09e29c86db73f2de7abbee6946b4773078c380a3;hp=679652b2da49402a2c76f2f0720407c0928e043b;hpb=5f96d1334435e74545670a5dff24078edf749d60;p=rust-lightning diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 679652b2..5be32a87 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -308,8 +308,15 @@ pub struct TestBroadcaster { } impl TestBroadcaster { - pub fn new(blocks: Arc>>) -> TestBroadcaster { - TestBroadcaster { txn_broadcasted: Mutex::new(Vec::new()), blocks } + pub fn new(network: Network) -> Self { + Self { + txn_broadcasted: Mutex::new(Vec::new()), + blocks: Arc::new(Mutex::new(vec![(genesis_block(network), 0)])), + } + } + + pub fn with_blocks(blocks: Arc>>) -> Self { + Self { txn_broadcasted: Mutex::new(Vec::new()), blocks } } pub fn txn_broadcast(&self) -> Vec { @@ -328,7 +335,7 @@ impl chaininterface::BroadcasterInterface for TestBroadcaster { fn broadcast_transaction(&self, tx: &Transaction) { let lock_time = tx.lock_time.0; assert!(lock_time < 1_500_000_000); - if lock_time > self.blocks.lock().unwrap().len() as u32 + 1 && lock_time < 500_000_000 { + if bitcoin::LockTime::from(tx.lock_time).is_block_height() && lock_time > self.blocks.lock().unwrap().last().unwrap().1 { for inp in tx.input.iter() { if inp.sequence != Sequence::MAX { panic!("We should never broadcast a transaction before its locktime ({})!", tx.lock_time);