Merge pull request #10100 from filecoin-project/fix/paych-itest-syncwait

fix: itests: Fix flaky paych test
This commit is contained in:
Łukasz Magiera 2023-01-23 16:24:42 +01:00 committed by GitHub
commit dd12cad1ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ func TestPaymentChannelsAPI(t *testing.T) {
kit.QuietMiningLogs()
ctx := context.Background()
blockTime := 5 * time.Millisecond
blockTime := 10 * time.Millisecond
var (
paymentCreator kit.TestFullNode
@ -55,6 +55,15 @@ func TestPaymentChannelsAPI(t *testing.T) {
bms := ens.BeginMiningMustPost(blockTime)
bm := bms[0]
waitRecvInSync := func() {
// paymentCreator is the block miner, in some cases paymentReceiver may fall behind, so we wait for it to catch up
head, err := paymentReceiver.ChainHead(ctx)
require.NoError(t, err)
paymentReceiver.WaitTillChain(ctx, kit.HeightAtLeast(head.Height()))
}
// send some funds to register the receiver
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
require.NoError(t, err)
@ -74,6 +83,8 @@ func TestPaymentChannelsAPI(t *testing.T) {
channel, err := paymentCreator.PaychGetWaitReady(ctx, channelInfo.WaitSentinel)
require.NoError(t, err)
waitRecvInSync()
// allocate three lanes
var lanes []uint64
for i := 0; i < 3; i++ {
@ -110,6 +121,8 @@ func TestPaymentChannelsAPI(t *testing.T) {
res := waitForMessage(ctx, t, paymentCreator, settleMsgCid, time.Second*10, "settle")
require.EqualValues(t, 0, res.Receipt.ExitCode, "Unable to settle payment channel")
waitRecvInSync()
creatorStore := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(paymentCreator)))
// wait for the receiver to submit their vouchers