Skip to content

Commit 532ee9b

Browse files
committed
ln/refactor: add helper function for channel type tests
1 parent 267f736 commit 532ee9b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13318,6 +13318,17 @@ mod tests {
1331813318
fn test_supports_anchors_zero_htlc_tx_fee() {
1331913319
// Tests that if both sides support and negotiate `anchors_zero_fee_htlc_tx`, it is the
1332013320
// resulting `channel_type`.
13321+
let mut config = UserConfig::default();
13322+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
13323+
13324+
let mut expected_channel_type = ChannelTypeFeatures::empty();
13325+
expected_channel_type.set_static_remote_key_required();
13326+
expected_channel_type.set_anchors_zero_fee_htlc_tx_required();
13327+
13328+
do_test_supports_channel_type(config, expected_channel_type)
13329+
}
13330+
13331+
fn do_test_supports_channel_type(config: UserConfig, expected_channel_type: ChannelTypeFeatures) {
1332113332
let secp_ctx = Secp256k1::new();
1332213333
let fee_estimator = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
1332313334
let network = Network::Testnet;
@@ -13327,21 +13338,13 @@ mod tests {
1332713338
let node_id_a = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[1; 32]).unwrap());
1332813339
let node_id_b = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[2; 32]).unwrap());
1332913340

13330-
let mut config = UserConfig::default();
13331-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
13332-
13333-
// It is not enough for just the initiator to signal `option_anchors_zero_fee_htlc_tx`, both
13334-
// need to signal it.
13341+
// Assert that we get `static_remotekey` when no custom config is negotiated.
1333513342
let channel_a = OutboundV1Channel::<&TestKeysInterface>::new(
1333613343
&fee_estimator, &&keys_provider, &&keys_provider, node_id_b,
1333713344
&channelmanager::provided_init_features(&UserConfig::default()), 10000000, 100000, 42,
1333813345
&config, 0, 42, None, &logger
1333913346
).unwrap();
13340-
assert!(!channel_a.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx());
13341-
13342-
let mut expected_channel_type = ChannelTypeFeatures::empty();
13343-
expected_channel_type.set_static_remote_key_required();
13344-
expected_channel_type.set_anchors_zero_fee_htlc_tx_required();
13347+
assert_eq!(channel_a.funding.get_channel_type(), &ChannelTypeFeatures::only_static_remote_key());
1334513348

1334613349
let mut channel_a = OutboundV1Channel::<&TestKeysInterface>::new(
1334713350
&fee_estimator, &&keys_provider, &&keys_provider, node_id_b,

0 commit comments

Comments
 (0)