e2eutils

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMnemonicConfig = &MnemonicConfig{
	Mnemonic:     "test test test test test test test test test test test junk",
	Deployer:     "m/44'/60'/0'/0/1",
	CliqueSigner: "m/44'/60'/0'/0/2",
	Proposer:     "m/44'/60'/0'/0/3",
	Batcher:      "m/44'/60'/0'/0/4",
	SequencerP2P: "m/44'/60'/0'/0/5",
	Alice:        "m/44'/60'/0'/0/6",
	Bob:          "m/44'/60'/0'/0/7",
	Mallory:      "m/44'/60'/0'/0/8",
	SysCfgOwner:  "m/44'/60'/0'/0/9",
}

DefaultMnemonicConfig is the default mnemonic used in testing. We prefer a mnemonic rather than direct private keys to make it easier to export all testing keys in external tooling for use during debugging.

Functions

func CollectAddresses added in v0.8.10

func CollectAddresses(sd *SetupData, dp *DeployParams) (out []common.Address)

CollectAddresses constructs a lists of addresses that may be used as fuzzing corpora or random address selection.

func EncodePrivKey

func EncodePrivKey(priv *ecdsa.PrivateKey) hexutil.Bytes

EncodePrivKey encodes the given private key in 32 bytes

func Ether

func Ether(v uint64) *big.Int

Ether converts a uint64 Ether amount into a *big.Int amount in wei units, for allocating test balances.

func ForkedDeployConfig added in v0.10.1

func ForkedDeployConfig(t require.TestingT, mnemonicCfg *MnemonicConfig, startBlock *types.Block) *genesis.DeployConfig

ForkedDeployConfig returns a deploy config that's suitable for use with a forked L1.

func SystemConfigFromDeployConfig added in v0.9.0

func SystemConfigFromDeployConfig(deployConfig *genesis.DeployConfig) eth.SystemConfig

func TimeoutCtx added in v0.8.10

func TimeoutCtx(t *testing.T, timeout time.Duration) context.Context

func WaitBlock added in v0.8.10

func WaitBlock(ctx context.Context, client *ethclient.Client, n uint64) error

func WaitFor added in v0.8.10

func WaitFor(ctx context.Context, rate time.Duration, cb func() (bool, error)) error

func WaitReceipt added in v0.8.10

func WaitReceipt(ctx context.Context, client *ethclient.Client, hash common.Hash, status uint64) (*types.Receipt, error)

func WaitReceiptFail added in v0.8.10

func WaitReceiptFail(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Receipt, error)

func WaitReceiptOK added in v0.8.10

func WaitReceiptOK(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Receipt, error)

func WriteDefaultJWT

func WriteDefaultJWT(t TestingBase) string

WriteDefaultJWT writes a testing JWT to the temporary directory of the test and returns the path to the JWT file.

Types

type Addresses

type Addresses struct {
	Deployer     common.Address
	CliqueSigner common.Address
	SysCfgOwner  common.Address

	// rollup actors
	Proposer     common.Address
	Batcher      common.Address
	SequencerP2P common.Address

	// prefunded L1/L2 accounts for testing
	Alice   common.Address
	Bob     common.Address
	Mallory common.Address
}

Addresses bundles the addresses for all common rollup addresses for testing purposes.

func (*Addresses) All

func (a *Addresses) All() []common.Address

type AllocParams

type AllocParams struct {
	L1Alloc          core.GenesisAlloc
	L2Alloc          core.GenesisAlloc
	PrefundTestUsers bool
}

AllocParams defines genesis allocations to apply on top of the genesis generated by deploy parameters. These allocations override existing allocations per account, i.e. the allocations are merged with AllocParams having priority.

type DeployParams

type DeployParams struct {
	DeployConfig   *genesis.DeployConfig
	MnemonicConfig *MnemonicConfig
	Secrets        *Secrets
	Addresses      *Addresses
}

DeployParams bundles the deployment parameters to generate further testing inputs with.

func MakeDeployParams

func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams

type DeploymentsL1

type DeploymentsL1 struct {
	L1CrossDomainMessengerProxy common.Address
	L1StandardBridgeProxy       common.Address
	L2OutputOracleProxy         common.Address
	OptimismPortalProxy         common.Address
	SystemConfigProxy           common.Address
}

DeploymentsL1 captures the L1 addresses used in the deployment, commonly just the developer predeploys during testing, but later deployed contracts may be used in some tests too.

type MnemonicConfig

type MnemonicConfig struct {
	Mnemonic string

	Deployer     string
	CliqueSigner string
	SysCfgOwner  string

	// rollup actors
	Proposer     string
	Batcher      string
	SequencerP2P string

	// prefunded L1/L2 accounts for testing
	Alice   string
	Bob     string
	Mallory string
}

MnemonicConfig configures the private keys for the hive testnet. It's json-serializable, so we can ship it to e.g. the hardhat script client.

func (*MnemonicConfig) Secrets

func (m *MnemonicConfig) Secrets() (*Secrets, error)

Secrets computes the private keys for all mnemonic paths, which can then be kept around for fast precomputed private key access.

type Secrets

type Secrets struct {
	Deployer     *ecdsa.PrivateKey
	CliqueSigner *ecdsa.PrivateKey
	SysCfgOwner  *ecdsa.PrivateKey

	// rollup actors
	Proposer     *ecdsa.PrivateKey
	Batcher      *ecdsa.PrivateKey
	SequencerP2P *ecdsa.PrivateKey

	// prefunded L1/L2 accounts for testing
	Alice   *ecdsa.PrivateKey
	Bob     *ecdsa.PrivateKey
	Mallory *ecdsa.PrivateKey

	// Share the wallet to be able to generate more accounts
	Wallet *hdwallet.Wallet
}

Secrets bundles secp256k1 private keys for all common rollup actors for testing purposes.

func (*Secrets) Addresses

func (s *Secrets) Addresses() *Addresses

Addresses computes the ethereum address of each account, which can then be kept around for fast precomputed address access.

type SetupData

type SetupData struct {
	L1Cfg         *core.Genesis
	L2Cfg         *core.Genesis
	RollupCfg     *rollup.Config
	DeploymentsL1 DeploymentsL1
}

SetupData bundles the L1, L2, rollup and deployment configuration data: everything for a full test setup.

func Setup

func Setup(t require.TestingT, deployParams *DeployParams, alloc *AllocParams) *SetupData

Setup computes the testing setup configurations from deployment configuration and optional allocation parameters.

type TestParams

type TestParams struct {
	MaxSequencerDrift   uint64
	SequencerWindowSize uint64
	ChannelTimeout      uint64
	L1BlockTime         uint64
}

TestParams parametrizes the most essential rollup configuration parameters

type TestingBase

type TestingBase interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
	Name() string
	Setenv(key, value string)
	Skip(args ...any)
	SkipNow()
	Skipf(format string, args ...any)
	Skipped() bool
	TempDir() string
	Parallel()
}

TestingBase is an interface used for standard Go testing. This interface is used for unit tests, benchmarks, and fuzz tests and also emulated in Hive.

The Go testing.TB interface does not allow extensions by embedding the interface, so we repeat it here.

Jump to

Keyboard shortcuts

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