mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-08-06 08:30:14 +08:00
chore(test): minor cleanup and debugging output for TestEthBlockHashesCorrect_MultiBlockTipset
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user