Merge pull request #2101 from TheBlueMatt/2023-03-one-less-sig
[rust-lightning] / lightning / src / ln / monitor_tests.rs
index 7ed996820053388a1de650282c828b6cafe8a52b..5bd2e87ba5c15ca3f1ef998bafc15b92e5c88c68 100644 (file)
@@ -16,6 +16,9 @@ use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
 use crate::chain::channelmonitor::{ANTI_REORG_DELAY, Balance};
 use crate::chain::transaction::OutPoint;
 use crate::chain::chaininterface::LowerBoundedFeeEstimator;
+#[cfg(anchors)]
+use crate::events::bump_transaction::BumpTransactionEvent;
+use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
 use crate::ln::channel;
 #[cfg(anchors)]
 use crate::ln::chan_utils;
@@ -28,9 +31,6 @@ use crate::util::config::UserConfig;
 #[cfg(anchors)]
 use crate::util::crypto::sign;
 #[cfg(anchors)]
-use crate::util::events::BumpTransactionEvent;
-use crate::util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
-#[cfg(anchors)]
 use crate::util::ser::Writeable;
 #[cfg(anchors)]
 use crate::util::test_utils;
@@ -1775,7 +1775,7 @@ fn test_yield_anchors_events() {
        let mut htlc_txs = Vec::with_capacity(2);
        for event in holder_events {
                match event {
-                       Event::BumpTransaction(BumpTransactionEvent::HTLCResolution { htlc_descriptors, .. }) => {
+                       Event::BumpTransaction(BumpTransactionEvent::HTLCResolution { htlc_descriptors, tx_lock_time, .. }) => {
                                assert_eq!(htlc_descriptors.len(), 1);
                                let htlc_descriptor = &htlc_descriptors[0];
                                let signer = nodes[0].keys_manager.derive_channel_keys(
@@ -1784,11 +1784,7 @@ fn test_yield_anchors_events() {
                                let per_commitment_point = signer.get_per_commitment_point(htlc_descriptor.per_commitment_number, &secp);
                                let mut htlc_tx = Transaction {
                                        version: 2,
-                                       lock_time: if htlc_descriptor.htlc.offered {
-                                               PackedLockTime(htlc_descriptor.htlc.cltv_expiry)
-                                       } else {
-                                               PackedLockTime::ZERO
-                                       },
+                                       lock_time: tx_lock_time,
                                        input: vec![
                                                htlc_descriptor.unsigned_tx_input(), // HTLC input
                                                TxIn { ..Default::default() } // Fee input
@@ -2063,7 +2059,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
                };
                let mut descriptors = Vec::with_capacity(4);
                for event in events {
-                       if let Event::BumpTransaction(BumpTransactionEvent::HTLCResolution { mut htlc_descriptors, .. }) = event {
+                       if let Event::BumpTransaction(BumpTransactionEvent::HTLCResolution { mut htlc_descriptors, tx_lock_time, .. }) = event {
                                assert_eq!(htlc_descriptors.len(), 2);
                                for htlc_descriptor in &htlc_descriptors {
                                        assert!(!htlc_descriptor.htlc.offered);
@@ -2075,6 +2071,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
                                        htlc_tx.output.push(htlc_descriptor.tx_output(&per_commitment_point, &secp));
                                }
                                descriptors.append(&mut htlc_descriptors);
+                               htlc_tx.lock_time = tx_lock_time;
                        } else {
                                panic!("Unexpected event");
                        }