Skip to content

Commit 795a0a6

Browse files
committed
Add 0FC case to functional_tests::test_multiple_package_conflicts
1 parent c498c2c commit 795a0a6

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
@@ -61,8 +61,6 @@ use bitcoin::locktime::absolute::LockTime;
6161
use bitcoin::network::Network;
6262
use bitcoin::opcodes;
6363
use bitcoin::script::Builder;
64-
use bitcoin::transaction::Version;
65-
use bitcoin::{Amount, Transaction, TxIn, TxOut};
6664

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)