testutils

package
v1.16.10 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 40 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RandomDataSize = 1000

Functions

func BigEqual

func BigEqual(a, b *big.Int) bool

func FakeGenesis

func FakeGenesis(l1 rune, l2 rune, l1GenesisNumber uint64) rollup.Genesis

func GenerateDeposit

func GenerateDeposit(sourceHash common.Hash, rng *rand.Rand) *types.DepositTx

Returns a DepositEvent customized on the basis of the id parameter.

func GenerateLog

func GenerateLog(addr common.Address, topics []common.Hash, data []byte) *types.Log

Generates an EVM log entry with the given topics and data.

func InsecureRandomKey

func InsecureRandomKey(rng *rand.Rand) *ecdsa.PrivateKey

InsecureRandomKey returns a random private key from a limited set of keys. Output is deterministic when the supplied rng generates the same random sequence.

func IsolatedTestDirWithAutoCleanup

func IsolatedTestDirWithAutoCleanup(t *testing.T) string

func MakeBlockInfo

func MakeBlockInfo(fn func(l *MockBlockInfo)) func(rng *rand.Rand) *MockBlockInfo

func NextRandomL2Ref

func NextRandomL2Ref(rng *rand.Rand, l2BlockTime uint64, parent eth.L2BlockRef, origin eth.BlockID) eth.L2BlockRef

func NextRandomRef

func NextRandomRef(rng *rand.Rand, parent eth.L1BlockRef) eth.L1BlockRef

func RandomAccessList

func RandomAccessList(rng *rand.Rand) types.AccessList

func RandomAccessListTx

func RandomAccessListTx(rng *rand.Rand, signer types.Signer) *types.Transaction

func RandomAddress

func RandomAddress(rng *rand.Rand) (out common.Address)

func RandomBlob

func RandomBlob(rng *rand.Rand) (kzg4844.Blob, kzg4844.Commitment, error)

func RandomBlock

func RandomBlock(rng *rand.Rand, txCount uint64) (*types.Block, []*types.Receipt)

func RandomBlockID

func RandomBlockID(rng *rand.Rand) eth.BlockID

func RandomBlockPrependTxs

func RandomBlockPrependTxs(rng *rand.Rand, txCount int, ptxs ...*types.Transaction) (*types.Block, []*types.Receipt)

RandomBlockPrependTxs returns a random block with txCount randomly generated transactions and additionally the transactions ptxs prepended. So the total number of transactions is len(ptxs) + txCount.

func RandomBlockPrependTxsWithTime

func RandomBlockPrependTxsWithTime(rng *rand.Rand, txCount int, t uint64, ptxs ...*types.Transaction) (*types.Block, []*types.Receipt)

func RandomBlockRef

func RandomBlockRef(rng *rand.Rand) eth.L1BlockRef

func RandomBool

func RandomBool(rng *rand.Rand) bool

func RandomData

func RandomData(rng *rand.Rand, size int) []byte

func RandomDynamicFeeTx

func RandomDynamicFeeTx(rng *rand.Rand, signer types.Signer) *types.Transaction

func RandomDynamicFeeTxWithBaseFee

func RandomDynamicFeeTxWithBaseFee(rng *rand.Rand, baseFee *big.Int, signer types.Signer) *types.Transaction

func RandomETH

func RandomETH(rng *rand.Rand, max int64) *big.Int

func RandomHash

func RandomHash(rng *rand.Rand) (out common.Hash)

func RandomHeader

func RandomHeader(rng *rand.Rand) *types.Header

func RandomHeaderWithTime

func RandomHeaderWithTime(rng *rand.Rand, t uint64) *types.Header

func RandomKey

func RandomKey() *ecdsa.PrivateKey

func RandomL2BlockRef

func RandomL2BlockRef(rng *rand.Rand) eth.L2BlockRef

func RandomLegacyTx

func RandomLegacyTx(rng *rand.Rand, signer types.Signer) *types.Transaction

func RandomLegacyTxNotProtected

func RandomLegacyTxNotProtected(rng *rand.Rand) *types.Transaction

