From e2c46f1af1e088535d2bb5a2ec04362b9b0e5009 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 21 Nov 2024 17:48:47 +1100 Subject: [PATCH] chore(test): minor cleanup and debugging output for TestEthBlockHashesCorrect_MultiBlockTipset --- itests/eth_block_hash_test.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/itests/eth_block_hash_test.go b/itests/eth_block_hash_test.go index 2e30fe0e641..ca31d8104d3 100644 --- a/itests/eth_block_hash_test.go +++ b/itests/eth_block_hash_test.go @@ -3,7 +3,6 @@ package itests import ( "context" "fmt" - "strings" "testing" "time" @@ -12,6 +11,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/build/buildconstants" + "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/itests/kit" ) @@ -35,23 +35,21 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) { { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) - n1.WaitTillChain(ctx, kit.HeightAtLeast(abi.ChainEpoch(5))) + n1.WaitTillChain(ctx, kit.HeightAtLeast(abi.ChainEpoch(10))) cancel() } var n2 kit.TestFullNode ens.FullNode(&n2, kit.ThroughRPC()).Start().Connect(n2, n1) + var head *types.TipSet { // find the first tipset where all miners mined a block. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) - n2.WaitTillChain(ctx, kit.BlocksMinedByAll(m1.ActorAddr, m2.ActorAddr)) + head = n2.WaitTillChain(ctx, kit.BlocksMinedByAll(m1.ActorAddr, m2.ActorAddr)) cancel() } - head, err := n2.ChainHead(context.Background()) - require.NoError(t, err) - ctx := context.Background() // let the chain run a little bit longer to minimise the chance of reorgs @@ -63,15 +61,13 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) { ts, err := n2.ChainGetTipSetByHeight(ctx, abi.ChainEpoch(i), tsk) require.NoError(t, err) - - ethBlockA, err := n2.EthGetBlockByNumber(ctx, hex, true) - // Cannot use static ErrFullRound error for comparison since it gets reserialized as a JSON RPC error. - if err != nil && strings.Contains(err.Error(), "null round") { - require.Less(t, ts.Height(), abi.ChainEpoch(i), "did not expect a tipset at epoch %d", i) + if ts.Height() != abi.ChainEpoch(i) { // null round continue } + + ethBlockA, err := n2.EthGetBlockByNumber(ctx, hex, true) require.NoError(t, err) - require.Equal(t, ts.Height(), abi.ChainEpoch(i), "expected a tipset at epoch %i", i) + require.EqualValues(t, ts.Height(), ethBlockA.Number) ethBlockB, err := n2.EthGetBlockByHash(ctx, ethBlockA.Hash, true) require.NoError(t, err) @@ -80,6 +76,6 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) { numBlocks := len(ts.Blocks()) expGasLimit := ethtypes.EthUint64(int64(numBlocks) * buildconstants.BlockGasLimit) - require.Equal(t, expGasLimit, ethBlockB.GasLimit) + require.Equal(t, expGasLimit, ethBlockB.GasLimit, "expected gas limit to be %d for %d blocks", expGasLimit, numBlocks) } }