From f44a9e1d4cb7a1a6951a9664856c7c4bae030a87 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 16 Apr 2020 10:36:58 +0200 Subject: [PATCH] routing/test: make test channel capacities configurable --- routing/integrated_routing_test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/routing/integrated_routing_test.go b/routing/integrated_routing_test.go index 2fdf7136..d0aa4d08 100644 --- a/routing/integrated_routing_test.go +++ b/routing/integrated_routing_test.go @@ -107,7 +107,7 @@ func onePathGraph(g *mockGraph) { g.addChannel(chanIm1Target, targetNodeID, im1NodeID, 100000) } -func twoPathGraph(g *mockGraph) { +func twoPathGraph(g *mockGraph, capacityOut, capacityIn btcutil.Amount) { // Create the following network of nodes: // source -> intermediate1 -> target // source -> intermediate2 -> target @@ -120,10 +120,10 @@ func twoPathGraph(g *mockGraph) { intermediate2 := newMockNode(im2NodeID) g.addNode(intermediate2) - g.addChannel(chanSourceIm1, sourceNodeID, im1NodeID, 200000) - g.addChannel(chanSourceIm2, sourceNodeID, im2NodeID, 200000) - g.addChannel(chanIm1Target, targetNodeID, im1NodeID, 100000) - g.addChannel(chanIm2Target, targetNodeID, im2NodeID, 100000) + g.addChannel(chanSourceIm1, sourceNodeID, im1NodeID, capacityOut) + g.addChannel(chanSourceIm2, sourceNodeID, im2NodeID, capacityOut) + g.addChannel(chanIm1Target, targetNodeID, im1NodeID, capacityIn) + g.addChannel(chanIm2Target, targetNodeID, im2NodeID, capacityIn) } var mppTestCases = []mppSendTestCase{ @@ -136,8 +136,10 @@ var mppTestCases = []mppSendTestCase{ // too. Mpp payment complete. { - name: "sufficient inbound", - graph: twoPathGraph, + name: "sufficient inbound", + graph: func(g *mockGraph) { + twoPathGraph(g, 200000, 100000) + }, amt: 70000, expectedAttempts: 5, expectedSuccesses: []expectedHtlcSuccess{ @@ -155,8 +157,10 @@ var mppTestCases = []mppSendTestCase{ // Test that a cap on the max htlcs makes it impossible to pay. { - name: "no splitting", - graph: twoPathGraph, + name: "no splitting", + graph: func(g *mockGraph) { + twoPathGraph(g, 200000, 100000) + }, amt: 70000, expectedAttempts: 2, expectedSuccesses: []expectedHtlcSuccess{},