func RandomLog

func RandomLog(rng *rand.Rand) *types.Log

func RandomOutputResponse

func RandomOutputResponse(rng *rand.Rand) *eth.OutputResponse

func RandomOutputV0

func RandomOutputV0(rng *rand.Rand) *eth.OutputV0

func RandomReceipt

func RandomReceipt(rng *rand.Rand, signer types.Signer, tx *types.Transaction, txIndex uint64, cumulativeGasUsed uint64) *types.Receipt

func RandomSetCodeAuth

func RandomSetCodeAuth(rng *rand.Rand) types.SetCodeAuthorization

func RandomSetCodeTx

func RandomSetCodeTx(rng *rand.Rand, signer types.Signer) *types.Transaction

func RandomTo

func RandomTo(rng *rand.Rand) *common.Address

func RandomTx

func RandomTx(rng *rand.Rand, baseFee *big.Int, signer types.Signer) *types.Transaction

func RequireBigEqual

func RequireBigEqual(t *testing.T, exp, actual *big.Int)

func RunOnBranch

func RunOnBranch(t *testing.T, re *regexp.Regexp)

RunOnBranch skips the current test unless the current Git branch matches the provided regex. This method shells out to git. Any failures running git are considered test failures.

func WithAccountBalance

func WithAccountBalance(address common.Address, balance *big.Int) func(*SimulatedEthClientConfig)

func WithAccountsBalances

func WithAccountsBalances(balances map[common.Address]*big.Int) func(*SimulatedEthClientConfig)

func WithBlockGasLimit

func WithBlockGasLimit(limit uint64) func(*SimulatedEthClientConfig)

Types

type FakeChainSource

type FakeChainSource struct {
	// contains filtered or unexported fields
}

FakeChainSource implements the ChainSource interface with the ability to control what the head block is of the L1 and L2 chains. In addition, it enables re-orgs to easily be implemented

func NewFakeChainSource

func NewFakeChainSource(l1 []string, l2 []string, l1GenesisNumber int, log log.Logger) *FakeChainSource

func (*FakeChainSource) AdvanceL1

func (m *FakeChainSource) AdvanceL1() eth.L1BlockRef

func (*FakeChainSource) ForkchoiceUpdate

func (*FakeChainSource) L1BlockRefByHash

func (m *FakeChainSource) L1BlockRefByHash(ctx context.Context, l1Hash common.Hash) (eth.L1BlockRef, error)

func (*FakeChainSource) L1BlockRefByLabel

func (m *FakeChainSource) L1BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L1BlockRef, error)

func (*FakeChainSource) L1BlockRefByNumber

func (m *FakeChainSource) L1BlockRefByNumber(ctx context.Context, l1Num uint64) (eth.L1BlockRef, error)

func (*FakeChainSource) L1Head

func (m *FakeChainSource) L1Head() eth.L1BlockRef

func (*FakeChainSource) L1Range

func (m *FakeChainSource) L1Range(ctx context.Context, base eth.BlockID, max uint64) ([]eth.BlockID, error)

func (*FakeChainSource) L2BlockRefByHash

func (m *FakeChainSource) L2BlockRefByHash(ctx context.Context, l2Hash common.Hash) (eth.L2BlockRef, error)

func (*FakeChainSource) L2BlockRefByLabel

func (m *FakeChainSource) L2BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L2BlockRef, error)

func (*FakeChainSource) L2BlockRefByNumber

func (m *FakeChainSource) L2BlockRefByNumber(ctx context.Context, l2Num *big.Int) (eth.L2BlockRef, error)

func (*FakeChainSource) ReorgL1

func (m *FakeChainSource) ReorgL1()

func (*FakeChainSource) SetL2Finalized

func (m *FakeChainSource) SetL2Finalized(finalized common.Hash)

func (*FakeChainSource) SetL2Head

func (m *FakeChainSource) SetL2Head(head int) eth.L2BlockRef

func (*FakeChainSource) SetL2Safe

func (m *FakeChainSource) SetL2Safe(safe common.Hash)

