Skip to content

Commit

Permalink
Merge pull request #18 from gnosischain/fix/broken-tests-nethermind
Browse files Browse the repository at this point in the history
fix/broken tests nethermind
  • Loading branch information
stdevMac authored Aug 21, 2023
2 parents 77506a8 + 1de7547 commit c792aec
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 336 deletions.
27 changes: 12 additions & 15 deletions simulators/ethereum/engine/clmock/clmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,14 @@ func (cl *CLMocker) GetTimestampIncrement() uint64 {
return cl.BlockTimestampIncrement.Uint64()
}

var counter = 0

// Returns the timestamp value to be included in the next payload attributes
// Returns the next timestamp value to be included in the next payload attributes
func (cl *CLMocker) GetNextBlockTimestamp() uint64 {

now := time.Now()
ret := uint64(now.Truncate(time.Minute).Add(5 * time.Second).Add(time.Duration(counter) * time.Second).Unix())
counter += 1
return ret
//if cl.FirstPoSBlockNumber == nil && cl.TransitionPayloadTimestamp != nil {
// // We are producing the transition payload and there's a value specified
// // for this specific payload
// return cl.TransitionPayloadTimestamp.Uint64()
//}
//return cl.LatestHeader.Time + cl.GetTimestampIncrement()
if cl.FirstPoSBlockNumber == nil && cl.TransitionPayloadTimestamp != nil {
// We are producing the transition payload and there's a value specified
// for this specific payload
return cl.TransitionPayloadTimestamp.Uint64()
}
return cl.LatestHeader.Time + cl.GetTimestampIncrement()
}

// Picks the next payload producer from the set of clients registered
Expand Down Expand Up @@ -350,6 +343,7 @@ func (cl *CLMocker) RequestNextPayload() {
defer cancel()
var (
resp api.ForkChoiceResponse
b *client.Block
fcUVersion int
err error
)
Expand All @@ -359,7 +353,10 @@ func (cl *CLMocker) RequestNextPayload() {
resp, err = cl.NextBlockProducer.ForkchoiceUpdatedV2(ctx, &cl.LatestForkchoice, &cl.LatestPayloadAttributes)

} else {
b, _ := cl.EngineClients[0].BlockByNumber(ctx, nil)
b, err = cl.EngineClients[0].BlockByNumber(ctx, nil)
if err != nil {
cl.Fatalf("Can't get latest block from the first client: %v", err)
}
latestBlockHash := b.Hash()
if cl.LatestForkchoice.HeadBlockHash != latestBlockHash {
cl.Fatalf("CLMocker: Latest forkchoice head block hash (%v) does not match latest block hash (%v)", cl.LatestForkchoice.HeadBlockHash.Hex(), latestBlockHash.Hex())
Expand Down
3 changes: 2 additions & 1 deletion simulators/ethereum/engine/globals/globals.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package globals

import (
"github.com/ethereum/go-ethereum/crypto"
"math/big"
"time"

"github.com/ethereum/go-ethereum/crypto"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/hive/hivesim"
Expand Down
16 changes: 10 additions & 6 deletions simulators/ethereum/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
suite_withdrawals "github.com/ethereum/hive/simulators/ethereum/engine/suites/withdrawals"
)

// we will wait that time before every test execution to be sure environment is ready
// may be changed to other value if necessary
const SetupTime = 3 * time.Minute

func main() {
var (
// engine = hivesim.Suite{
Expand Down Expand Up @@ -85,8 +89,6 @@ type ClientGenesis interface {
GetTTD()
}

// Load the genesis based on each client

func getTimestamp(spec test.SpecInterface) int64 {
now := time.Now()

Expand All @@ -95,8 +97,10 @@ func getTimestamp(spec test.SpecInterface) int64 {
preShapellaBlock = 1
}

nextMinute := now.Truncate(time.Minute).Add(time.Duration(preShapellaBlock) * 3 * time.Minute).Add(time.Minute)
return nextMinute.Unix()
preShapellaTime := time.Duration(uint64(preShapellaBlock)*spec.GetBlockTimeIncrements()) * time.Second
// after setup wait chain will produce blocks in preShapellaTime and than shapella happens
shanghaiTimestamp := now.Add(SetupTime).Add(preShapellaTime)
return shanghaiTimestamp.Unix()
}

// Add test cases to a given test suite
Expand Down Expand Up @@ -183,12 +187,12 @@ func addTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test
defer func() {
t.Logf("End test (%s): %s", c.Type, currentTest.GetName())
}()
timeout := time.Minute * 20
timeout := 30 * time.Minute
// If a test.Spec specifies a timeout, use that instead
if currentTest.GetTimeout() != 0 {
timeout = time.Second * time.Duration(currentTest.GetTimeout())
}
//time.Sleep(30 * time.Second)
time.Sleep(30 * time.Second)
// Run the test case
test.Run(
currentTest,
Expand Down
Loading

0 comments on commit c792aec

Please sign in to comment.