Skip to content

Commit

Permalink
use mock consensus client
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Jun 8, 2024
1 parent 24f5511 commit caf227c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ethergo/backends/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package geth
import (
"math/big"
"testing"
"time"

"github.com/Flaque/filet"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -45,11 +46,13 @@ func makeNodeConfig(tb testing.TB) *node.Config {
// makeEthConfig gets the eth config for a mock node.
func makeEthConfig(address common.Address, config *params.ChainConfig) *ethconfig.Config {
ethConfig := ethconfig.Defaults

ethConfig.NetworkId = config.ChainID.Uint64()
ethConfig.Genesis = core.DeveloperGenesisBlock(10000000, address)
ethConfig.Genesis.ExtraData = append([]byte{}, make([]byte, 32)...) // 32 bytes of vanity
ethConfig.Genesis.ExtraData = append(ethConfig.Genesis.ExtraData, address.Bytes()...) // Signer address
ethConfig.Genesis.ExtraData = append(ethConfig.Genesis.ExtraData, make([]byte, 65)...) // 65 bytes of signature
ethConfig.Miner.Recommit = time.Second

ethConfig.Genesis.Config = config
ethConfig.Miner.Etherbase = address
Expand Down
6 changes: 6 additions & 0 deletions ethergo/backends/geth/geth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package geth

import (
"context"
"github.com/ethereum/go-ethereum/eth/catalyst"
"github.com/synapsecns/sanguine/ethergo/client"
"math/big"
"os"
Expand Down Expand Up @@ -92,6 +93,11 @@ func NewEmbeddedBackendWithConfig(ctx context.Context, t *testing.T, config *par
embedded.ethBackend, err = eth.New(embedded.Node, ethConfig)
assert.Nil(t, err)

// setup the consensus client
simBeacon, err := catalyst.NewSimulatedBeacon(1, embedded.ethBackend)

Check failure on line 97 in ethergo/backends/geth/geth.go

View workflow job for this annotation

GitHub Actions / Lint (ethergo)

ineffectual assignment to err (ineffassign)
catalyst.RegisterSimulatedBeaconAPIs(embedded.Node, simBeacon)
embedded.Node.RegisterLifecycle(simBeacon)

embedded.Node.RegisterAPIs(toPublic(tracers.APIs(embedded.ethBackend.APIBackend)))

// Configure log filter RPC API.
Expand Down

0 comments on commit caf227c

Please sign in to comment.