type FakePublishAPI

type FakePublishAPI struct {
	Log log.Logger
}

FakePublishAPI is used to instantiate an opstack API backend without full block publishing

func (*FakePublishAPI) PublishBlock

type MockBlobsFetcher

type MockBlobsFetcher struct {
	mock.Mock
}

func (*MockBlobsFetcher) ExpectOnGetBlobSidecars

func (cl *MockBlobsFetcher) ExpectOnGetBlobSidecars(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash, commitment eth.Bytes48, blobs []*eth.Blob, err error)

func (*MockBlobsFetcher) ExpectOnGetBlobsByHash

func (cl *MockBlobsFetcher) ExpectOnGetBlobsByHash(ctx context.Context, time uint64, hashes []common.Hash, blobs []*eth.Blob, err error)

func (*MockBlobsFetcher) GetBlobSidecars

func (cl *MockBlobsFetcher) GetBlobSidecars(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.BlobSidecar, error)

func (*MockBlobsFetcher) GetBlobsByHash

func (cl *MockBlobsFetcher) GetBlobsByHash(ctx context.Context, time uint64, hashes []common.Hash) ([]*eth.Blob, error)

type MockBlockInfo

type MockBlockInfo struct {
	InfoHash          common.Hash
	InfoParentHash    common.Hash
	InfoCoinbase      common.Address
	InfoRoot          common.Hash
	InfoNum           uint64
	InfoTime          uint64
	InfoMixDigest     [32]byte
	InfoBaseFee       *big.Int
	InfoBlobBaseFee   *big.Int
	InfoExcessBlobGas *uint64
	InfoReceiptRoot   common.Hash
	InfoGasUsed       uint64
	InfoBlobGasUsed   *uint64
	InfoGasLimit      uint64
	InfoHeaderRLP     []byte

	InfoParentBeaconRoot *common.Hash
	InfoWithdrawalsRoot  *common.Hash
}

func RandomBlockInfo

func RandomBlockInfo(rng *rand.Rand) *MockBlockInfo

func (*MockBlockInfo) BaseFee

func (l *MockBlockInfo) BaseFee() *big.Int

func (*MockBlockInfo) BlobBaseFee

func (l *MockBlockInfo) BlobBaseFee(chainConfig *params.ChainConfig) *big.Int

func (*MockBlockInfo) BlobGasUsed

func (l *MockBlockInfo) BlobGasUsed() *uint64

func (*MockBlockInfo) BlockRef

func (l *MockBlockInfo) BlockRef() eth.L1BlockRef

func (*MockBlockInfo) Coinbase

func (l *MockBlockInfo) Coinbase() common.Address

func (*MockBlockInfo) ExcessBlobGas

func (l *MockBlockInfo) ExcessBlobGas() *uint64

func (*MockBlockInfo) GasLimit

func (l *MockBlockInfo) GasLimit() uint64

func (*MockBlockInfo) GasUsed

func (l *MockBlockInfo) GasUsed() uint64

func (*MockBlockInfo) Hash

func (l *MockBlockInfo) Hash() common.Hash

func (*MockBlockInfo) Header

func (l *MockBlockInfo) Header() *types.Header

func (*MockBlockInfo) HeaderRLP

func (l *MockBlockInfo) HeaderRLP() ([]byte, error)

func (*MockBlockInfo) ID

func (l *MockBlockInfo) ID() eth.BlockID

func (*MockBlockInfo) MixDigest

func (l *MockBlockInfo) MixDigest() common.Hash

func (*MockBlockInfo) NumberU64

func (l *MockBlockInfo) NumberU64() uint64

func (*MockBlockInfo) ParentBeaconRoot

func (l *MockBlockInfo) ParentBeaconRoot() *common.Hash

func (*MockBlockInfo) ParentHash

func (l *MockBlockInfo) ParentHash() common.Hash

func (*MockBlockInfo) ReceiptHash

func (l *MockBlockInfo) ReceiptHash() common.Hash

func (*MockBlockInfo) Root

