From e5c7e9a38c79354178ae0366c0582c9a80fb83fd Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Wed, 18 Mar 2020 10:51:07 +0100 Subject: [PATCH] routing/test: return pathfinding error --- routing/integrated_routing_context_test.go | 6 +++--- routing/integrated_routing_test.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/routing/integrated_routing_context_test.go b/routing/integrated_routing_context_test.go index d421c62f..418b380c 100644 --- a/routing/integrated_routing_context_test.go +++ b/routing/integrated_routing_context_test.go @@ -81,7 +81,7 @@ type htlcAttempt struct { // testPayment launches a test payment and asserts that it is completed after // the expected number of attempts. -func (c *integratedRoutingContext) testPayment() []htlcAttempt { +func (c *integratedRoutingContext) testPayment() ([]htlcAttempt, error) { var ( nextPid uint64 attempts []htlcAttempt @@ -150,7 +150,7 @@ func (c *integratedRoutingContext) testPayment() []htlcAttempt { c.amt, lnwire.MaxMilliSatoshi, 0, 0, ) if err != nil { - c.t.Fatal(err) + return nil, err } // Send out the htlc on the mock graph. @@ -199,7 +199,7 @@ func (c *integratedRoutingContext) testPayment() []htlcAttempt { c.t.Logf("Payment attempts: %v\n", len(attempts)) - return attempts + return attempts, nil } // getNodeIndex returns the zero-based index of the given node in the route. diff --git a/routing/integrated_routing_test.go b/routing/integrated_routing_test.go index 0362f208..1e77ce81 100644 --- a/routing/integrated_routing_test.go +++ b/routing/integrated_routing_test.go @@ -50,7 +50,10 @@ func TestProbabilityExtrapolation(t *testing.T) { // a specific number of attempts to safe-guard against accidental // modifications anywhere in the chain of components that is involved in // this test. - attempts := ctx.testPayment() + attempts, err := ctx.testPayment() + if err != nil { + t.Fatalf("payment failed: %v", err) + } if len(attempts) != 5 { t.Fatalf("expected 5 attempts, but needed %v", len(attempts)) } @@ -59,7 +62,10 @@ func TestProbabilityExtrapolation(t *testing.T) { // of data from other channels), all ten bad channels will be tried // first before switching to the paid channel. ctx.mcCfg.AprioriWeight = 1 - attempts = ctx.testPayment() + attempts, err = ctx.testPayment() + if err != nil { + t.Fatalf("payment failed: %v", err) + } if len(attempts) != 11 { t.Fatalf("expected 11 attempts, but needed %v", len(attempts)) }