From 0ecde767daba09204c4eb5d5d291a2fec65b3d13 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Tue, 6 May 2025 17:53:46 +0530 Subject: [PATCH] upstream: fixed a few unit tests --- accounts/abi/bind/backends/simulated.go | 7 +++++++ consensus/misc/eip4844/eip4844_test.go | 12 +++++++++++- core/blockchain_test.go | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 3eb4591327..f15d1ff2aa 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -33,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/filtermaps" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" @@ -99,6 +100,8 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc types.Genesi config: genesis.Config, } + filterBackend := &filterBackend{database, blockchain, backend} + backend.filterSystem = filters.NewFilterSystem(filterBackend, filters.Config{}) backend.events = filters.NewEventSystem(backend.filterSystem) header := backend.blockchain.CurrentBlock() @@ -970,6 +973,10 @@ func (fb *filterBackend) CurrentHeader() *types.Header { panic("not supported") } +func (fb *filterBackend) NewMatcherBackend() filtermaps.MatcherBackend { + panic("not supported") +} + func nullSubscription() event.Subscription { return event.NewSubscription(func(quit <-chan struct{}) error { <-quit diff --git a/consensus/misc/eip4844/eip4844_test.go b/consensus/misc/eip4844/eip4844_test.go index bec97ca8f9..7918e4de88 100644 --- a/consensus/misc/eip4844/eip4844_test.go +++ b/consensus/misc/eip4844/eip4844_test.go @@ -27,7 +27,17 @@ import ( func TestCalcExcessBlobGas(t *testing.T) { var ( - config = params.MainnetChainConfig + config = ¶ms.ChainConfig{ + LondonBlock: big.NewInt(0), + CancunBlock: big.NewInt(0), + BlobScheduleConfig: ¶ms.BlobScheduleConfig{ + Cancun: ¶ms.BlobConfig{ + Target: 3, + Max: 6, + UpdateFraction: 3338477, + }, + }, + } targetBlobs = targetBlobsPerBlock(config, uint64(0)) targetBlobGas = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob ) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 6971ad1987..2c2c74f361 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -2292,7 +2292,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon mergeBlock = 0 // Set the terminal total difficulty in the config - gspec.Config.TerminalTotalDifficulty = big.NewInt(0) + chain.Config().TerminalTotalDifficulty = big.NewInt(0) } genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 2*state.TriesInMemory, func(i int, gen *BlockGen) { tx, err := types.SignTx(types.NewTransaction(nonce, common.HexToAddress("deadbeef"), big.NewInt(100), 21000, big.NewInt(int64(i+1)*params.GWei), nil), signer, key) @@ -2329,7 +2329,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // Set the terminal total difficulty in the config ttd := big.NewInt(int64(len(blocks))) ttd.Mul(ttd, params.GenesisDifficulty) - gspec.Config.TerminalTotalDifficulty = ttd + chain.Config().TerminalTotalDifficulty = ttd mergeBlock = len(blocks) }