func (l *MockBlockInfo) Root() common.Hash

func (*MockBlockInfo) Time

func (l *MockBlockInfo) Time() uint64

func (*MockBlockInfo) WithdrawalsRoot

func (l *MockBlockInfo) WithdrawalsRoot() *common.Hash

type MockDebugClient

type MockDebugClient struct {
	mock.Mock
}

func (*MockDebugClient) CodeByHash

func (m *MockDebugClient) CodeByHash(ctx context.Context, hash common.Hash) ([]byte, error)

func (*MockDebugClient) ExpectCodeByHash

func (m *MockDebugClient) ExpectCodeByHash(hash common.Hash, res []byte, err error)

func (*MockDebugClient) ExpectNodeByHash

func (m *MockDebugClient) ExpectNodeByHash(hash common.Hash, res []byte, err error)

func (*MockDebugClient) NodeByHash

func (m *MockDebugClient) NodeByHash(ctx context.Context, hash common.Hash) ([]byte, error)

type MockEmitter

type MockEmitter struct {
	mock.Mock
}

func (*MockEmitter) AssertExpectations

func (m *MockEmitter) AssertExpectations(t mock.TestingT)

func (*MockEmitter) Emit

func (m *MockEmitter) Emit(ctx context.Context, ev event.Event)

func (*MockEmitter) ExpectMaybeRun

func (m *MockEmitter) ExpectMaybeRun(fn func(ev event.Event))

func (*MockEmitter) ExpectOnce

func (m *MockEmitter) ExpectOnce(expected event.Event)

func (*MockEmitter) ExpectOnceRun

func (m *MockEmitter) ExpectOnceRun(fn func(ev event.Event))

func (*MockEmitter) ExpectOnceType

func (m *MockEmitter) ExpectOnceType(typ string)

type MockEngine

type MockEngine struct {
	MockL2Client
}

func (*MockEngine) ExpectForkchoiceUpdate

func (m *MockEngine) ExpectForkchoiceUpdate(state *eth.ForkchoiceState, attr *eth.PayloadAttributes, result *eth.ForkchoiceUpdatedResult, err error)

func (*MockEngine) ExpectGetPayload

func (m *MockEngine) ExpectGetPayload(payloadId eth.PayloadID, payload *eth.ExecutionPayloadEnvelope, err error)

func (*MockEngine) ExpectNewPayload

func (m *MockEngine) ExpectNewPayload(payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash, result *eth.PayloadStatusV1, err error)

func (*MockEngine) ForkchoiceUpdate

func (m *MockEngine) ForkchoiceUpdate(ctx context.Context, state *eth.ForkchoiceState, attr *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)

func (*MockEngine) GetPayload

func (m *MockEngine) GetPayload(ctx context.Context, payloadInfo eth.PayloadInfo) (*eth.ExecutionPayloadEnvelope, error)

func (*MockEngine) NewPayload

func (m *MockEngine) NewPayload(ctx context.Context, payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash) (*eth.PayloadStatusV1, error)

type MockEthClient

type MockEthClient struct {
	mock.Mock
}

func (*MockEthClient) BlockByNumber

func (m *MockEthClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

func (*MockEthClient) BlockRefByHash

func (m *MockEthClient) BlockRefByHash(ctx context.Context, hash common.Hash) (eth.BlockRef, error)

func (*MockEthClient) BlockRefByLabel

func (m *MockEthClient) BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockRef, error)

func (*MockEthClient) BlockRefByNumber

func (m *MockEthClient) BlockRefByNumber(ctx context.Context, num uint64) (eth.BlockRef, error)

func (*MockEthClient) Client

func (m *MockEthClient) Client() *rpc.Client

func (*MockEthClient) Close

func (m *MockEthClient) Close()

func (*MockEthClient) ExpectBlockByNumber

func (m *MockEthClient) ExpectBlockByNumber(number *big.Int, block *types.Block, err error)

func (*MockEthClient) ExpectBlockRefByHash

func (m *MockEthClient) ExpectBlockRefByHash(hash common.Hash, ref eth.BlockRef, err error)

