From 9d4251c18d3431769006cd7f63f588c46880a7bc Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 26 Jan 2023 10:14:28 +0100 Subject: [PATCH] routing/test: test local unified edge --- routing/unified_edges_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/routing/unified_edges_test.go b/routing/unified_edges_test.go index 043447f52..23808fe22 100644 --- a/routing/unified_edges_test.go +++ b/routing/unified_edges_test.go @@ -18,10 +18,15 @@ func TestNodeEdgeUnifier(t *testing.T) { source := route.Vertex{1} toNode := route.Vertex{2} fromNode := route.Vertex{3} - bandwidthHints := &mockBandwidthHints{} + bandwidthHints := &mockBandwidthHints{ + hints: map[uint64]lnwire.MilliSatoshi{ + 100: 150, + }, + } // Add two channels between the pair of nodes. p1 := models.CachedEdgePolicy{ + ChannelID: 100, FeeProportionalMillionths: 100000, FeeBaseMSat: 30, TimeLockDelta: 60, @@ -30,6 +35,7 @@ func TestNodeEdgeUnifier(t *testing.T) { MinHTLC: 100, } p2 := models.CachedEdgePolicy{ + ChannelID: 101, FeeProportionalMillionths: 190000, FeeBaseMSat: 10, TimeLockDelta: 40, @@ -53,6 +59,9 @@ func TestNodeEdgeUnifier(t *testing.T) { fromNode, &models.CachedEdgePolicy{}, 0, defaultHopPayloadSize, ) + unifierLocal := newNodeEdgeUnifier(fromNode, toNode, nil) + unifierLocal.addPolicy(fromNode, &p1, c1, defaultHopPayloadSize) + tests := []struct { name string unifier *nodeEdgeUnifier @@ -116,6 +125,21 @@ func TestNodeEdgeUnifier(t *testing.T) { unifier: unifierNoInfo, expectedCapacity: 0, }, + { + name: "local insufficient bandwidth", + unifier: unifierLocal, + amount: 200, + expectNoPolicy: true, + }, + { + name: "local", + unifier: unifierLocal, + amount: 100, + expectedFeeBase: p1.FeeBaseMSat, + expectedFeeRate: p1.FeeProportionalMillionths, + expectedTimeLock: p1.TimeLockDelta, + expectedCapacity: c1, + }, } for _, test := range tests {