@@ -3,7 +3,6 @@ package itests
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "strings"
7
6
"testing"
8
7
"time"
9
8
@@ -12,6 +11,7 @@ import (
12
11
"github.com/filecoin-project/go-state-types/abi"
13
12
14
13
"github.com/filecoin-project/lotus/build/buildconstants"
14
+ "github.com/filecoin-project/lotus/chain/types"
15
15
"github.com/filecoin-project/lotus/chain/types/ethtypes"
16
16
"github.com/filecoin-project/lotus/itests/kit"
17
17
)
@@ -35,23 +35,21 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
35
35
36
36
{
37
37
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 )))
39
39
cancel ()
40
40
}
41
41
42
42
var n2 kit.TestFullNode
43
43
ens .FullNode (& n2 , kit .ThroughRPC ()).Start ().Connect (n2 , n1 )
44
44
45
+ var head * types.TipSet
45
46
{
46
47
// find the first tipset where all miners mined a block.
47
48
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 ))
49
50
cancel ()
50
51
}
51
52
52
- head , err := n2 .ChainHead (context .Background ())
53
- require .NoError (t , err )
54
-
55
53
ctx := context .Background ()
56
54
57
55
// let the chain run a little bit longer to minimise the chance of reorgs
@@ -63,15 +61,13 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
63
61
64
62
ts , err := n2 .ChainGetTipSetByHeight (ctx , abi .ChainEpoch (i ), tsk )
65
63
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
71
65
continue
72
66
}
67
+
68
+ ethBlockA , err := n2 .EthGetBlockByNumber (ctx , hex , true )
73
69
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 )
75
71
76
72
ethBlockB , err := n2 .EthGetBlockByHash (ctx , ethBlockA .Hash , true )
77
73
require .NoError (t , err )
@@ -80,6 +76,6 @@ func TestEthBlockHashesCorrect_MultiBlockTipset(t *testing.T) {
80
76
81
77
numBlocks := len (ts .Blocks ())
82
78
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 )
84
80
}
85
81
}
0 commit comments