func (*MockEthClient) ExpectBlockRefByLabel

func (m *MockEthClient) ExpectBlockRefByLabel(label eth.BlockLabel, ref eth.BlockRef, err error)

func (*MockEthClient) ExpectBlockRefByNumber

func (m *MockEthClient) ExpectBlockRefByNumber(num uint64, ref eth.BlockRef, err error)

func (*MockEthClient) ExpectClose

func (m *MockEthClient) ExpectClose()

func (*MockEthClient) ExpectFetchReceipts

func (m *MockEthClient) ExpectFetchReceipts(hash common.Hash, info eth.BlockInfo, receipts types.Receipts, err error)

func (*MockEthClient) ExpectGetProof

func (m *MockEthClient) ExpectGetProof(address common.Address, storage []common.Hash, blockTag string, result *eth.AccountResult, err error)

func (*MockEthClient) ExpectGetStorageAt

func (m *MockEthClient) ExpectGetStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockTag string, result common.Hash, err error)

func (*MockEthClient) ExpectInfoAndTxsByHash

func (m *MockEthClient) ExpectInfoAndTxsByHash(hash common.Hash, info eth.BlockInfo, transactions types.Transactions, err error)

func (*MockEthClient) ExpectInfoAndTxsByLabel

func (m *MockEthClient) ExpectInfoAndTxsByLabel(label eth.BlockLabel, info eth.BlockInfo, transactions types.Transactions, err error)

func (*MockEthClient) ExpectInfoAndTxsByNumber

func (m *MockEthClient) ExpectInfoAndTxsByNumber(number uint64, info eth.BlockInfo, transactions types.Transactions, err error)

func (*MockEthClient) ExpectInfoByHash

func (m *MockEthClient) ExpectInfoByHash(hash common.Hash, info eth.BlockInfo, err error)

func (*MockEthClient) ExpectInfoByLabel

func (m *MockEthClient) ExpectInfoByLabel(label eth.BlockLabel, info eth.BlockInfo, err error)

func (*MockEthClient) ExpectInfoByNumber

func (m *MockEthClient) ExpectInfoByNumber(number uint64, info eth.BlockInfo, err error)

func (*MockEthClient) ExpectPayloadByHash

func (m *MockEthClient) ExpectPayloadByHash(hash common.Hash, payload *eth.ExecutionPayloadEnvelope, err error)

func (*MockEthClient) ExpectPayloadByLabel

func (m *MockEthClient) ExpectPayloadByLabel(label eth.BlockLabel, payload *eth.ExecutionPayloadEnvelope, err error)

func (*MockEthClient) ExpectPayloadByNumber

func (m *MockEthClient) ExpectPayloadByNumber(n uint64, payload *eth.ExecutionPayloadEnvelope, err error)

func (*MockEthClient) ExpectReadStorageAt

func (m *MockEthClient) ExpectReadStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockHash common.Hash, result common.Hash, err error)

func (*MockEthClient) FetchReceipts

func (m *MockEthClient) FetchReceipts(ctx context.Context, blockHash common.Hash) (eth.BlockInfo, types.Receipts, error)

func (*MockEthClient) GetProof

func (m *MockEthClient) GetProof(ctx context.Context, address common.Address, storage []common.Hash, blockTag string) (*eth.AccountResult, error)

func (*MockEthClient) GetStorageAt

func (m *MockEthClient) GetStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockTag string) (common.Hash, error)

func (*MockEthClient) InfoAndTxsByHash

func (m *MockEthClient) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, types.Transactions, error)

func (*MockEthClient) InfoAndTxsByLabel

func (m *MockEthClient) InfoAndTxsByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, types.Transactions, error)

func (*MockEthClient) InfoAndTxsByNumber

func (m *MockEthClient) InfoAndTxsByNumber(ctx context.Context, number uint64) (eth.BlockInfo, types.Transactions, error)

func (*MockEthClient) InfoByHash

func (m *MockEthClient) InfoByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, error)

