Track HTLC-failure trigger tx until anti-reorg delay reached
[rust-lightning] / src / ln / functional_test_utils.rs
index 9a24d503ceea3d5323ab8783f84d274f56d0388f..b8f5e5835a359f5a30bc9a821685f5bd5be26577 100644 (file)
@@ -20,6 +20,7 @@ use bitcoin::blockdata::transaction::{Transaction, TxOut};
 use bitcoin::network::constants::Network;
 
 use bitcoin_hashes::sha256::Hash as Sha256;
+use bitcoin_hashes::sha256d::Hash as Sha256d;
 use bitcoin_hashes::Hash;
 
 use secp256k1::Secp256k1;
@@ -46,6 +47,15 @@ pub fn confirm_transaction(chain: &chaininterface::ChainWatchInterfaceUtil, tx:
        }
 }
 
+pub fn connect_blocks(chain: &chaininterface::ChainWatchInterfaceUtil, depth: u32, height: u32, parent: bool, prev_blockhash: Sha256d) {
+       let mut header = BlockHeader { version: 0x2000000, prev_blockhash: if parent { prev_blockhash } else { Default::default() }, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       chain.block_connected_checked(&header, height + 1, &Vec::new(), &Vec::new());
+       for i in 2..depth + 1 {
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               chain.block_connected_checked(&header, height + i, &Vec::new(), &Vec::new());
+       }
+}
+
 pub struct Node {
        pub chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
        pub tx_broadcaster: Arc<test_utils::TestBroadcaster>,