routing: fix use of T.Fatal() in test goroutine
This commit is contained in:
parent
c069bdd4c7
commit
6254c53a4a
@ -2,6 +2,7 @@ package routing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"math"
|
"math"
|
||||||
@ -2978,13 +2979,14 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
|
|
||||||
// On startup, the router should fetch all pending payments
|
// On startup, the router should fetch all pending payments
|
||||||
// from the ControlTower, so assert that here.
|
// from the ControlTower, so assert that here.
|
||||||
didFetch := make(chan struct{})
|
errCh := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
|
close(errCh)
|
||||||
select {
|
select {
|
||||||
case <-control.fetchInFlight:
|
case <-control.fetchInFlight:
|
||||||
close(didFetch)
|
return
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
t.Fatalf("router did not fetch in flight " +
|
errCh <- errors.New("router did not fetch in flight " +
|
||||||
"payments")
|
"payments")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -2994,7 +2996,10 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-didFetch:
|
case err := <-errCh:
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error in anonymous goroutine: %s", err)
|
||||||
|
}
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
t.Fatalf("did not fetch in flight payments at startup")
|
t.Fatalf("did not fetch in flight payments at startup")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user