func (*MockEthClient) InfoByLabel

func (m *MockEthClient) InfoByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, error)

func (*MockEthClient) InfoByNumber

func (m *MockEthClient) InfoByNumber(ctx context.Context, number uint64) (eth.BlockInfo, error)

func (*MockEthClient) MaybeClose

func (m *MockEthClient) MaybeClose()

func (*MockEthClient) PayloadByHash

func (m *MockEthClient) PayloadByHash(ctx context.Context, hash common.Hash) (*eth.ExecutionPayloadEnvelope, error)

func (*MockEthClient) PayloadByLabel

func (m *MockEthClient) PayloadByLabel(ctx context.Context, label eth.BlockLabel) (*eth.ExecutionPayloadEnvelope, error)

func (*MockEthClient) PayloadByNumber

func (m *MockEthClient) PayloadByNumber(ctx context.Context, n uint64) (*eth.ExecutionPayloadEnvelope, error)

func (*MockEthClient) ReadStorageAt

func (m *MockEthClient) ReadStorageAt(ctx context.Context, address common.Address, storageSlot common.Hash, blockHash common.Hash) (common.Hash, error)

type MockL1Source

type MockL1Source struct {
	MockEthClient
}

func (*MockL1Source) ExpectL1BlockRefByHash

func (m *MockL1Source) ExpectL1BlockRefByHash(hash common.Hash, ref eth.L1BlockRef, err error)

func (*MockL1Source) ExpectL1BlockRefByLabel

func (m *MockL1Source) ExpectL1BlockRefByLabel(label eth.BlockLabel, ref eth.L1BlockRef, err error)

func (*MockL1Source) ExpectL1BlockRefByNumber

func (m *MockL1Source) ExpectL1BlockRefByNumber(num uint64, ref eth.L1BlockRef, err error)

func (*MockL1Source) L1BlockRefByHash

func (m *MockL1Source) L1BlockRefByHash(ctx context.Context, hash common.Hash) (eth.L1BlockRef, error)

func (*MockL1Source) L1BlockRefByLabel

func (m *MockL1Source) L1BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L1BlockRef, error)

func (*MockL1Source) L1BlockRefByNumber

func (m *MockL1Source) L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1BlockRef, error)

type MockL2Client

type MockL2Client struct {
	MockEthClient
}

func (*MockL2Client) ExpectL2BlockRefByHash

func (m *MockL2Client) ExpectL2BlockRefByHash(hash common.Hash, ref eth.L2BlockRef, err error)

func (*MockL2Client) ExpectL2BlockRefByLabel

func (m *MockL2Client) ExpectL2BlockRefByLabel(label eth.BlockLabel, ref eth.L2BlockRef, err error)

func (*MockL2Client) ExpectL2BlockRefByNumber

func (m *MockL2Client) ExpectL2BlockRefByNumber(num uint64, ref eth.L2BlockRef, err error)

func (*MockL2Client) ExpectOutputV0AtBlock

func (m *MockL2Client) ExpectOutputV0AtBlock(blockHash common.Hash, output *eth.OutputV0, err error)

func (*MockL2Client) ExpectSystemConfigByL2Hash

func (m *MockL2Client) ExpectSystemConfigByL2Hash(hash common.Hash, cfg eth.SystemConfig, err error)

func (*MockL2Client) L2BlockRefByHash

func (c *MockL2Client) L2BlockRefByHash(ctx context.Context, hash common.Hash) (eth.L2BlockRef, error)

func (*MockL2Client) L2BlockRefByLabel

func (c *MockL2Client) L2BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L2BlockRef, error)

func (*MockL2Client) L2BlockRefByNumber

func (c *MockL2Client) L2BlockRefByNumber(ctx context.Context, num uint64) (eth.L2BlockRef, error)

func (*MockL2Client) OutputV0AtBlock

func (m *MockL2Client) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error)

func (*MockL2Client) SystemConfigByL2Hash

func (m *MockL2Client) SystemConfigByL2Hash(ctx context.Context, hash common.Hash) (eth.SystemConfig, error)

