@@ -3,7 +3,6 @@ package itests
33import (
44 "context"
55 "fmt"
6- "strings"
76 "testing"
87 "time"
98
@@ -12,6 +11,7 @@ import (
1211 "github.com/filecoin-project/go-state-types/abi"
1312
1413 "github.com/filecoin-project/lotus/build/buildconstants"
14+ "github.com/filecoin-project/lotus/chain/types"
1515 "github.com/filecoin-project/lotus/chain/types/ethtypes"
1616 "github.com/filecoin-project/lotus/itests/kit"
1717)
@@ -35,23 +35,21 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
3535
3636 {
3737 ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
38- n1 .WaitTillChain (ctx , kit .HeightAtLeast (abi .ChainEpoch (5 )))
38+ n1 .WaitTillChain (ctx , kit .HeightAtLeast (abi .ChainEpoch (10 )))
3939 cancel ()
4040 }
4141
4242 var n2 kit.TestFullNode
4343 ens .FullNode (& n2 , kit .ThroughRPC ()).Start ().Connect (n2 , n1 )
4444
45+ var head * types.TipSet
4546 {
4647 // find the first tipset where all miners mined a block.
4748 ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Minute )
48- n2 .WaitTillChain (ctx , kit .BlocksMinedByAll (m1 .ActorAddr , m2 .ActorAddr ))
49+ head = n2 .WaitTillChain (ctx , kit .BlocksMinedByAll (m1 .ActorAddr , m2 .ActorAddr ))
4950 cancel ()
5051 }
5152
52- head , err := n2 .ChainHead (context .Background ())
53- require .NoError (t , err )
54-
5553 ctx := context .Background ()
5654
5755 // let the chain run a little bit longer to minimise the chance of reorgs
@@ -63,15 +61,13 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
6361
6462 ts , err := n2 .ChainGetTipSetByHeight (ctx , abi .ChainEpoch (i ), tsk )
6563 require .NoError (t , err )
66-
67- ethBlockA , err := n2 .EthGetBlockByNumber (ctx , hex , true )
68- // Cannot use static ErrFullRound error for comparison since it gets reserialized as a JSON RPC error.
69- if err != nil && strings .Contains (err .Error (), "null round" ) {
70- require .Less (t , ts .Height (), abi .ChainEpoch (i ), "did not expect a tipset at epoch %d" , i )
64+ if ts .Height () != abi .ChainEpoch (i ) { // null round
7165 continue
7266 }
67+
68+ ethBlockA , err := n2 .EthGetBlockByNumber (ctx , hex , true )
7369 require .NoError (t , err )
74- require .Equal (t , ts .Height (), abi . ChainEpoch ( i ), "expected a tipset at epoch %i" , i )
70+ require .EqualValues (t , ts .Height (), ethBlockA . Number )
7571
7672 ethBlockB , err := n2 .EthGetBlockByHash (ctx , ethBlockA .Hash , true )
7773 require .NoError (t , err )
@@ -80,6 +76,6 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
8076
8177 numBlocks := len (ts .Blocks ())
8278 expGasLimit := ethtypes .EthUint64 (int64 (numBlocks ) * buildconstants .BlockGasLimit )
83- require .Equal (t , expGasLimit , ethBlockB .GasLimit )
79+ require .Equal (t , expGasLimit , ethBlockB .GasLimit , "expected gas limit to be %d for %d blocks" , expGasLimit , numBlocks )
8480 }
8581}
0 commit comments