You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Test that `new_outbound` creates a channel with the correct value for
6673
6673
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
6674
-
// which is set to the lower bound (1%) of the `channel_value`.
6675
-
let chan_1 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_1_percent,0,42).unwrap();
6674
+
// which is set to the lower bound + 1 (2%) of the `channel_value`.
6675
+
let chan_1 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_2_percent,0,42).unwrap();
6676
6676
let chan_1_value_msat = chan_1.channel_value_satoshis*1000;
// Test with the upper bound of valid values (100%).
6680
-
let chan_2 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_100_percent,0,42).unwrap();
6679
+
// Test with the upper bound - 1 of valid values (99%).
6680
+
let chan_2 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_99_percent,0,42).unwrap();
6681
6681
let chan_2_value_msat = chan_2.channel_value_satoshis*1000;
let chan_1_open_channel_msg = chan_1.get_open_channel(genesis_block(network).header.block_hash());
6685
6685
6686
6686
// Test that `new_from_req` creates a channel with the correct value for
6687
6687
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
6688
-
// which is set to the lower bound (1%) of the `channel_value`.
6689
-
let chan_3 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_1_percent,0,&&logger,42).unwrap();
6688
+
// which is set to the lower bound - 1 (2%) of the `channel_value`.
6689
+
let chan_3 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_2_percent,0,&&logger,42).unwrap();
6690
6690
let chan_3_value_msat = chan_3.channel_value_satoshis*1000;
// Test with the upper bound of valid values (100%).
6694
-
let chan_4 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_100_percent,0,&&logger,42).unwrap();
6693
+
// Test with the upper bound - 1 of valid values (99%).
6694
+
let chan_4 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_99_percent,0,&&logger,42).unwrap();
6695
6695
let chan_4_value_msat = chan_4.channel_value_satoshis*1000;
let get_error_string = | percentage_value | {format!(
6700
-
"UserConfig::channel_options::holder_max_htlc_value_in_flight_msat_channel_value_percent must be set to a value between 1-100. Current value set ({})",
6701
-
percentage_value)
6702
-
};
6703
-
6704
-
// Test that `new_outbound` fails when trying to create a channel invalid percentage value
6705
-
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (less than 1).
6706
-
let err_1 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_0_percent,0,42);
6707
-
match err_1 {
6708
-
Err(APIError::APIMisuseError{ err }) => {
6709
-
assert_eq!(err, get_error_string(0));
6710
-
}
6711
-
_ => {panic!("new_outbound should have resulted in APIError::APIMisuseError");}
6712
-
}
6713
-
6714
-
// Test that `new_outbound` fails when trying to create a channel invalid percentage value
6715
-
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (larger than 100).
6716
-
let err_2 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_101_percent,0,42);
6717
-
match err_2 {
6718
-
Err(APIError::APIMisuseError{ err }) => {
6719
-
assert_eq!(err, get_error_string(101));
6720
-
}
6721
-
_ => {panic!("new_outbound should have resulted in APIError::APIMisuseError");}
6722
-
}
6723
-
6724
-
// Test that `new_from_req` fails when trying to create a channel invalid percentage value
6725
-
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (less than 1).
6726
-
let err_3 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_0_percent,0,&&logger,42);
6727
-
match err_3 {
6728
-
Err(ChannelError::Close(err)) => {
6729
-
assert_eq!(err, get_error_string(0));
6730
-
}
6731
-
_ => {panic!("new_from_req should have resulted in ChannelError::Close");}
6732
-
}
6733
-
6734
-
// Test that `new_from_req` fails when trying to create a channel invalid percentage value
6735
-
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (larger than 100).
6736
-
let err_4 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_101_percent,0,&&logger,42);
6737
-
match err_4 {
6738
-
Err(ChannelError::Close(err)) => {
6739
-
assert_eq!(err, get_error_string(101));
6740
-
}
6741
-
_ => {panic!("new_from_req should have resulted in ChannelError::Close");}
// Test that `new_outbound` uses the lower bound of the configurable percentage values (1%)
6699
+
// if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a value less than 1.
6700
+
let chan_5 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_0_percent,0,42).unwrap();
6701
+
let chan_5_value_msat = chan_5.channel_value_satoshis*1000;
// Test that `new_outbound` uses the upper bound of the configurable percentage values
6705
+
// (100%) if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a larger value
6706
+
// than 100.
6707
+
let chan_6 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_101_percent,0,42).unwrap();
6708
+
let chan_6_value_msat = chan_6.channel_value_satoshis*1000;
// Test that `new_from_req` uses the lower bound of the configurable percentage values (1%)
6712
+
// if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a value less than 1.
6713
+
let chan_7 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_0_percent,0,&&logger,42).unwrap();
6714
+
let chan_7_value_msat = chan_7.channel_value_satoshis*1000;
// Test that `new_from_req` uses the upper bound of the configurable percentage values
6718
+
// (100%) if `max_inbound_htlc_value_in_flight_percent_of_channel` is set to a larger value
6719
+
// than 100.
6720
+
let chan_8 = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_1_open_channel_msg,7,&config_101_percent,0,&&logger,42).unwrap();
6721
+
let chan_8_value_msat = chan_8.channel_value_satoshis*1000;
0 commit comments