type MockRPC

type MockRPC struct {
	mock.Mock
}

func (*MockRPC) BatchCallContext

func (m *MockRPC) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

func (*MockRPC) CallContext

func (m *MockRPC) CallContext(ctx context.Context, result any, method string, args ...any) error

func (*MockRPC) Close

func (m *MockRPC) Close()

func (*MockRPC) ExpectBatchCallContext

func (m *MockRPC) ExpectBatchCallContext(b []rpc.BatchElem, err error)

func (*MockRPC) ExpectCallContext

func (m *MockRPC) ExpectCallContext(result any, method string, args []any, err error)

func (*MockRPC) ExpectClose

func (m *MockRPC) ExpectClose()

func (*MockRPC) ExpectSubscribe

func (m *MockRPC) ExpectSubscribe(namespace string, channel any, args []any, sub ethereum.Subscription, err error)

func (*MockRPC) Subscribe

func (m *MockRPC) Subscribe(ctx context.Context, namespace string, channel any, args ...any) (ethereum.Subscription, error)

func (*MockRPC) URL

func (m *MockRPC) URL() string

type MockRollupClient

type MockRollupClient struct {
	mock.Mock
}

func (*MockRollupClient) Close

func (m *MockRollupClient) Close()

func (*MockRollupClient) ExpectClose

func (m *MockRollupClient) ExpectClose()

func (*MockRollupClient) ExpectOutputAtBlock

func (m *MockRollupClient) ExpectOutputAtBlock(blockNum uint64, response *eth.OutputResponse, err error) *mock.Call

func (*MockRollupClient) ExpectRollupConfig

func (m *MockRollupClient) ExpectRollupConfig(config *rollup.Config, err error)

func (*MockRollupClient) ExpectSequencerActive

func (m *MockRollupClient) ExpectSequencerActive(active bool, err error)

func (*MockRollupClient) ExpectStartSequencer

func (m *MockRollupClient) ExpectStartSequencer(unsafeHead common.Hash, err error)

func (*MockRollupClient) ExpectSyncStatus

func (m *MockRollupClient) ExpectSyncStatus(status *eth.SyncStatus, err error)

func (*MockRollupClient) MaybeClose

func (m *MockRollupClient) MaybeClose()

func (*MockRollupClient) OutputAtBlock

func (m *MockRollupClient) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)

func (*MockRollupClient) RollupConfig

func (m *MockRollupClient) RollupConfig(ctx context.Context) (*rollup.Config, error)

func (*MockRollupClient) SequencerActive

func (m *MockRollupClient) SequencerActive(ctx context.Context) (bool, error)

func (*MockRollupClient) StartSequencer

func (m *MockRollupClient) StartSequencer(ctx context.Context, unsafeHead common.Hash) error

func (*MockRollupClient) SyncStatus

func (m *MockRollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)

type MockRuntimeConfig

type MockRuntimeConfig struct {
	P2PSeqAddress common.Address
}

func (*MockRuntimeConfig) P2PSequencerAddress

func (m *MockRuntimeConfig) P2PSequencerAddress() common.Address

type RPCErrFaker

type RPCErrFaker struct {
	// RPC to call when no ErrFn is set, or the ErrFn does not return an error
	RPC client.RPC
	// ErrFn returns an error when the RPC needs to return error upon a call, batch call or subscription (nil input).
	// The RPC operates without fake errors if the ErrFn is nil, or returns nil.
	ErrFn func(call []rpc.BatchElem) error
}

RPCErrFaker implements an RPC by wrapping one, but returns an error when prepared with one, to test RPC error handling.

func (RPCErrFaker) BatchCallContext

func (r RPCErrFaker) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

func (RPCErrFaker) CallContext

func (r RPCErrFaker) CallContext(ctx context.Context, result any, method string, args ...any) error

func (RPCErrFaker) Close

func (r RPCErrFaker) Close()

func (RPCErrFaker) Subscribe

func (r RPCErrFaker) Subscribe(ctx context.Context, namespace string, channel any, args ...any) (ethereum.Subscription, error)

