@@ -9891,8 +9891,8 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
9891
9891
// Default test fee estimator rate is 253 sat/kw, so we set the multiplier to 5_000_000 / 253
9892
9892
// to get roughly the same initial value as the default setting when this test was
9893
9893
// originally written.
9894
- MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253)
9895
- } else { MaxDustHTLCExposure::FixedLimitMsat(5_000_000 ) }; // initial default setting value
9894
+ MaxDustHTLCExposure::FeeRateMultiplier(6_000_000 / 253)
9895
+ } else { MaxDustHTLCExposure::FixedLimitMsat(6_000_000 ) }; // initial default setting value
9896
9896
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
9897
9897
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config), None]);
9898
9898
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -9901,6 +9901,8 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
9901
9901
let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
9902
9902
open_channel.common_fields.max_htlc_value_in_flight_msat = 50_000_000;
9903
9903
open_channel.common_fields.max_accepted_htlcs = 60;
9904
+ // --
9905
+
9904
9906
if on_holder_tx {
9905
9907
open_channel.common_fields.dust_limit_satoshis = 546;
9906
9908
}
@@ -9935,18 +9937,21 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
9935
9937
let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
9936
9938
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
9937
9939
update_nodes_with_chan_announce(&nodes, 0, 1, &announcement, &as_update, &bs_update);
9940
+ // Node A < - > Node B channel is now established
9938
9941
9939
9942
// Fetch a route in advance as we will be unable to once we're unable to send.
9940
9943
let (mut route, payment_hash, _, payment_secret) =
9941
9944
get_route_and_payment_hash!(nodes[0], nodes[1], 1000);
9942
9945
9946
+
9943
9947
let (dust_buffer_feerate, max_dust_htlc_exposure_msat) = {
9944
9948
let per_peer_state = nodes[0].node.per_peer_state.read().unwrap();
9945
9949
let chan_lock = per_peer_state.get(&nodes[1].node.get_our_node_id()).unwrap().lock().unwrap();
9946
9950
let chan = chan_lock.channel_by_id.get(&channel_id).unwrap();
9947
9951
(chan.context().get_dust_buffer_feerate(None) as u64,
9948
9952
chan.context().get_max_dust_htlc_exposure_msat(&LowerBoundedFeeEstimator(nodes[0].fee_estimator)))
9949
9953
};
9954
+
9950
9955
let dust_outbound_htlc_on_holder_tx_msat: u64 = (dust_buffer_feerate * htlc_timeout_tx_weight(&channel_type_features) / 1000 + open_channel.common_fields.dust_limit_satoshis - 1) * 1000;
9951
9956
let dust_outbound_htlc_on_holder_tx: u64 = max_dust_htlc_exposure_msat / dust_outbound_htlc_on_holder_tx_msat;
9952
9957
@@ -10032,7 +10037,7 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
10032
10037
// For the multiplier dust exposure limit, since it scales with feerate,
10033
10038
// we need to add a lot of HTLCs that will become dust at the new feerate
10034
10039
// to cross the threshold.
10035
- for _ in 0..20 {
10040
+ for _ in 0..30 {
10036
10041
let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[1], Some(1_000), None);
10037
10042
nodes[0].node.send_payment_with_route(&route, payment_hash,
10038
10043
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
@@ -10054,12 +10059,12 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
10054
10059
fn do_test_max_dust_htlc_exposure_by_threshold_type(multiplier_dust_limit: bool) {
10055
10060
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
10056
10061
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
10062
+ do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10063
+ do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10057
10064
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCReception, true, multiplier_dust_limit);
10058
10065
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCReception, false, multiplier_dust_limit);
10059
- do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10060
10066
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCReception, false, multiplier_dust_limit);
10061
10067
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCReception, true, multiplier_dust_limit);
10062
- do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10063
10068
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, true, multiplier_dust_limit);
10064
10069
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);
10065
10070
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);
@@ -10068,7 +10073,7 @@ fn do_test_max_dust_htlc_exposure_by_threshold_type(multiplier_dust_limit: bool)
10068
10073
10069
10074
#[test]
10070
10075
fn test_max_dust_htlc_exposure() {
10071
- do_test_max_dust_htlc_exposure_by_threshold_type(false);
10076
+ do_test_max_dust_htlc_exposure_by_threshold_type(false);
10072
10077
do_test_max_dust_htlc_exposure_by_threshold_type(true);
10073
10078
}
10074
10079
0 commit comments