Skip to content

Commit 3856b51

Browse files
committed
Add 0FC case to functional_tests::test_multiple_package_conflicts
1 parent b76476c commit 3856b51

File tree

1 file changed

+15
-44
lines changed

1 file changed

+15
-44
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ use bitcoin::locktime::absolute::LockTime;
6262
use bitcoin::network::Network;
6363
use bitcoin::opcodes;
6464
use bitcoin::script::Builder;
65-
use bitcoin::transaction::Version;
66-
use bitcoin::{Amount, Transaction, TxIn, TxOut};
6765

6866
use bitcoin::secp256k1::Secp256k1;
6967
use bitcoin::secp256k1::{PublicKey, SecretKey};
@@ -1148,65 +1146,27 @@ pub fn claim_htlc_outputs() {
11481146
assert_eq!(nodes[1].node.list_channels().len(), 0);
11491147
}
11501148

1151-
// Test that the HTLC package logic removes HTLCs from the package when they are claimed by the
1152-
// counterparty, even when the counterparty claims HTLCs from multiple packages in a single
1153-
// transaction.
1154-
//
1155-
// This is a regression test for https://github.com/lightningdevkit/rust-lightning/issues/3537.
1156-
#[xtest(feature = "_externalize_tests")]
1157-
pub fn test_multiple_package_conflicts() {
1158-
use crate::events::bump_transaction::sync::WalletSourceSync;
1159-
1149+
pub fn do_test_multiple_package_conflicts(p2a_anchor: bool) {
11601150
let chanmon_cfgs = create_chanmon_cfgs(3);
11611151
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
11621152
let mut user_cfg = test_default_channel_config();
11631153

11641154
// Anchor channels are required so that multiple HTLC-Successes can be aggregated into a single
11651155
// transaction.
11661156
user_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1157+
user_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
11671158
user_cfg.manually_accept_inbound_channels = true;
11681159

11691160
let configs = [Some(user_cfg.clone()), Some(user_cfg.clone()), Some(user_cfg)];
11701161
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &configs);
11711162
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
11721163

1164+
let coinbase_tx = provide_anchor_reserves(&nodes);
1165+
11731166
let node_a_id = nodes[0].node.get_our_node_id();
11741167
let node_b_id = nodes[1].node.get_our_node_id();
11751168
let node_c_id = nodes[2].node.get_our_node_id();
11761169

1177-
// Since we're using anchor channels, make sure each node has a UTXO for paying fees.
1178-
let coinbase_tx = Transaction {
1179-
version: Version::TWO,
1180-
lock_time: LockTime::ZERO,
1181-
input: vec![TxIn { ..Default::default() }],
1182-
output: vec![
1183-
TxOut {
1184-
value: Amount::ONE_BTC,
1185-
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
1186-
},
1187-
TxOut {
1188-
value: Amount::ONE_BTC,
1189-
script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
1190-
},
1191-
TxOut {
1192-
value: Amount::ONE_BTC,
1193-
script_pubkey: nodes[2].wallet_source.get_change_script().unwrap(),
1194-
},
1195-
],
1196-
};
1197-
nodes[0].wallet_source.add_utxo(
1198-
bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 },
1199-
coinbase_tx.output[0].value,
1200-
);
1201-
nodes[1].wallet_source.add_utxo(
1202-
bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 1 },
1203-
coinbase_tx.output[1].value,
1204-
);
1205-
nodes[2].wallet_source.add_utxo(
1206-
bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 2 },
1207-
coinbase_tx.output[2].value,
1208-
);
1209-
12101170
// Create the network.
12111171
// 0 -- 1 -- 2
12121172
//
@@ -1403,6 +1363,17 @@ pub fn test_multiple_package_conflicts() {
14031363
);
14041364
}
14051365

1366+
// Test that the HTLC package logic removes HTLCs from the package when they are claimed by the
1367+
// counterparty, even when the counterparty claims HTLCs from multiple packages in a single
1368+
// transaction.
1369+
//
1370+
// This is a regression test for https://github.com/lightningdevkit/rust-lightning/issues/3537.
1371+
#[xtest(feature = "_externalize_tests")]
1372+
pub fn test_multiple_package_conflicts() {
1373+
do_test_multiple_package_conflicts(false);
1374+
do_test_multiple_package_conflicts(true);
1375+
}
1376+
14061377
#[xtest(feature = "_externalize_tests")]
14071378
pub fn test_htlc_on_chain_success() {
14081379
// Test that in case of a unilateral close onchain, we detect the state of output and pass

0 commit comments

Comments
 (0)