type SimulatedEthClient

type SimulatedEthClient struct {
	simulated.Client
	// contains filtered or unexported fields
}

func NewSimulatedEthClient

func NewSimulatedEthClient(opts ...func(*SimulatedEthClientConfig)) *SimulatedEthClient

func (*SimulatedEthClient) Address

func (c *SimulatedEthClient) Address() common.Address

func (*SimulatedEthClient) Commit

func (c *SimulatedEthClient) Commit()

func (*SimulatedEthClient) EstimateGas

func (c *SimulatedEthClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

func (*SimulatedEthClient) PrivateKey

func (c *SimulatedEthClient) PrivateKey() string

func (*SimulatedEthClient) RPC

func (c *SimulatedEthClient) RPC() string

type SimulatedEthClientConfig

type SimulatedEthClientConfig struct {
	GenesisAccountsBalances map[common.Address]*big.Int
	BlockGasLimit           uint64
}

type TestDerivationMetrics

type TestDerivationMetrics struct {
	FnRecordL1ReorgDepth      func(d uint64)
	FnRecordL1Ref             func(name string, ref eth.L1BlockRef)
	FnRecordL2Ref             func(name string, ref eth.L2BlockRef)
	FnRecordUnsafePayloads    func(length uint64, memSize uint64, next eth.BlockID)
	FnRecordChannelInputBytes func(inputCompressedBytes int)
	FnRecordChannelTimedOut   func()
}

TestDerivationMetrics implements the metrics used in the derivation pipeline as no-op operations. Optionally a test may hook into the metrics

func (*TestDerivationMetrics) CountSequencedTxsInBlock

func (t *TestDerivationMetrics) CountSequencedTxsInBlock(txns int, deposits int)

func (*TestDerivationMetrics) RecordChannelInputBytes

func (t *TestDerivationMetrics) RecordChannelInputBytes(inputCompressedBytes int)

func (*TestDerivationMetrics) RecordChannelTimedOut

func (t *TestDerivationMetrics) RecordChannelTimedOut()

func (*TestDerivationMetrics) RecordDerivedBatches

func (n *TestDerivationMetrics) RecordDerivedBatches(batchType string)

func (*TestDerivationMetrics) RecordFrame

func (t *TestDerivationMetrics) RecordFrame()

func (*TestDerivationMetrics) RecordHeadChannelOpened

func (t *TestDerivationMetrics) RecordHeadChannelOpened()

func (*TestDerivationMetrics) RecordL1Ref

func (t *TestDerivationMetrics) RecordL1Ref(name string, ref eth.L1BlockRef)

func (*TestDerivationMetrics) RecordL1ReorgDepth

func (t *TestDerivationMetrics) RecordL1ReorgDepth(d uint64)

func (*TestDerivationMetrics) RecordL2Ref

func (t *TestDerivationMetrics) RecordL2Ref(name string, ref eth.L2BlockRef)

func (*TestDerivationMetrics) RecordPipelineReset

func (t *TestDerivationMetrics) RecordPipelineReset()

func (*TestDerivationMetrics) RecordSequencerBuildingDiffTime

func (t *TestDerivationMetrics) RecordSequencerBuildingDiffTime(duration time.Duration)

func (*TestDerivationMetrics) RecordSequencerSealingTime

func (t *TestDerivationMetrics) RecordSequencerSealingTime(duration time.Duration)

func (*TestDerivationMetrics) RecordUnsafePayloadsBuffer

func (t *TestDerivationMetrics) RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)

func (*TestDerivationMetrics) SetDerivationIdle

func (t *TestDerivationMetrics) SetDerivationIdle(idle bool)

type TestID

type TestID string

TestID represents an eth.BlockID as string, and can be shortened for convenience in test definitions.

Format: <hash-characters>:<number> where the <hash-characters> are copied over (i.e. not hex) and <number> is in decimal.

Examples: "foobar:123", or "B:2"

func (TestID) ID

func (id TestID) ID() eth.BlockID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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