]> git.bitcoin.ninja Git - rust-lightning/commitdiff
[functional tests] Drop unused disconnect_block utility 2021-03-test-chains
authorMatt Corallo <git@bluematt.me>
Thu, 18 Mar 2021 17:16:58 +0000 (13:16 -0400)
committerMatt Corallo <git@bluematt.me>
Sat, 20 Mar 2021 03:32:38 +0000 (23:32 -0400)
This also reduces some needless clones and indirections.

lightning/src/ln/functional_test_utils.rs

index fe3df8d1e5bd674a3f18bb4c94017d454106c215..e7f61c6a3dfeefb23f845b7a47d6ab0efa5abf60 100644 (file)
@@ -107,16 +107,12 @@ pub fn connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: &Block)
        node.blocks.borrow_mut().push((block.header, height));
 }
 
-pub fn disconnect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, header: &BlockHeader) {
-       node.chain_monitor.chain_monitor.block_disconnected(header, node.best_block_info().1);
-       node.node.block_disconnected(header);
-       node.blocks.borrow_mut().pop();
-}
 pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32) {
-       assert!(node.blocks.borrow_mut().len() as u32 > count); // Cannot disconnect genesis
        for _ in 0..count {
-               let block_header = node.blocks.borrow().last().unwrap().0;
-               disconnect_block(&node, &block_header);
+               let orig_header = node.blocks.borrow_mut().pop().unwrap();
+               assert!(orig_header.1 > 0); // Cannot disconnect genesis
+               node.chain_monitor.chain_monitor.block_disconnected(&orig_header.0, orig_header.1);
+               node.node.block_disconnected(&orig_header.0);
        }
 }