Mark failed counterparty-is-destination HTLCs retryable
[rust-lightning] / lightning / src / ln / reorg_tests.rs
index fab6962e514957209b832c786916575be95fed4c..0440e2135144c6efe27a53e12c0ab6d3ac836011 100644 (file)
@@ -28,6 +28,8 @@ use bitcoin::secp256k1::Secp256k1;
 
 use prelude::*;
 use core::mem;
+use bitcoin::hashes::Hash;
+use bitcoin::TxMerkleNode;
 
 use ln::functional_test_utils::*;
 
@@ -68,7 +70,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
        check_added_monitors!(nodes[2], 1);
        get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
 
-       let mut header = BlockHeader { version: 0x2000_0000, prev_blockhash: nodes[2].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let mut header = BlockHeader { version: 0x2000_0000, prev_blockhash: nodes[2].best_block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 };
        let claim_txn = if local_commitment {
                // Broadcast node 1 commitment txn to broadcast the HTLC-Timeout
                let node_1_commitment_txn = get_local_commitment_txn!(nodes[1], chan_2.2);
@@ -128,10 +130,11 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
        assert_eq!(nodes[1].node.get_and_clear_pending_events().len(), 0);
 
        if claim {
-               disconnect_blocks(&nodes[1], ANTI_REORG_DELAY - 2);
+               // Disconnect Node 1's HTLC-Timeout which was connected above
+               disconnect_blocks(&nodes[1], ANTI_REORG_DELAY - 1);
 
                let block = Block {
-                       header: BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 },
+                       header: BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 },
                        txdata: claim_txn,
                };
                connect_block(&nodes[1], &block);
@@ -143,7 +146,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
        } else {
                // Confirm the timeout tx and check that we fail the HTLC backwards
                let block = Block {
-                       header: BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 },
+                       header: BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 },
                        txdata: vec![],
                };
                connect_block(&nodes[1], &block);
@@ -253,7 +256,7 @@ fn test_counterparty_revoked_reorg() {
 
        // Connect blocks to confirm the unrevoked commitment transaction
        connect_blocks(&nodes[1], ANTI_REORG_DELAY - 2);
-       expect_payment_failed!(nodes[1], payment_hash_4, true);
+       expect_payment_failed!(nodes[1], payment_hash_4, false);
 }
 
 fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_unconfirmed: bool, connect_style: ConnectStyle) {