This commit is contained in:
Carsten Otto
2022-05-22 16:14:12 +02:00
parent 3c50596437
commit 59365f34ef
2 changed files with 19 additions and 2 deletions

View File

@@ -73,8 +73,7 @@ public class MultiPathPaymentSplitter {
List<Route> routes = getWithLiquidityInformation(extendedBasicRoutes);
List<Route> fixedRoutes = Routes.getFixedWithTotalAmount(routes, amount);
boolean isTooExpensive = isTooExpensive(paymentOptions, fixedRoutes);
if (isTooExpensive) {
if (isTooExpensive(paymentOptions, fixedRoutes)) {
return MultiPathPayment.FAILURE;
}
return new MultiPathPayment(fixedRoutes);

View File

@@ -163,6 +163,24 @@ class MultiPathPaymentSplitterTest {
assertThat(multiPathPayment.isFailure()).isTrue();
}
@Test
void fee_rate_at_limit_excluding_fees_from_first_hop() {
int feeRate = 200;
Coins amount = Coins.ofSatoshis(3_000_000);
Policy policy = policyFor(feeRate);
PaymentOptions paymentOptions = PaymentOptions.forFeeRateLimit(feeRate);
Flow firstEdgeFlow = new Flow(firstEdge, amount);
Edge edge = new Edge(CHANNEL_ID_2, PUBKEY_2, PUBKEY_4, CAPACITY, policy);
Flow flow = new Flow(edge, amount);
addEdgeWithoutInformation(edge);
when(flowComputation.getOptimalFlows(PUBKEY, PUBKEY_4, amount, paymentOptions))
.thenReturn(new Flows(firstEdgeFlow, flow));
MultiPathPayment multiPathPayment =
multiPathPaymentSplitter.getMultiPathPayment(PUBKEY, PUBKEY_4, amount, paymentOptions);
assertThat(multiPathPayment.isFailure()).isFalse();
}
@Test
void one_flow_has_fee_rate_above_limit_but_average_fee_rate_is_below_limit_including_fees_from_first_hop() {
mockExtensionEdge(PUBKEY_4);