From f11bb4b63228c4be2cfa083efc514453531dbedf Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 20 Feb 2026 23:11:13 +0100 Subject: [PATCH] eth/catalyst: remove useless constructor --- eth/catalyst/api.go | 3 ++- eth/catalyst/api_testing.go | 18 +++++------------- eth/catalyst/api_testing_test.go | 2 +- eth/catalyst/simulated_beacon.go | 1 + 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index e6ecf4ff6a..f4202f5b52 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -45,9 +45,10 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -// Register adds the engine API to the full node. +// Register adds the engine API and related APIs to the full node. func Register(stack *node.Node, backend *eth.Ethereum) error { stack.RegisterAPIs([]rpc.API{ + newTestingAPI(backend), { Namespace: "engine", Service: NewConsensusAPI(backend), diff --git a/eth/catalyst/api_testing.go b/eth/catalyst/api_testing.go index 406e977d8a..5d6d9de1a5 100644 --- a/eth/catalyst/api_testing.go +++ b/eth/catalyst/api_testing.go @@ -25,7 +25,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" ) @@ -35,20 +34,13 @@ type TestingAPI struct { eth *eth.Ethereum } -func NewTestingAPI(eth *eth.Ethereum) *TestingAPI { - return &TestingAPI{ - eth: eth, - } -} - -func RegisterTestingAPI(stack *node.Node, backend *eth.Ethereum) error { - stack.RegisterAPIs([]rpc.API{{ +func newTestingAPI(backend *eth.Ethereum) rpc.API { + return rpc.API{ Namespace: "testing", - Service: NewTestingAPI(backend), + Service: &TestingAPI{backend}, + Version: "1.0", Authenticated: false, - }, - }) - return nil + } } func (api *TestingAPI) BuildBlockV1(parentHash common.Hash, payloadAttributes engine.PayloadAttributes, transactions *[]hexutil.Bytes, extraData *hexutil.Bytes) (*engine.ExecutionPayloadEnvelope, error) { diff --git a/eth/catalyst/api_testing_test.go b/eth/catalyst/api_testing_test.go index a189a73905..09978c8e2b 100644 --- a/eth/catalyst/api_testing_test.go +++ b/eth/catalyst/api_testing_test.go @@ -46,7 +46,7 @@ func TestBuildBlockV1(t *testing.T) { currentNonce, _ := ethservice.APIBackend.GetPoolNonce(context.Background(), testAddr) tx, _ := types.SignTx(types.NewTransaction(currentNonce, testAddr, big.NewInt(1), params.TxGas, big.NewInt(params.InitialBaseFee*2), nil), types.LatestSigner(ethservice.BlockChain().Config()), testKey) - api := NewTestingAPI(ethservice) + api := &TestingAPI{eth: ethservice} t.Run("buildOnCurrentHead", func(t *testing.T) { envelope, err := api.BuildBlockV1(parent.Hash(), attrs, nil, nil) diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index 92f9798e71..9b6ad54893 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -364,5 +364,6 @@ func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) { Service: api, Version: "1.0", }, + newTestingAPI(sim.eth), }) }