Skip to content

Commit a832a55

Browse files
committed
ln/refactor: add helper function for channel type tests
1 parent 97d9d51 commit a832a55

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
@@ -13320,6 +13320,17 @@ mod tests {
1332013320
fn test_supports_anchors_zero_htlc_tx_fee() {
1332113321
// Tests that if both sides support and negotiate `anchors_zero_fee_htlc_tx`, it is the
1332213322
// resulting `channel_type`.
13323+
let mut config = UserConfig::default();
13324+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
13325+
13326+
let mut expected_channel_type = ChannelTypeFeatures::empty();
13327+
expected_channel_type.set_static_remote_key_required();
13328+
expected_channel_type.set_anchors_zero_fee_htlc_tx_required();
13329+
13330+
do_test_supports_channel_type(config, expected_channel_type)
13331+
}
13332+
13333+
fn do_test_supports_channel_type(config: UserConfig, expected_channel_type: ChannelTypeFeatures) {
1332313334
let secp_ctx = Secp256k1::new();
1332413335
let fee_estimator = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
1332513336
let network = Network::Testnet;
@@ -13329,21 +13340,13 @@ mod tests {
1332913340
let node_id_a = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[1; 32]).unwrap());
1333013341
let node_id_b = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[2; 32]).unwrap());
1333113342

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

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

0 commit comments

Comments
 (0)