From 62032e7c2a2eddb0d0989e06ab4e02cbe536d5cf Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 9 Aug 2023 19:25:32 -0400 Subject: [PATCH] feat: deflake: TestGetBlockByNumber --- itests/eth_transactions_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index 8d836573d..b39632795 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -310,13 +310,23 @@ func TestGetBlockByNumber(t *testing.T) { afterNullHeight := hc[0].Val.Height() + nullHeight := afterNullHeight - 1 + for nullHeight > 0 { + ts, err := client.ChainGetTipSetByHeight(ctx, nullHeight, types.EmptyTSK) + require.NoError(t, err) + if ts.Height() == nullHeight { + nullHeight-- + } else { + break + } + } + // Fail when trying to fetch a null round. - _, err = client.EthGetBlockByNumber(ctx, (ethtypes.EthUint64(afterNullHeight - 1)).Hex(), true) + _, err = client.EthGetBlockByNumber(ctx, (ethtypes.EthUint64(nullHeight)).Hex(), true) require.Error(t, err) // Fetch balance on a null round; should not fail and should return previous balance. - // Should be lower than original balance. - bal, err := client.EthGetBalance(ctx, ethAddr, ethtypes.NewEthBlockNumberOrHashFromNumber(ethtypes.EthUint64(afterNullHeight-1))) + bal, err := client.EthGetBalance(ctx, ethAddr, ethtypes.NewEthBlockNumberOrHashFromNumber(ethtypes.EthUint64(nullHeight))) require.NoError(t, err) require.NotEqual(t, big.Zero(), bal) require.Equal(t, types.FromFil(10).Int, bal.Int)