Skip to content

Commit

Permalink
chore(test): minor cleanup and debugging output for TestEthBlockHashe…
Browse files Browse the repository at this point in the history
…sCorrect_MultiBlockTipset
  • Loading branch information
rvagg committed Nov 22, 2024
1 parent 9548629 commit e2c46f1
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions itests/eth_block_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package itests
import (
"context"
"fmt"
"strings"
"testing"
"time"

Expand All @@ -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"
)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
}
}

0 comments on commit e2c46f1

Please sign in to comment.