Skip to content

Commit baf84c2

Browse files
committed
Fix test_bump_penalty_txn_on_remote_commitment
1 parent 371a42c commit baf84c2

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

lightning/src/ln/functional_tests.rs

+25-16
Original file line numberDiff line numberDiff line change
@@ -7923,22 +7923,31 @@ fn test_bump_penalty_txn_on_remote_commitment() {
79237923
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
79247924
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
79257925

7926-
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000);
7927-
let (payment_preimage, payment_hash, ..) = route_payment(&nodes[0], &[&nodes[1]], 3_000_000);
7928-
route_payment(&nodes[1], &vec!(&nodes[0])[..], 3000000).0;
7929-
7930-
// Remote commitment txn with 4 outputs : to_local, to_remote, 1 outgoing HTLC, 1 incoming HTLC
7931-
let remote_txn = get_local_commitment_txn!(nodes[0], chan.2);
7932-
assert_eq!(remote_txn[0].output.len(), 4);
7933-
assert_eq!(remote_txn[0].input.len(), 1);
7934-
assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
7935-
7936-
// Claim a HTLC without revocation (provide B monitor with preimage)
7937-
nodes[1].node.claim_funds(payment_preimage);
7938-
expect_payment_claimed!(nodes[1], payment_hash, 3_000_000);
7939-
mine_transaction(&nodes[1], &remote_txn[0]);
7940-
check_added_monitors!(nodes[1], 2);
7941-
connect_blocks(&nodes[1], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
7926+
let remote_txn = {
7927+
// post-bump fee (288 satoshis) + dust threshold for output type (294 satoshis) = 582
7928+
let htlc_value_a_msats = 582_000;
7929+
let htlc_value_b_msats = 583_000;
7930+
7931+
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 59000000);
7932+
let (payment_preimage, payment_hash, ..) = route_payment(&nodes[0], &[&nodes[1]], htlc_value_a_msats);
7933+
route_payment(&nodes[1], &vec!(&nodes[0])[..], htlc_value_b_msats);
7934+
7935+
// Remote commitment txn with 4 outputs : to_local, to_remote, 1 outgoing HTLC, 1 incoming HTLC
7936+
let remote_txn = get_local_commitment_txn!(nodes[0], chan.2);
7937+
assert_eq!(remote_txn[0].output.len(), 4);
7938+
assert_eq!(remote_txn[0].input.len(), 1);
7939+
assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
7940+
7941+
// Claim a HTLC without revocation (provide B monitor with preimage)
7942+
nodes[1].node.claim_funds(payment_preimage);
7943+
expect_payment_claimed!(nodes[1], payment_hash, htlc_value_a_msats);
7944+
mine_transaction(&nodes[1], &remote_txn[0]);
7945+
check_added_monitors!(nodes[1], 2);
7946+
connect_blocks(&nodes[1], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
7947+
// depending on the block connection style, node 1 may have broadcast either 3 or 10 txs
7948+
7949+
remote_txn
7950+
};
79427951

79437952
// One or more claim tx should have been broadcast, check it
79447953
let timeout;

0 commit comments

Comments
 (0)