mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
lntest: fix completePaymentRequestsAssertStatus
This commit moves the assertion `AssertPaymentStatusFromStream` outside of the goroutine so the test won't fail after the case is finished.
This commit is contained in:
parent
178e4b0103
commit
7bd8ae08c0
1 changed files with 7 additions and 12 deletions
|
@ -1271,7 +1271,7 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode,
|
|||
paymentRequests []string, status lnrpc.Payment_PaymentStatus) {
|
||||
|
||||
// Create a buffered chan to signal the results.
|
||||
results := make(chan struct{}, len(paymentRequests))
|
||||
results := make(chan rpc.PaymentClient, len(paymentRequests))
|
||||
|
||||
// send sends a payment and asserts if it doesn't succeeded.
|
||||
send := func(payReq string) {
|
||||
|
@ -1281,10 +1281,9 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode,
|
|||
FeeLimitMsat: noFeeLimitMsat,
|
||||
}
|
||||
stream := hn.RPC.SendPayment(req)
|
||||
h.AssertPaymentStatusFromStream(stream, status)
|
||||
|
||||
// Signal success.
|
||||
results <- struct{}{}
|
||||
// Signal sent succeeded.
|
||||
results <- stream
|
||||
}
|
||||
|
||||
// Launch all payments simultaneously.
|
||||
|
@ -1293,16 +1292,12 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode,
|
|||
go send(payReqCopy)
|
||||
}
|
||||
|
||||
// Wait for all payments to report success.
|
||||
// Wait for all payments to report the expected status.
|
||||
timer := time.After(DefaultTimeout)
|
||||
count := 0
|
||||
select {
|
||||
case <-results:
|
||||
count++
|
||||
// Exit if the expected number of results are received.
|
||||
if count == len(paymentRequests) {
|
||||
return
|
||||
}
|
||||
case stream := <-results:
|
||||
h.AssertPaymentStatusFromStream(stream, status)
|
||||
|
||||
case <-timer:
|
||||
require.Fail(h, "timeout", "waiting payment results timeout")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue