Skip to content

Commit 855f4ca

Browse files
committed
ln/refactor: add helper function for channel type tests
1 parent 28a9735 commit 855f4ca

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
@@ -13155,6 +13155,17 @@ mod tests {
1315513155
fn test_supports_anchors_zero_htlc_tx_fee() {
1315613156
// Tests that if both sides support and negotiate `anchors_zero_fee_htlc_tx`, it is the
1315713157
// resulting `channel_type`.
13158+
let mut config = UserConfig::default();
13159+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
13160+
13161+
let mut expected_channel_type = ChannelTypeFeatures::empty();
13162+
expected_channel_type.set_static_remote_key_required();
13163+
expected_channel_type.set_anchors_zero_fee_htlc_tx_required();
13164+
13165+
do_test_supports_channel_type(config, expected_channel_type)
13166+
}
13167+
13168+
fn do_test_supports_channel_type(config: UserConfig, expected_channel_type: ChannelTypeFeatures) {
1315813169
let secp_ctx = Secp256k1::new();
1315913170
let fee_estimator = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
1316013171
let network = Network::Testnet;
@@ -13164,21 +13175,13 @@ mod tests {
1316413175
let node_id_a = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[1; 32]).unwrap());
1316513176
let node_id_b = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[2; 32]).unwrap());
1316613177

13167-
let mut config = UserConfig::default();
13168-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
13169-
13170-
// It is not enough for just the initiator to signal `option_anchors_zero_fee_htlc_tx`, both
13171-
// need to signal it.
13178+
// Assert that we get `static_remotekey` when no custom config is negotiated.
1317213179
let channel_a = OutboundV1Channel::<&TestKeysInterface>::new(
1317313180
&fee_estimator, &&keys_provider, &&keys_provider, node_id_b,
1317413181
&channelmanager::provided_init_features(&UserConfig::default()), 10000000, 100000, 42,
1317513182
&config, 0, 42, None, &logger
1317613183
).unwrap();
13177-
assert!(!channel_a.funding.get_channel_type().supports_anchors_zero_fee_htlc_tx());
13178-
13179-
let mut expected_channel_type = ChannelTypeFeatures::empty();
13180-
expected_channel_type.set_static_remote_key_required();
13181-
expected_channel_type.set_anchors_zero_fee_htlc_tx_required();
13184+
assert_eq!(channel_a.funding.get_channel_type(), &ChannelTypeFeatures::only_static_remote_key());
1318213185

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

0 commit comments

Comments
 (0)