backends

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 12 Imported by: 11

README

Backends

Ethergo supports a wide variety of backends for testing contract and chain interactions. Which one you use depends on your needs. There is usually a trade-off between speed, requirements and visibility.

Backend Description Supports RPC Address Supports Forking Embedded (does not require Docker) Speed
Anvil Anvil is a dockerized-backend that supports a wide variety of options including forking, custom gas pricing, etc all configurable at boot time Slow boot, fast run
Geth Geth is an embedded go-ethereum node. This is the equivelant of the geth --dev command. Fastish boot, fast run
Simulated Geth simulated backend Practically instant

Documentation

Overview

Package backends provides different kinds of backends you can test against that conform to a common interface thesse allow you to test eth functionality against a variety of backends

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthType

type AuthType struct {
	// transaction options
	*bind.TransactOpts
	// PrivateKey used for the tx
	PrivateKey *ecdsa.PrivateKey
}

AuthType is the type used for authentication.

type ContractVerifier

type ContractVerifier interface {
	VerifyContract(contractType contracts.ContractType, contract contracts.DeployedContract) error
}

ContractVerifier is a hook used to verify contracts with a test provider.

type SimulatedTestBackend

type SimulatedTestBackend interface {
	// BackendName gets the name of the backend
	BackendName() string
	// T is the testing.T
	T() *testing.T
	// SetT sets the testing.T
	SetT(t *testing.T)
	// Manager is used for concurrent signing while generating nonce
	nonce.Manager
	// ContractVerifier are contract verification hooks
	ContractVerifier
	// WaitForConfirmation waits for a tx confirmation
	WaitForConfirmation(ctx context.Context, transaction *types.Transaction)
	// FundAccount funds an account address with an amount amount
	FundAccount(ctx context.Context, address common.Address, amount big.Int)
	// GetTxContext gets a signed transaction. If the address is `nil`, will fund a new account.
	GetTxContext(ctx context.Context, address *common.Address) (auth AuthType)
	// GetFundedAccount gets a funded account with requestBalance
	GetFundedAccount(ctx context.Context, requestBalance *big.Int) *keystore.Key
	// Chain is the Chain
	//nolint:staticcheck
	chain.Chain
	// Signer is the signer for the chain
	Signer() types.Signer
	// ImpersonateAccount impersonates an account. This is only supported on the anvil backend backends.
	ImpersonateAccount(ctx context.Context, address common.Address, transact func(opts *bind.TransactOpts) *types.Transaction) error
	// EVM is the evm client
	client.EVM
	// Store stores an account
	Store(key *keystore.Key)
}

SimulatedTestBackend is a strict subset of TestBackend that all backends must comply with. TODO: we need one of these for testnets so we can run e2e tests. This should source addresses from a single address.

Directories

Path Synopsis
Package anvil is an anvil test backend.
Package anvil is an anvil test backend.
Package base contains a common interface to be used by multiple backends.
Package base contains a common interface to be used by multiple backends.
Package geth handles creating mock geth clients and simulated backends
Package geth handles creating mock geth clients and simulated backends
Package preset defines preset backends that can be used to create backends of different types
Package preset defines preset backends that can be used to create backends of different types
Package simulated represents a simulated backend.
Package simulated represents a simulated backend.
multibackend
Package multibackend contains a copy of https://github.com/ethereum/go-ethereum/blob/master/accounts/abi/bind/backends/simulated.go that allows use with multiple chains by exporting new methods.
Package multibackend contains a copy of https://github.com/ethereum/go-ethereum/blob/master/accounts/abi/bind/backends/simulated.go that allows use with multiple chains by exporting new methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL