add toString

This commit is contained in:
Carsten Otto
2022-05-22 23:32:58 +02:00
parent f4b146da58
commit 7a784f90bc
2 changed files with 19 additions and 0 deletions

View File

@@ -124,6 +124,15 @@ public class Route {
return Objects.hash(edgesWithLiquidityInformation, amount, feesForHops);
}
@Override
public String toString() {
return "Route{" +
"edgesWithLiquidityInformation=" + edgesWithLiquidityInformation +
", amount=" + amount +
", feesForHops=" + feesForHops +
'}';
}
private static List<Coins> computeFees(List<EdgeWithLiquidityInformation> edges, Coins amount) {
Coins fees = Coins.NONE;
Coins amountWithFees = amount;

View File

@@ -466,6 +466,16 @@ class RouteTest {
EqualsVerifier.forClass(Route.class).usingGetClass().verify();
}
@Test
void testToString() {
assertThat(ROUTE).hasToString("Route{edgesWithLiquidityInformation=[" +
EdgeWithLiquidityInformation.forUpperBound(EDGE, EDGE.capacity()) + ", " +
EdgeWithLiquidityInformation.forUpperBound(EDGE_2_3, EDGE_2_3.capacity()) + ", " +
EdgeWithLiquidityInformation.forUpperBound(EDGE_3_4, EDGE_3_4.capacity()) +
"], amount=100.000, feesForHops=[0.020, 0.020, 0.000]}"
);
}
private Route routeForAmountAndCapacityAndKnownLiquidity(int amountSat, int capacitySat, int knownLiquiditySat) {
Coins capacity = Coins.ofSatoshis(capacitySat);
Coins amount = Coins.ofSatoshis(amountSat);