mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-31 11:44:33 +01:00
add channel policy to edge
This commit is contained in:
@@ -3,14 +3,14 @@ package de.cotto.lndmanagej.model;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICIES_FOR_LOCAL_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_2;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_DISABLED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PoliciesForLocalChannelTest {
|
||||
@Test
|
||||
void local() {
|
||||
assertThat(POLICIES_FOR_LOCAL_CHANNEL.local()).isEqualTo(POLICY_1);
|
||||
assertThat(POLICIES_FOR_LOCAL_CHANNEL.local()).isEqualTo(POLICY_DISABLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.cotto.lndmanagej.model;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_DISABLED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PolicyTest {
|
||||
@@ -18,7 +19,12 @@ class PolicyTest {
|
||||
|
||||
@Test
|
||||
void enabled() {
|
||||
assertThat(POLICY_1.enabled()).isFalse();
|
||||
assertThat(POLICY_1.enabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void disabled() {
|
||||
assertThat(POLICY_DISABLED.enabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package de.cotto.lndmanagej.model;
|
||||
|
||||
public class PolicyFixtures {
|
||||
public static final Policy POLICY_1 = new Policy(100, Coins.ofMilliSatoshis(10), false);
|
||||
public static final Policy POLICY_1 = new Policy(100, Coins.ofMilliSatoshis(10), true);
|
||||
public static final Policy POLICY_DISABLED = new Policy(100, Coins.ofMilliSatoshis(10), false);
|
||||
public static final Policy POLICY_2 = new Policy(222, Coins.ofMilliSatoshis(0), true);
|
||||
|
||||
public static final PoliciesForLocalChannel POLICIES_FOR_LOCAL_CHANNEL =
|
||||
new PoliciesForLocalChannel(POLICY_1, POLICY_2);
|
||||
new PoliciesForLocalChannel(POLICY_DISABLED, POLICY_2);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class FlowComputation {
|
||||
ChannelId channelId = channelEdge.channelId();
|
||||
Pubkey pubkey1 = channelEdge.source();
|
||||
Pubkey pubkey2 = channelEdge.target();
|
||||
Edge edge = new Edge(channelId, pubkey1, pubkey2, channelEdge.capacity());
|
||||
Edge edge = new Edge(channelId, pubkey1, pubkey2, channelEdge.capacity(), channelEdge.policy());
|
||||
Coins availableCapacity = getAvailableCapacity(channelEdge, ownPubkey);
|
||||
EdgeWithCapacityInformation edgeWithCapacityInformation =
|
||||
new EdgeWithCapacityInformation(edge, availableCapacity);
|
||||
|
||||
@@ -2,7 +2,8 @@ package de.cotto.lndmanagej.pickhardtpayments.model;
|
||||
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.Policy;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
|
||||
public record Edge(ChannelId channelId, Pubkey startNode, Pubkey endNode, Coins capacity) {
|
||||
public record Edge(ChannelId channelId, Pubkey startNode, Pubkey endNode, Coins capacity, Policy policy) {
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_2;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_DISABLED;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_3;
|
||||
@@ -82,8 +83,9 @@ class FlowComputationTest {
|
||||
|
||||
@Test
|
||||
void solve_edge_disabled() {
|
||||
DirectedChannelEdge disabledEdge = new DirectedChannelEdge(CHANNEL_ID, CAPACITY, PUBKEY, PUBKEY_2, POLICY_1);
|
||||
assumeThat(POLICY_1.enabled()).isFalse();
|
||||
DirectedChannelEdge disabledEdge =
|
||||
new DirectedChannelEdge(CHANNEL_ID, CAPACITY, PUBKEY, PUBKEY_2, POLICY_DISABLED);
|
||||
assumeThat(POLICY_DISABLED.enabled()).isFalse();
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(disabledEdge)));
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY, PUBKEY_2, Coins.ofSatoshis(1))).isEqualTo(new Flows());
|
||||
}
|
||||
@@ -93,7 +95,7 @@ class FlowComputationTest {
|
||||
Coins amount = Coins.ofSatoshis(1);
|
||||
DirectedChannelEdge enabledEdge = new DirectedChannelEdge(CHANNEL_ID, CAPACITY, PUBKEY, PUBKEY_2, POLICY_2);
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(enabledEdge)));
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY), amount);
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY, PUBKEY_2, amount)).isEqualTo(new Flows(expectedFlow));
|
||||
}
|
||||
|
||||
@@ -105,14 +107,14 @@ class FlowComputationTest {
|
||||
when(balanceService.getAvailableLocalBalance(CHANNEL_ID)).thenReturn(Coins.ofSatoshis(1));
|
||||
Coins amount = Coins.ofSatoshis(100);
|
||||
DirectedChannelEdge largerButDepletedChannel =
|
||||
new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY, PUBKEY_2, POLICY_2);
|
||||
new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY, PUBKEY_2, POLICY_1);
|
||||
DirectedChannelEdge smallerChannel =
|
||||
new DirectedChannelEdge(CHANNEL_ID_2, SMALL, PUBKEY, PUBKEY_2, POLICY_2);
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(
|
||||
largerButDepletedChannel,
|
||||
smallerChannel
|
||||
)));
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, SMALL), amount);
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, SMALL, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY, PUBKEY_2, amount)).isEqualTo(new Flows(expectedFlow));
|
||||
}
|
||||
|
||||
@@ -124,14 +126,14 @@ class FlowComputationTest {
|
||||
when(balanceService.getAvailableRemoteBalance(CHANNEL_ID)).thenReturn(Coins.ofSatoshis(1));
|
||||
Coins amount = Coins.ofSatoshis(100);
|
||||
DirectedChannelEdge largerButDepletedChannel =
|
||||
new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY_2, PUBKEY, POLICY_2);
|
||||
new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY_2, PUBKEY, POLICY_1);
|
||||
DirectedChannelEdge smallerChannel =
|
||||
new DirectedChannelEdge(CHANNEL_ID_2, SMALL, PUBKEY_2, PUBKEY, POLICY_2);
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(
|
||||
largerButDepletedChannel,
|
||||
smallerChannel
|
||||
)));
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_2, PUBKEY_2, PUBKEY, SMALL), amount);
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_2, PUBKEY_2, PUBKEY, SMALL, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY_2, PUBKEY, amount)).isEqualTo(new Flows(expectedFlow));
|
||||
}
|
||||
|
||||
@@ -140,20 +142,20 @@ class FlowComputationTest {
|
||||
Coins amount = Coins.ofSatoshis(100);
|
||||
DirectedChannelEdge edge = new DirectedChannelEdge(CHANNEL_ID, CAPACITY, PUBKEY_2, PUBKEY_3, POLICY_2);
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(edge)));
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID, PUBKEY_2, PUBKEY_3, CAPACITY), amount);
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID, PUBKEY_2, PUBKEY_3, CAPACITY, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY_2, PUBKEY_3, amount)).isEqualTo(new Flows(expectedFlow));
|
||||
}
|
||||
|
||||
@Test
|
||||
void solve_with_recent_mission_control_failure_as_upper_bound() {
|
||||
Coins amount = Coins.ofSatoshis(100);
|
||||
DirectedChannelEdge edge1a = new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY_2, PUBKEY_3, POLICY_2);
|
||||
DirectedChannelEdge edge1b = new DirectedChannelEdge(CHANNEL_ID_2, LARGE, PUBKEY_3, PUBKEY_4, POLICY_2);
|
||||
DirectedChannelEdge edge1a = new DirectedChannelEdge(CHANNEL_ID, LARGE, PUBKEY_2, PUBKEY_3, POLICY_1);
|
||||
DirectedChannelEdge edge1b = new DirectedChannelEdge(CHANNEL_ID_2, LARGE, PUBKEY_3, PUBKEY_4, POLICY_1);
|
||||
DirectedChannelEdge edge2 = new DirectedChannelEdge(CHANNEL_ID_3, SMALL, PUBKEY_2, PUBKEY_4, POLICY_2);
|
||||
when(missionControlService.getMinimumOfRecentFailures(PUBKEY_2, PUBKEY_3))
|
||||
.thenReturn(Optional.of(Coins.ofSatoshis(100)));
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(edge1a, edge1b, edge2)));
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY_4, SMALL), amount);
|
||||
Flow expectedFlow = new Flow(new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY_4, SMALL, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY_2, PUBKEY_4, amount)).isEqualTo(new Flows(expectedFlow));
|
||||
}
|
||||
|
||||
@@ -166,8 +168,8 @@ class FlowComputationTest {
|
||||
when(missionControlService.getMinimumOfRecentFailures(PUBKEY_3, PUBKEY_4))
|
||||
.thenReturn(Optional.of(Coins.ofSatoshis(5_000_000)));
|
||||
when(grpcGraph.getChannelEdges()).thenReturn(Optional.of(Set.of(edge1a, edge1b, edge2)));
|
||||
Flow expectedFlow1 = new Flow(new Edge(CHANNEL_ID, PUBKEY_3, PUBKEY_4, LARGE), amount);
|
||||
Flow expectedFlow2 = new Flow(new Edge(CHANNEL_ID_2, PUBKEY_4, PUBKEY, LARGE), amount);
|
||||
Flow expectedFlow1 = new Flow(new Edge(CHANNEL_ID, PUBKEY_3, PUBKEY_4, LARGE, POLICY_2), amount);
|
||||
Flow expectedFlow2 = new Flow(new Edge(CHANNEL_ID_2, PUBKEY_4, PUBKEY, LARGE, POLICY_2), amount);
|
||||
assertThat(flowComputation.getOptimalFlows(PUBKEY_3, PUBKEY, amount))
|
||||
.isEqualTo(new Flows(expectedFlow1, expectedFlow2));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelFixtures.CAPACITY;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static de.cotto.lndmanagej.pickhardtpayments.model.EdgeFixtures.EDGE;
|
||||
@@ -29,4 +30,9 @@ class EdgeTest {
|
||||
void capacity() {
|
||||
assertThat(EDGE.capacity()).isEqualTo(CAPACITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
void policy() {
|
||||
assertThat(EDGE.policy()).isEqualTo(POLICY_1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelFixtures.CAPACITY;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.pickhardtpayments.model.EdgeFixtures.EDGE;
|
||||
import static de.cotto.lndmanagej.pickhardtpayments.model.FlowFixtures.FLOW;
|
||||
@@ -29,7 +30,7 @@ class FlowTest {
|
||||
@Test
|
||||
void source_and_target_must_be_different() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> new Flow(new Edge(CHANNEL_ID, PUBKEY, PUBKEY, CAPACITY), Coins.ofSatoshis(1))
|
||||
() -> new Flow(new Edge(CHANNEL_ID, PUBKEY, PUBKEY, CAPACITY, POLICY_1), Coins.ofSatoshis(1))
|
||||
).withMessage("Source and target must be different");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_2;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_4;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_5;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_3;
|
||||
@@ -158,11 +159,11 @@ class FlowsTest {
|
||||
@Test
|
||||
void getShortestPath_complex() {
|
||||
Coins coins = Coins.ofSatoshis(1);
|
||||
Edge edge1to2 = new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY);
|
||||
Edge edge2to3 = new Edge(CHANNEL_ID_2, PUBKEY_2, PUBKEY_3, CAPACITY);
|
||||
Edge edge2to1 = new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY, CAPACITY);
|
||||
Edge edge1to3 = new Edge(CHANNEL_ID_4, PUBKEY, PUBKEY_3, CAPACITY);
|
||||
Edge edge3to4 = new Edge(CHANNEL_ID_5, PUBKEY_3, PUBKEY_4, CAPACITY);
|
||||
Edge edge1to2 = new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1);
|
||||
Edge edge2to3 = new Edge(CHANNEL_ID_2, PUBKEY_2, PUBKEY_3, CAPACITY, POLICY_1);
|
||||
Edge edge2to1 = new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY, CAPACITY, POLICY_1);
|
||||
Edge edge1to3 = new Edge(CHANNEL_ID_4, PUBKEY, PUBKEY_3, CAPACITY, POLICY_1);
|
||||
Edge edge3to4 = new Edge(CHANNEL_ID_5, PUBKEY_3, PUBKEY_4, CAPACITY, POLICY_1);
|
||||
Flows flows = new Flows(
|
||||
new Flow(edge1to2, coins),
|
||||
new Flow(edge2to3, coins),
|
||||
|
||||
@@ -11,6 +11,7 @@ import static de.cotto.lndmanagej.model.ChannelFixtures.CAPACITY;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_2;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_3;
|
||||
@@ -67,7 +68,7 @@ class RoutesTest {
|
||||
void fromFlows_two_channels_joining() {
|
||||
Edge edge1a = createEdgeWithChannelId(CHANNEL_ID);
|
||||
Edge edge1b = createEdgeWithChannelId(CHANNEL_ID_2);
|
||||
Edge edge2 = new Edge(CHANNEL_ID, PUBKEY_2, PUBKEY_3, CAPACITY);
|
||||
Edge edge2 = new Edge(CHANNEL_ID, PUBKEY_2, PUBKEY_3, CAPACITY, POLICY_1);
|
||||
flows.add(edge1a, Coins.ofSatoshis(10));
|
||||
flows.add(edge1b, Coins.ofSatoshis(10));
|
||||
flows.add(edge2, Coins.ofSatoshis(20));
|
||||
@@ -88,20 +89,20 @@ class RoutesTest {
|
||||
@Test
|
||||
void ensureTotalAmount_adds_to_route_with_highest_probability() {
|
||||
Flows flows = new Flows();
|
||||
flows.add(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY), Coins.ofSatoshis(2));
|
||||
flows.add(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, CAPACITY), Coins.ofSatoshis(1));
|
||||
flows.add(new Edge(CHANNEL_ID_3, PUBKEY, PUBKEY_2, CAPACITY), Coins.ofSatoshis(3));
|
||||
flows.add(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1), Coins.ofSatoshis(2));
|
||||
flows.add(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1), Coins.ofSatoshis(1));
|
||||
flows.add(new Edge(CHANNEL_ID_3, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1), Coins.ofSatoshis(3));
|
||||
Set<Route> routes = Routes.fromFlows(PUBKEY, PUBKEY_2, flows);
|
||||
Routes.ensureTotalAmount(routes, Coins.ofSatoshis(7));
|
||||
assertThat(routes).containsExactlyInAnyOrder(
|
||||
new Route(List.of(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY)), Coins.ofSatoshis(2)),
|
||||
new Route(List.of(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, CAPACITY)), Coins.ofSatoshis(2)),
|
||||
new Route(List.of(new Edge(CHANNEL_ID_3, PUBKEY, PUBKEY_2, CAPACITY)), Coins.ofSatoshis(3))
|
||||
new Route(List.of(new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1)), Coins.ofSatoshis(2)),
|
||||
new Route(List.of(new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1)), Coins.ofSatoshis(2)),
|
||||
new Route(List.of(new Edge(CHANNEL_ID_3, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1)), Coins.ofSatoshis(3))
|
||||
);
|
||||
}
|
||||
|
||||
private Edge createEdgeWithChannelId(ChannelId channelId) {
|
||||
return new Edge(channelId, PUBKEY, PUBKEY_2, CAPACITY);
|
||||
return new Edge(channelId, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,15 +7,16 @@ import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_2;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_4;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_5;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_3;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_4;
|
||||
|
||||
public class EdgeFixtures {
|
||||
public static final Edge EDGE = new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY);
|
||||
public static final Edge EDGE_1_3 = new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_3, CAPACITY);
|
||||
public static final Edge EDGE_2_3 = new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY_3, CAPACITY);
|
||||
public static final Edge EDGE_3_2 = new Edge(CHANNEL_ID_4, PUBKEY_3, PUBKEY_2, CAPACITY_2);
|
||||
public static final Edge EDGE_3_4 = new Edge(CHANNEL_ID_5, PUBKEY_3, PUBKEY_4, CAPACITY);
|
||||
public static final Edge EDGE = new Edge(CHANNEL_ID, PUBKEY, PUBKEY_2, CAPACITY, POLICY_1);
|
||||
public static final Edge EDGE_1_3 = new Edge(CHANNEL_ID_2, PUBKEY, PUBKEY_3, CAPACITY, POLICY_1);
|
||||
public static final Edge EDGE_2_3 = new Edge(CHANNEL_ID_3, PUBKEY_2, PUBKEY_3, CAPACITY, POLICY_1);
|
||||
public static final Edge EDGE_3_2 = new Edge(CHANNEL_ID_4, PUBKEY_3, PUBKEY_2, CAPACITY_2, POLICY_1);
|
||||
public static final Edge EDGE_3_4 = new Edge(CHANNEL_ID_5, PUBKEY_3, PUBKEY_4, CAPACITY, POLICY_1);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ package de.cotto.lndmanagej.controller.dto;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICIES_FOR_LOCAL_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_2;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_DISABLED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PoliciesForLocalChannelDtoTest {
|
||||
@Test
|
||||
void createFromModel() {
|
||||
PoliciesDto expected =
|
||||
new PoliciesDto(PolicyDto.createFromModel(POLICY_1), PolicyDto.createFromModel(POLICY_2));
|
||||
new PoliciesDto(PolicyDto.createFromModel(POLICY_DISABLED), PolicyDto.createFromModel(POLICY_2));
|
||||
PoliciesDto dto = PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL);
|
||||
assertThat(dto).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_1;
|
||||
import static de.cotto.lndmanagej.model.PolicyFixtures.POLICY_DISABLED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PolicyDtoTest {
|
||||
@Test
|
||||
void createFromModel() {
|
||||
PolicyDto expected = new PolicyDto(100, 10, false);
|
||||
PolicyDto dto = PolicyDto.createFromModel(POLICY_1);
|
||||
PolicyDto dto = PolicyDto.createFromModel(POLICY_DISABLED);
|
||||
assertThat(dto).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user