From 911b0ed5f304a7f3c1817bc87caa981a60a992ef Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sun, 28 May 2023 19:01:14 +0800 Subject: [PATCH] try to fix flake --- integration/integration_test.go | 9 +++++---- integration/util_test.go | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/integration/integration_test.go b/integration/integration_test.go index 20d4d242..19764610 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -4,7 +4,6 @@ import ( "context" "math/big" "math/rand" - "time" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" @@ -26,8 +25,6 @@ var ( erc20TotalSupply, _ = new(big.Int).SetString("1000000000000000000000", 10) ercTotalSupplyIndex = common.HexToHash("0x2") - - delayInterval = time.Second * 1 ) var _ = Describe("Basic integration test", func() { @@ -43,7 +40,8 @@ var _ = Describe("Basic integration test", func() { contract, contractErr = integration.DeployContract() Expect(contractErr).ToNot(HaveOccurred()) - time.Sleep(delayInterval) + err := waitForBlock(ctx, ipldClient, contract.BlockNumber) + Expect(err).ToNot(HaveOccurred()) }) It("get not existing block by number", func() { @@ -298,6 +296,9 @@ var _ = Describe("Basic integration test", func() { Expect(contract.BlockNumber).ToNot(BeZero()) contractSalt = common.Bytes2Hex(contract.BlockHash[:10]) + + err := waitForBlock(ctx, ipldClient, contract.BlockNumber) + Expect(err).ToNot(HaveOccurred()) }) It("gets ERC20 total supply (with block number)", func() { diff --git a/integration/util_test.go b/integration/util_test.go index 00e8a4fe..e33482cb 100644 --- a/integration/util_test.go +++ b/integration/util_test.go @@ -22,6 +22,7 @@ func waitForBlock(ctx context.Context, client *ethclient.Client, target int64) e if uint64(target) <= latest { return nil } + time.Sleep(time.Second) } }