From b1419eb41d38fdb0a8dbe27e3e29caf8865ee57a Mon Sep 17 00:00:00 2001 From: anshalshukla Date: Tue, 13 Aug 2024 16:46:46 +0530 Subject: [PATCH] fix: testcases --- core/blockchain.go | 5 +++++ eth/downloader/bor_downloader_test.go | 2 +- eth/tracers/internal/tracetest/supply_test.go | 4 ++-- internal/ethapi/api_test.go | 6 +++++- metrics/sample_test.go | 4 ++-- tests/bor/bor_sprint_length_change_test.go | 7 +++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 8f274de11d..1cca9a9dc5 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -522,6 +522,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } bc.snaps, _ = snapshot.New(snapconfig, bc.db, bc.triedb, head.Root) } + + // Start future block processor. + // bc.wg.Add(1) + // go bc.updateFutureBlocks() + // Rewind the chain in case of an incompatible config upgrade. if compat, ok := genesisErr.(*params.ConfigCompatError); ok { log.Warn("Rewinding chain to upgrade configuration", "err", compat) diff --git a/eth/downloader/bor_downloader_test.go b/eth/downloader/bor_downloader_test.go index d7ec45d55a..0a568bf35b 100644 --- a/eth/downloader/bor_downloader_test.go +++ b/eth/downloader/bor_downloader_test.go @@ -76,7 +76,7 @@ func newTesterWithNotification(t *testing.T, success func()) *downloadTester { gspec := &core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{testAddress: {Balance: big.NewInt(1000000000000000)}}, + Alloc: types.GenesisAlloc{testAddress: {Balance: big.NewInt(1000000000000000)}}, BaseFee: big.NewInt(params.InitialBaseFee), } diff --git a/eth/tracers/internal/tracetest/supply_test.go b/eth/tracers/internal/tracetest/supply_test.go index 30fa6d4870..2bc6928d1a 100644 --- a/eth/tracers/internal/tracetest/supply_test.go +++ b/eth/tracers/internal/tracetest/supply_test.go @@ -69,7 +69,7 @@ func emptyBlockGenerationFunc(b *core.BlockGen) {} func TestSupplyOmittedFields(t *testing.T) { var ( - config = *params.MergedTestChainConfig + config = *params.TestChainConfig gspec = &core.Genesis{ Config: &config, } @@ -86,7 +86,7 @@ func TestSupplyOmittedFields(t *testing.T) { expected := supplyInfo{ Number: 0, - Hash: common.HexToHash("0x52f276d96f0afaaf2c3cb358868bdc2779c4b0cb8de3e7e5302e247c0b66a703"), + Hash: common.HexToHash("0xadeda0a83e337b6c073e3f0e9a17531a04009b397a9588c093b628f21b8bc5a3"), ParentHash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), } actual := out[expected.Number] diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 718ce7cb39..a292d6a6e0 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -1856,7 +1856,7 @@ func TestRPCGetBlockOrHeader(t *testing.T) { } func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) { - config := *params.MergedTestChainConfig + config := *params.TestChainConfig config.ShanghaiBlock = big.NewInt(0) config.CancunBlock = big.NewInt(0) @@ -1891,6 +1891,10 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha txHashes = make([]common.Hash, genBlocks) ) + // Set the terminal total difficulty in the config + genesis.Config.TerminalTotalDifficulty = big.NewInt(0) + genesis.Config.TerminalTotalDifficultyPassed = true + backend := newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) { var ( tx *types.Transaction diff --git a/metrics/sample_test.go b/metrics/sample_test.go index 3e7e8f72f1..4e76805be7 100644 --- a/metrics/sample_test.go +++ b/metrics/sample_test.go @@ -129,8 +129,8 @@ func TestExpDecaySample(t *testing.T) { // The priority becomes +Inf quickly after starting if this is done, // effectively freezing the set of samples until a rescale step happens. func TestExpDecaySampleNanosecondRegression(t *testing.T) { - sw := NewExpDecaySample(1000, 0.99) - for i := 0; i < 1000; i++ { + sw := NewExpDecaySample(100, 0.99) + for i := 0; i < 100; i++ { sw.Update(10) } time.Sleep(1 * time.Millisecond) diff --git a/tests/bor/bor_sprint_length_change_test.go b/tests/bor/bor_sprint_length_change_test.go index a031388779..16d5c73722 100644 --- a/tests/bor/bor_sprint_length_change_test.go +++ b/tests/bor/bor_sprint_length_change_test.go @@ -96,6 +96,12 @@ func TestValidatorsBlockProduction(t *testing.T) { // Iterate over all the nodes and start mining time.Sleep(3 * time.Second) + for _, node := range nodes { + if node.PeerCount() == 0 { + panic("Node is not connected to any peers") + } + } + for _, node := range nodes { if err := node.StartMining(); err != nil { panic(err) @@ -117,6 +123,7 @@ func TestValidatorsBlockProduction(t *testing.T) { // check block 7 miner ; expected author is node0 signer blockHeaderVal0 := nodes[0].BlockChain().GetHeaderByNumber(7) blockHeaderVal1 := nodes[1].BlockChain().GetHeaderByNumber(7) + authorVal0, err := nodes[0].Engine().Author(blockHeaderVal0) if err != nil {