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

chore(test): minor cleanup and debugging output for TestEthBlockHashesCorrect_MultiBlockTipset #12712

Merged
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
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)
}
}
Loading