Merge pull request #10100 from filecoin-project/fix/paych-itest-syncwait
fix: itests: Fix flaky paych test
This commit is contained in:
commit
dd12cad1ef
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user