mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 22:50:58 +02:00
itest: fix flake in testCoopCloseWithExternalDeliveryImpl
The response from `ClosedChannels` may not be up-to-date, so we wrap it inside a wait closure.
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package itest
|
package itest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -114,11 +116,20 @@ func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
|
|||||||
// assertion. We want to ensure that even though alice's delivery
|
// assertion. We want to ensure that even though alice's delivery
|
||||||
// address is set to an address in bob's wallet, we should still show
|
// address is set to an address in bob's wallet, we should still show
|
||||||
// the balance as settled.
|
// the balance as settled.
|
||||||
|
err = wait.NoError(func() error {
|
||||||
closed := alice.RPC.ClosedChannels(&lnrpc.ClosedChannelsRequest{
|
closed := alice.RPC.ClosedChannels(&lnrpc.ClosedChannelsRequest{
|
||||||
Cooperative: true,
|
Cooperative: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
// The settled balance should never be zero at this point.
|
if len(closed.Channels) == 0 {
|
||||||
require.NotZero(ht, len(closed.Channels))
|
return fmt.Errorf("expected closed channel not found")
|
||||||
require.NotZero(ht, closed.Channels[0].SettledBalance)
|
}
|
||||||
|
|
||||||
|
if closed.Channels[0].SettledBalance == 0 {
|
||||||
|
return fmt.Errorf("expected settled balance to be zero")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}, defaultTimeout)
|
||||||
|
require.NoError(ht, err, "timeout checking closed channels")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user