diff --git a/loopout_test.go b/loopout_test.go index 254ccea8..b367911e 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -140,6 +140,18 @@ func testLoopOutPaymentParameters(t *testing.T) { // this to prevent a blocked channel in the mock. ctx.AssertRegisterConf(false, defaultConfirmations) + // Drive both payments to a terminal state so the async payment + // goroutines complete and don't hit a nil status path. + for _, p := range payments { + select { + case p.Updates <- lndclient.PaymentStatus{ + State: lnrpc.Payment_SUCCEEDED, + }: + case <-time.After(test.Timeout): + t.Fatalf("could not send payment update") + } + } + // Cancel the swap. There is nothing else we need to assert. The payment // parameters don't play a role in the remainder of the swap process. cancel() diff --git a/test/context.go b/test/context.go index 943a1dee..a81e7557 100644 --- a/test/context.go +++ b/test/context.go @@ -151,7 +151,7 @@ func (ctx *Context) AssertPaid( return done } - // Assert that client pays swap invoice. + // Assert that the client pays swap invoice. for { var swapPayment RouterPaymentChannelMessage select { @@ -171,7 +171,12 @@ func (ctx *Context) AssertPaid( done := func(result error) { if result != nil { - swapPayment.Errors <- result + // Send a terminal FAILED status so the client + // always receives a non-nil PaymentStatus and + // won't dereference nil. + swapPayment.Updates <- lndclient.PaymentStatus{ + State: lnrpc.Payment_FAILED, + } return } swapPayment.Updates <- lndclient.PaymentStatus{