Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: itests: Fix flaky paych test #10100

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion itests/paych_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd even suggest doing head + 5 here, just in case of minor reorgs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one miner in that test, can't have reorgs

}

// send some funds to register the receiver
receiverAddr, err := paymentReceiver.WalletNew(ctx, types.KTSecp256k1)
require.NoError(t, err)
Expand All @@ -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++ {
Expand Down Expand Up @@ -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
Expand Down