mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +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) {
|
paymentRequests []string, status lnrpc.Payment_PaymentStatus) {
|
||||||
|
|
||||||
// Create a buffered chan to signal the results.
|
// 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 sends a payment and asserts if it doesn't succeeded.
|
||||||
send := func(payReq string) {
|
send := func(payReq string) {
|
||||||
|
@ -1281,10 +1281,9 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode,
|
||||||
FeeLimitMsat: noFeeLimitMsat,
|
FeeLimitMsat: noFeeLimitMsat,
|
||||||
}
|
}
|
||||||
stream := hn.RPC.SendPayment(req)
|
stream := hn.RPC.SendPayment(req)
|
||||||
h.AssertPaymentStatusFromStream(stream, status)
|
|
||||||
|
|
||||||
// Signal success.
|
// Signal sent succeeded.
|
||||||
results <- struct{}{}
|
results <- stream
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch all payments simultaneously.
|
// Launch all payments simultaneously.
|
||||||
|
@ -1293,16 +1292,12 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode,
|
||||||
go send(payReqCopy)
|
go send(payReqCopy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all payments to report success.
|
// Wait for all payments to report the expected status.
|
||||||
timer := time.After(DefaultTimeout)
|
timer := time.After(DefaultTimeout)
|
||||||
count := 0
|
|
||||||
select {
|
select {
|
||||||
case <-results:
|
case stream := <-results:
|
||||||
count++
|
h.AssertPaymentStatusFromStream(stream, status)
|
||||||
// Exit if the expected number of results are received.
|
|
||||||
if count == len(paymentRequests) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case <-timer:
|
case <-timer:
|
||||||
require.Fail(h, "timeout", "waiting payment results timeout")
|
require.Fail(h, "timeout", "waiting payment results timeout")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue