Skip to content

Commit f438778

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 8ffc2d1 commit f438778

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
@@ -5329,16 +5329,11 @@ fn test_onchain_to_onchain_claim() {
53295329
// 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
53305330
let header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
53315331
connect_block(&nodes[1], &Block { header, txdata: vec![c_txn[1].clone(), c_txn[2].clone()]});
5332-
connect_blocks(&nodes[1], TEST_FINAL_CLTV - 1); // Confirm blocks until the HTLC expires
53335332
{
53345333
let mut b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5335-
// ChannelMonitor: claim tx, ChannelManager: local commitment tx
5336-
assert_eq!(b_txn.len(), 2);
5334+
// ChannelMonitor: claim tx
5335+
assert_eq!(b_txn.len(), 1);
53375336
check_spends!(b_txn[0], chan_2.3); // B local commitment tx, issued by ChannelManager
5338-
check_spends!(b_txn[1], c_txn[1]); // timeout tx on C remote commitment tx, issued by ChannelMonitor
5339-
assert_eq!(b_txn[1].input[0].witness.clone().last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5340-
assert!(b_txn[1].output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5341-
assert_ne!(b_txn[1].lock_time, 0); // Timeout tx
53425337
b_txn.clear();
53435338
}
53445339
check_added_monitors!(nodes[1], 1);
@@ -5367,19 +5362,14 @@ fn test_onchain_to_onchain_claim() {
53675362
let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2);
53685363
mine_transaction(&nodes[1], &commitment_tx[0]);
53695364
let b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5370-
// ChannelMonitor: HTLC-Success tx + HTLC-Timeout RBF Bump, ChannelManager: local commitment tx + HTLC-Success tx
5371-
assert_eq!(b_txn.len(), 4);
5372-
check_spends!(b_txn[2], chan_1.3);
5373-
check_spends!(b_txn[3], b_txn[2]);
5374-
let (htlc_success_claim, htlc_timeout_bumped) =
5375-
if b_txn[0].input[0].previous_output.txid == commitment_tx[0].txid()
5376-
{ (&b_txn[0], &b_txn[1]) } else { (&b_txn[1], &b_txn[0]) };
5377-
check_spends!(htlc_success_claim, commitment_tx[0]);
5378-
assert_eq!(htlc_success_claim.input[0].witness.clone().last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
5379-
assert!(htlc_success_claim.output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5380-
assert_eq!(htlc_success_claim.lock_time, 0); // Success tx
5381-
check_spends!(htlc_timeout_bumped, c_txn[1]); // timeout tx on C remote commitment tx, issued by ChannelMonitor
5382-
assert_ne!(htlc_timeout_bumped.lock_time, 0); // Success tx
5365+
// ChannelMonitor: HTLC-Success tx, ChannelManager: local commitment tx + HTLC-Success tx
5366+
assert_eq!(b_txn.len(), 3);
5367+
check_spends!(b_txn[1], chan_1.3);
5368+
check_spends!(b_txn[2], b_txn[1]);
5369+
check_spends!(b_txn[0], commitment_tx[0]);
5370+
assert_eq!(b_txn[0].input[0].witness.clone().last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
5371+
assert!(b_txn[0].output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
5372+
assert_eq!(b_txn[0].lock_time, 0); // Success tx
53835373

53845374
check_closed_broadcast!(nodes[1], true);
53855375
check_added_monitors!(nodes[1], 1);

0 commit comments

Comments
 (0)