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
6689
+
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
6690
+
// which is set to the lower bound (1%) of the `channel_value`.
6691
+
let chan_1 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_1_percent,0,42).unwrap();
6692
+
let chan_1_value_msat = chan_1.channel_value_satoshis*1000;
// Test with the upper bound of valid values (100%).
6696
+
let chan_2 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_100_percent,0,42).unwrap();
6697
+
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());
6701
+
6702
+
// Test that `new_from_req` creates a channel with the correct value for
6703
+
// `holder_max_htlc_value_in_flight_msat`, when configured with a valid percentage value,
6704
+
// which is set to the lower bound (1%) of the `channel_value`.
6705
+
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();
6706
+
let chan_3_value_msat = chan_3.channel_value_satoshis*1000;
// Test with the upper bound of valid values (100%).
6710
+
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();
6711
+
let chan_4_value_msat = chan_4.channel_value_satoshis*1000;
let get_error_string = | percentage_value | {format!(
6716
+
"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 ({})",
6717
+
percentage_value)
6718
+
};
6719
+
6720
+
// Test that `new_outbound` fails when trying to create a channel invalid percentage value
6721
+
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (less than 1).
6722
+
let err_1 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_0_percent,0,42);
6723
+
match err_1 {
6724
+
Err(APIError::APIMisuseError{ err }) => {
6725
+
assert_eq!(err, get_error_string(0));
6726
+
}
6727
+
_ => {panic!("new_outbound should have resulted in APIError::APIMisuseError");}
6728
+
}
6729
+
6730
+
// Test that `new_outbound` fails when trying to create a channel invalid percentage value
6731
+
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (larger than 100).
6732
+
let err_2 = Channel::<EnforcingSigner>::new_outbound(&&feeest,&&keys_provider, outbound_node_id,&InitFeatures::known(),10000000,100000,42,&config_101_percent,0,42);
6733
+
match err_2 {
6734
+
Err(APIError::APIMisuseError{ err }) => {
6735
+
assert_eq!(err, get_error_string(101));
6736
+
}
6737
+
_ => {panic!("new_outbound should have resulted in APIError::APIMisuseError");}
6738
+
}
6739
+
6740
+
// Test that `new_from_req` fails when trying to create a channel invalid percentage value
6741
+
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (less than 1).
6742
+
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);
6743
+
match err_3 {
6744
+
Err(ChannelError::Close(err)) => {
6745
+
assert_eq!(err, get_error_string(0));
6746
+
}
6747
+
_ => {panic!("new_from_req should have resulted in ChannelError::Close");}
6748
+
}
6749
+
6750
+
// Test that `new_from_req` fails when trying to create a channel invalid percentage value
6751
+
// set for `holder_max_htlc_value_in_flight_msat_channel_value_percent` (larger than 100).
6752
+
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);
6753
+
match err_4 {
6754
+
Err(ChannelError::Close(err)) => {
6755
+
assert_eq!(err, get_error_string(101));
6756
+
}
6757
+
_ => {panic!("new_from_req should have resulted in ChannelError::Close");}
0 commit comments