@@ -4718,8 +4718,8 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
4718
4718
// ACCEPTED_HTLC_SCRIPT_WEIGHT.
4719
4719
let payment_params = PaymentParameters::from_node_id(nodes[3].node.get_our_node_id())
4720
4720
.with_features(nodes[3].node.invoice_features());
4721
- let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[3], payment_params, 900000 , TEST_FINAL_CLTV - 40);
4722
- send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[2], &nodes[3]]], 900000 , duplicate_payment_hash, payment_secret);
4721
+ let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[3], payment_params, 800_000 , TEST_FINAL_CLTV - 40);
4722
+ send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[2], &nodes[3]]], 800_000 , duplicate_payment_hash, payment_secret);
4723
4723
4724
4724
let commitment_txn = get_local_commitment_txn!(nodes[2], chan_2.2);
4725
4725
assert_eq!(commitment_txn[0].input.len(), 1);
@@ -4739,25 +4739,35 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
4739
4739
4740
4740
check_spends!(node_txn[0], commitment_txn[0]);
4741
4741
assert_eq!(node_txn[0].input.len(), 1);
4742
+ assert_eq!(node_txn[0].output.len(), 1);
4742
4743
4743
4744
if node_txn.len() > 2 {
4744
4745
check_spends!(node_txn[1], commitment_txn[0]);
4745
4746
assert_eq!(node_txn[1].input.len(), 1);
4747
+ assert_eq!(node_txn[1].output.len(), 1);
4746
4748
assert_eq!(node_txn[0].input[0].previous_output, node_txn[1].input[0].previous_output);
4747
4749
4748
4750
check_spends!(node_txn[2], commitment_txn[0]);
4751
+ assert_eq!(node_txn[2].input.len(), 1);
4752
+ assert_eq!(node_txn[2].output.len(), 1);
4749
4753
assert_ne!(node_txn[0].input[0].previous_output, node_txn[2].input[0].previous_output);
4750
4754
} else {
4751
4755
check_spends!(node_txn[1], commitment_txn[0]);
4756
+ assert_eq!(node_txn[1].input.len(), 1);
4757
+ assert_eq!(node_txn[1].output.len(), 1);
4752
4758
assert_ne!(node_txn[0].input[0].previous_output, node_txn[1].input[0].previous_output);
4753
4759
}
4754
4760
4755
4761
assert_eq!(node_txn[0].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
4756
4762
assert_eq!(node_txn[1].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
4763
+ // Assign htlc_timeout_tx to the forwarded HTLC (with value ~800 sats). The received HTLC
4764
+ // (with value 900 sats) will be claimed in the below `claim_funds` call.
4757
4765
if node_txn.len() > 2 {
4758
4766
assert_eq!(node_txn[2].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
4767
+ htlc_timeout_tx = if node_txn[2].output[0].value < 900 { node_txn[2].clone() } else { node_txn[0].clone() };
4768
+ } else {
4769
+ htlc_timeout_tx = if node_txn[0].output[0].value < 900 { node_txn[1].clone() } else { node_txn[0].clone() };
4759
4770
}
4760
- htlc_timeout_tx = node_txn[0].clone();
4761
4771
}
4762
4772
4763
4773
nodes[2].node.claim_funds(our_payment_preimage);
@@ -4808,7 +4818,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
4808
4818
// Note that the fee paid is effectively double as the HTLC value (including the nodes[1] fee
4809
4819
// and nodes[2] fee) is rounded down and then claimed in full.
4810
4820
mine_transaction(&nodes[1], &htlc_success_txn[1]);
4811
- expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(196*2 ), true, true);
4821
+ expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(196), true, true);
4812
4822
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
4813
4823
assert!(updates.update_add_htlcs.is_empty());
4814
4824
assert!(updates.update_fail_htlcs.is_empty());
0 commit comments