X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fmonitor_tests.rs;h=2b582fe877bc663ea2df7677684b575a48b2edf2;hb=482a2b9250679abb3c9931497b2324799fbfa087;hp=0e4733ea526d2c33e7206c85be5dc335613ad771;hpb=79541b11e8b6e62de0fc613f416e30bf1de5f3d9;p=rust-lightning diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 0e4733ea..2b582fe8 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -11,15 +11,11 @@ use chain::channelmonitor::{ANTI_REORG_DELAY, Balance}; use chain::transaction::OutPoint; -use ln::{channel, PaymentPreimage, PaymentHash}; +use ln::channel; use ln::channelmanager::BREAKDOWN_TIMEOUT; use ln::features::InitFeatures; -use ln::msgs::{ChannelMessageHandler, ErrorAction}; +use ln::msgs::ChannelMessageHandler; use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason}; -use routing::network_graph::NetworkUpdate; - -use bitcoin::hashes::sha256::Hash as Sha256; -use bitcoin::hashes::Hash; use bitcoin::blockdata::script::Builder; use bitcoin::blockdata::opcodes; @@ -103,9 +99,10 @@ fn chanmon_claim_value_coop_close() { assert_eq!(funding_outpoint.to_channel_id(), chan_id); let chan_feerate = get_feerate!(nodes[0], chan_id) as u64; + let opt_anchors = get_opt_anchors!(nodes[0], chan_id); assert_eq!(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::COMMITMENT_TX_BASE_WEIGHT / 1000 + claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(opt_anchors) / 1000 }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); assert_eq!(vec![Balance::ClaimableOnChannelClose { claimable_amount_satoshis: 1_000, }], @@ -140,7 +137,7 @@ fn chanmon_claim_value_coop_close() { assert!(nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_events().is_empty()); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::COMMITMENT_TX_BASE_WEIGHT / 1000, + claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(opt_anchors) / 1000, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -216,13 +213,14 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { let htlc_cltv_timeout = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + 1; // Note ChannelManager adds one to CLTV timeouts for safety let chan_feerate = get_feerate!(nodes[0], chan_id) as u64; + let opt_anchors = get_opt_anchors!(nodes[0], chan_id); let remote_txn = get_local_commitment_txn!(nodes[1], chan_id); // Before B receives the payment preimage, it only suggests the push_msat value of 1_000 sats // as claimable. A lists both its to-self balance and the (possibly-claimable) HTLCs. assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { claimable_amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * - (channel::COMMITMENT_TX_BASE_WEIGHT + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, + (channel::commitment_tx_base_weight(opt_anchors) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::MaybeClaimableHTLCAwaitingTimeout { claimable_amount_satoshis: 3_000, claimable_height: htlc_cltv_timeout, @@ -249,7 +247,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { if prev_commitment_tx { // To build a previous commitment transaction, deliver one round of commitment messages. nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &b_htlc_msgs.update_fulfill_htlcs[0]); - expect_payment_sent!(nodes[0], payment_preimage); + expect_payment_sent_without_paths!(nodes[0], payment_preimage); nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &b_htlc_msgs.commitment_signed); check_added_monitors!(nodes[0], 1); let (as_raa, as_cs) = get_revoke_commit_msgs!(nodes[0], nodes[1].node.get_our_node_id()); @@ -270,7 +268,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { 1_000 - // The push_msat value in satoshis 3 - // The dust HTLC value in satoshis // The commitment transaction fee with two HTLC outputs: - chan_feerate * (channel::COMMITMENT_TX_BASE_WEIGHT + + chan_feerate * (channel::commitment_tx_base_weight(opt_anchors) + if prev_commitment_tx { 1 } else { 2 } * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::MaybeClaimableHTLCAwaitingTimeout { @@ -333,7 +331,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { claimable_amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * - (channel::COMMITMENT_TX_BASE_WEIGHT + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, + (channel::commitment_tx_base_weight(opt_anchors) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }, Balance::MaybeClaimableHTLCAwaitingTimeout { claimable_amount_satoshis: 3_000, @@ -400,7 +398,9 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { // After broadcasting the HTLC claim transaction, node A will still consider the HTLC // possibly-claimable up to ANTI_REORG_DELAY, at which point it will drop it. mine_transaction(&nodes[0], &b_broadcast_txn[0]); - if !prev_commitment_tx { + if prev_commitment_tx { + expect_payment_path_successful!(nodes[0]); + } else { expect_payment_sent!(nodes[0], payment_preimage); } assert_eq!(sorted_vec(vec![Balance::MaybeClaimableHTLCAwaitingTimeout {