routing/test: add check that sendpayment completes
As is, we don't check that our SendPayment call in TestRouterPaymentStateMachine completes. This makes it easier to create malformed tests that just run through steps but leave the SendPayment call hanging. This commit adds a check that we have completed our payment to help catch tests like this. We also remove an unused quit channel.
This commit is contained in:
parent
5a82340a03
commit
cb927e89b0
@ -564,9 +564,6 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
control.failPayment = make(chan failPaymentArgs, 20)
|
||||
control.fetchInFlight = make(chan struct{}, 20)
|
||||
|
||||
quit := make(chan struct{})
|
||||
defer close(quit)
|
||||
|
||||
// setupRouter is a helper method that creates and starts the router in
|
||||
// the desired configuration for this test.
|
||||
setupRouter := func() (*ChannelRouter, chan error,
|
||||
@ -672,9 +669,11 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
// Send the payment. Since this is new payment hash, the
|
||||
// information should be registered with the ControlTower.
|
||||
paymentResult := make(chan error)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
_, _, err := router.SendPayment(&payment)
|
||||
paymentResult <- err
|
||||
close(done)
|
||||
}()
|
||||
|
||||
var resendResult chan error
|
||||
@ -894,5 +893,11 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
t.Fatalf("unknown step %v", step)
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(testTimeout):
|
||||
t.Fatalf("SendPayment didn't exit")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user