Skip to content

Commit d4984bf

Browse files
committed
Test preimages are learned instantly in test_onchain_to_onchain_claim
test_onchain_to_onchain_claim was connecting additional blocks in order to reach HTLC timeout and broadcast an HTLC-Timeout transaction, resulting in it not testing whether HTLC preimages are learned instantly in response to HTLC-Success transactions.
1 parent e00bf8d commit d4984bf

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,16 +5285,11 @@ fn test_onchain_to_onchain_claim() {
52855285
// So we broadcast C's commitment tx and HTLC-Success on B's chain, we should successfully be able to extract preimage and update downstream monitor
52865286
let header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
52875287
connect_block(&nodes[1], &Block { header, txdata: vec![c_txn[1].clone(), c_txn[2].clone()]});
5288-
connect_blocks(&nodes[1], TEST_FINAL_CLTV - 1); // Confirm blocks until the HTLC expires
52895288
{
52905289
let mut b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5291-
// ChannelMonitor: claim tx, ChannelManager: local commitment tx
5292-
assert_eq!(b_txn.len(), 2);
5290+
// ChannelMonitor: claim tx
5291+
assert_eq!(b_txn.len(), 1);
52935292
check_spends!(b_txn[0], chan_2.3); // B local commitment tx, issued by ChannelManager
5294-
check_spends!(b_txn[1], c_txn[1]); // timeout tx on C remote commitment tx, issued by ChannelMonitor
5295-
assert_eq!(b_txn[1].input[0].witness.clone().last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5296-
assert!(b_txn[1].output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5297-
assert_ne!(b_txn[1].lock_time, 0); // Timeout tx
52985293
b_txn.clear();
52995294
}
53005295
check_added_monitors!(nodes[1], 1);
@@ -5323,19 +5318,14 @@ fn test_onchain_to_onchain_claim() {
53235318
let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2);
53245319
mine_transaction(&nodes[1], &commitment_tx[0]);
53255320
let b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5326-
// ChannelMonitor: HTLC-Success tx + HTLC-Timeout RBF Bump, ChannelManager: local commitment tx + HTLC-Success tx
5327-
assert_eq!(b_txn.len(), 4);
5328-
check_spends!(b_txn[2], chan_1.3);
5329-
check_spends!(b_txn[3], b_txn[2]);
5330-
let (htlc_success_claim, htlc_timeout_bumped) =
5331-
if b_txn[0].input[0].previous_output.txid == commitment_tx[0].txid()
5332-
{ (&b_txn[0], &b_txn[1]) } else { (&b_txn[1], &b_txn[0]) };
5333-
check_spends!(htlc_success_claim, commitment_tx[0]);
5334-
assert_eq!(htlc_success_claim.input[0].witness.clone().last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
5335-
assert!(htlc_success_claim.output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5336-
assert_eq!(htlc_success_claim.lock_time, 0); // Success tx
5337-
check_spends!(htlc_timeout_bumped, c_txn[1]); // timeout tx on C remote commitment tx, issued by ChannelMonitor
5338-
assert_ne!(htlc_timeout_bumped.lock_time, 0); // Success tx
5321+
// ChannelMonitor: HTLC-Success tx, ChannelManager: local commitment tx + HTLC-Success tx
5322+
assert_eq!(b_txn.len(), 3);
5323+
check_spends!(b_txn[1], chan_1.3);
5324+
check_spends!(b_txn[2], b_txn[1]);
5325+
check_spends!(b_txn[0], commitment_tx[0]);
5326+
assert_eq!(b_txn[0].input[0].witness.clone().last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
5327+
assert!(b_txn[0].output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5328+
assert_eq!(b_txn[0].lock_time, 0); // Success tx
53395329

53405330
check_closed_broadcast!(nodes[1], true);
53415331
check_added_monitors!(nodes[1], 1);

0 commit comments

Comments
 (0)