Skip to content

Commit a0fe042

Browse files
committed
Drop test_dup_htlc_onchain_fails_on_reload as it no longer applies
test_dup_htlc_onchain_fails_on_reload tested our outbound payment tracking to ensure we never sent more than one PaymentSent event to users per payment in the case of a manager-monitor storage order inversion which was common. However, now that we require monitors be persisted when a block is connected, that inversion can never occur, and thus the test isn't testing anything.
1 parent 64a083e commit a0fe042

File tree

1 file changed

+0
-109
lines changed

1 file changed

+0
-109
lines changed

lightning/src/ln/functional_tests.rs

-109
Original file line numberDiff line numberDiff line change
@@ -4381,115 +4381,6 @@ fn retry_expired_payment() {
43814381
}
43824382
}
43834383

4384-
#[test]
4385-
fn test_dup_htlc_onchain_fails_on_reload() {
4386-
// When a Channel is closed, any outbound HTLCs which were relayed through it are simply
4387-
// dropped when the Channel is. From there, the ChannelManager relies on the ChannelMonitor
4388-
// having a copy of the relevant fail-/claim-back data and processes the HTLC fail/claim when
4389-
// the ChannelMonitor tells it to.
4390-
//
4391-
// If, due to an on-chain event, an HTLC is failed/claimed, and then we serialize the
4392-
// ChannelManager, we generally expect there not to be a duplicate HTLC fail/claim (eg via a
4393-
// PaymentPathFailed event appearing). However, because we may not serialize the relevant
4394-
// ChannelMonitor at the same time, this isn't strictly guaranteed. In order to provide this
4395-
// consistency, the ChannelManager explicitly tracks pending-onchain-resolution outbound HTLCs
4396-
// and de-duplicates ChannelMonitor events.
4397-
//
4398-
// This tests that explicit tracking behavior.
4399-
let chanmon_cfgs = create_chanmon_cfgs(2);
4400-
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
4401-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
4402-
let persister: test_utils::TestPersister;
4403-
let new_chain_monitor: test_utils::TestChainMonitor;
4404-
let nodes_0_deserialized: ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>;
4405-
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
4406-
4407-
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
4408-
4409-
// Route a payment, but force-close the channel before the HTLC fulfill message arrives at
4410-
// nodes[0].
4411-
let (payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], 10000000);
4412-
nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id).unwrap();
4413-
check_closed_broadcast!(nodes[0], true);
4414-
check_added_monitors!(nodes[0], 1);
4415-
check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed);
4416-
4417-
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
4418-
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
4419-
4420-
// Connect blocks until the CLTV timeout is up so that we get an HTLC-Timeout transaction
4421-
connect_blocks(&nodes[0], TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + 1);
4422-
let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
4423-
assert_eq!(node_txn.len(), 3);
4424-
assert_eq!(node_txn[0], node_txn[1]);
4425-
4426-
assert!(nodes[1].node.claim_funds(payment_preimage));
4427-
check_added_monitors!(nodes[1], 1);
4428-
4429-
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
4430-
connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[1].clone(), node_txn[2].clone()]});
4431-
check_closed_broadcast!(nodes[1], true);
4432-
check_added_monitors!(nodes[1], 1);
4433-
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
4434-
let claim_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
4435-
4436-
header.prev_blockhash = nodes[0].best_block_hash();
4437-
connect_block(&nodes[0], &Block { header, txdata: vec![node_txn[1].clone(), node_txn[2].clone()]});
4438-
4439-
// Serialize out the ChannelMonitor before connecting the on-chain claim transactions. This is
4440-
// fairly normal behavior as ChannelMonitor(s) are often not re-serialized when on-chain events
4441-
// happen, unlike ChannelManager which tends to be re-serialized after any relevant event(s).
4442-
let mut chan_0_monitor_serialized = test_utils::TestVecWriter(Vec::new());
4443-
nodes[0].chain_monitor.chain_monitor.monitors.read().unwrap().iter().next().unwrap().1.write(&mut chan_0_monitor_serialized).unwrap();
4444-
4445-
header.prev_blockhash = nodes[0].best_block_hash();
4446-
let claim_block = Block { header, txdata: claim_txn};
4447-
connect_block(&nodes[0], &claim_block);
4448-
expect_payment_sent!(nodes[0], payment_preimage);
4449-
4450-
// ChannelManagers generally get re-serialized after any relevant event(s). Since we just
4451-
// connected a highly-relevant block, it likely gets serialized out now.
4452-
let mut chan_manager_serialized = test_utils::TestVecWriter(Vec::new());
4453-
nodes[0].node.write(&mut chan_manager_serialized).unwrap();
4454-
4455-
// Now reload nodes[0]...
4456-
persister = test_utils::TestPersister::new();
4457-
let keys_manager = &chanmon_cfgs[0].keys_manager;
4458-
new_chain_monitor = test_utils::TestChainMonitor::new(Some(nodes[0].chain_source), nodes[0].tx_broadcaster.clone(), nodes[0].logger, node_cfgs[0].fee_estimator, &persister, keys_manager);
4459-
nodes[0].chain_monitor = &new_chain_monitor;
4460-
let mut chan_0_monitor_read = &chan_0_monitor_serialized.0[..];
4461-
let (_, mut chan_0_monitor) = <(BlockHash, ChannelMonitor<EnforcingSigner>)>::read(
4462-
&mut chan_0_monitor_read, keys_manager).unwrap();
4463-
assert!(chan_0_monitor_read.is_empty());
4464-
4465-
let (_, nodes_0_deserialized_tmp) = {
4466-
let mut channel_monitors = HashMap::new();
4467-
channel_monitors.insert(chan_0_monitor.get_funding_txo().0, &mut chan_0_monitor);
4468-
<(BlockHash, ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>)>
4469-
::read(&mut io::Cursor::new(&chan_manager_serialized.0[..]), ChannelManagerReadArgs {
4470-
default_config: Default::default(),
4471-
keys_manager,
4472-
fee_estimator: node_cfgs[0].fee_estimator,
4473-
chain_monitor: nodes[0].chain_monitor,
4474-
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
4475-
logger: nodes[0].logger,
4476-
channel_monitors,
4477-
}).unwrap()
4478-
};
4479-
nodes_0_deserialized = nodes_0_deserialized_tmp;
4480-
4481-
assert!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok());
4482-
check_added_monitors!(nodes[0], 1);
4483-
nodes[0].node = &nodes_0_deserialized;
4484-
4485-
// Note that if we re-connect the block which exposed nodes[0] to the payment preimage (but
4486-
// which the current ChannelMonitor has not seen), the ChannelManager's de-duplication of
4487-
// payment events should kick in, leaving us with no pending events here.
4488-
let height = nodes[0].blocks.lock().unwrap().len() as u32 - 1;
4489-
nodes[0].chain_monitor.chain_monitor.block_connected(&claim_block, height);
4490-
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
4491-
}
4492-
44934384
#[test]
44944385
fn test_manager_serialize_deserialize_events() {
44954386
// This test makes sure the events field in ChannelManager survives de/serialization

0 commit comments

Comments
 (0)