testutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakeGenesis

func FakeGenesis(l1 rune, l2 rune, l1GenesisNumber int) 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 MakeL1Info added in v0.3.0

func MakeL1Info(fn func(l *MockL1Info)) func(rng *rand.Rand) *MockL1Info

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 RandomAddress

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

func RandomBlockID

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

func RandomBlockRef

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

func RandomData

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

func RandomETH

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

func RandomHash

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

func RandomKey

func RandomKey() *ecdsa.PrivateKey

func RandomL2BlockRef

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

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) L1BlockRefByNumber

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

func (*FakeChainSource) L1Head

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

func (*FakeChainSource) L1HeadBlockRef added in v0.3.0

func (m *FakeChainSource) L1HeadBlockRef(ctx context.Context) (eth.L1BlockRef, error)

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) L2BlockRefByNumber

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

func (*FakeChainSource) L2BlockRefHead added in v0.3.0

func (m *FakeChainSource) L2BlockRefHead(ctx context.Context) (eth.L2BlockRef, error)

func (*FakeChainSource) ReorgL1

func (m *FakeChainSource) ReorgL1()

func (*FakeChainSource) SetL2Head

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

type MockEngine

type MockEngine struct {
	mock.Mock
}

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.ExecutionPayload, err error)

func (*MockEngine) ExpectL2BlockRefByHash added in v0.3.0

func (m *MockEngine) ExpectL2BlockRefByHash(l2Hash common.Hash, ref eth.L1BlockRef, err error)

func (*MockEngine) ExpectL2BlockRefHead added in v0.3.0

func (m *MockEngine) ExpectL2BlockRefHead(ref eth.L1BlockRef, err error)

func (*MockEngine) ExpectNewPayload

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

func (*MockEngine) ExpectPayloadByHash added in v0.3.0

func (m *MockEngine) ExpectPayloadByHash(hash common.Hash, payload *eth.ExecutionPayload, err error)

func (*MockEngine) ExpectPayloadByNumber added in v0.3.0

func (m *MockEngine) ExpectPayloadByNumber(hash common.Hash, payload *eth.ExecutionPayload, 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, payloadId eth.PayloadID) (*eth.ExecutionPayload, error)

func (*MockEngine) L2BlockRefByHash added in v0.3.0

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

func (*MockEngine) L2BlockRefHead added in v0.3.0

func (m *MockEngine) L2BlockRefHead(ctx context.Context) (eth.L2BlockRef, error)

func (*MockEngine) NewPayload

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

func (*MockEngine) PayloadByHash added in v0.3.0

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

func (*MockEngine) PayloadByNumber added in v0.3.0

func (m *MockEngine) PayloadByNumber(ctx context.Context, n uint64) (*eth.ExecutionPayload, error)

type MockL1Info added in v0.3.0

type MockL1Info struct {
	InfoHash           common.Hash
	InfoParentHash     common.Hash
	InfoRoot           common.Hash
	InfoNum            uint64
	InfoTime           uint64
	InfoMixDigest      [32]byte
	InfoBaseFee        *big.Int
	InfoReceiptRoot    common.Hash
	InfoSequenceNumber uint64
}

func RandomL1Info added in v0.3.0

func RandomL1Info(rng *rand.Rand) *MockL1Info

func (*MockL1Info) BaseFee added in v0.3.0

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

func (*MockL1Info) BlockRef added in v0.3.0

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

func (*MockL1Info) Hash added in v0.3.0

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

func (*MockL1Info) ID added in v0.3.0

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

func (*MockL1Info) MixDigest added in v0.3.0

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

func (*MockL1Info) NumberU64 added in v0.3.0

func (l *MockL1Info) NumberU64() uint64

func (*MockL1Info) ParentHash added in v0.3.0

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

func (*MockL1Info) ReceiptHash added in v0.3.0

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

func (*MockL1Info) Root added in v0.3.0

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

func (*MockL1Info) SequenceNumber added in v0.3.0

func (l *MockL1Info) SequenceNumber() uint64

func (*MockL1Info) Time added in v0.3.0

func (l *MockL1Info) Time() uint64

type MockL1Source

type MockL1Source struct {
	mock.Mock
}

func (*MockL1Source) ExpectFetch added in v0.3.0

func (m *MockL1Source) ExpectFetch(hash common.Hash, info eth.L1Info, transactions types.Transactions, receipts types.Receipts, err error)

func (*MockL1Source) ExpectInfoAndTxsByHash added in v0.3.0

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

func (*MockL1Source) ExpectInfoByHash added in v0.4.0

func (m *MockL1Source) ExpectInfoByHash(hash common.Hash, info eth.L1Info, err error)

func (*MockL1Source) ExpectL1BlockRefByHash

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

func (*MockL1Source) ExpectL1BlockRefByNumber

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

func (*MockL1Source) Fetch added in v0.3.0

func (*MockL1Source) InfoAndTxsByHash added in v0.3.0

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

func (*MockL1Source) InfoByHash added in v0.4.0

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

func (*MockL1Source) L1BlockRefByHash

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

func (*MockL1Source) L1BlockRefByNumber

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

func (*MockL1Source) L1HeadBlockRef added in v0.4.0

func (m *MockL1Source) L1HeadBlockRef(ctx context.Context) (eth.L1BlockRef, error)

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

Jump to

Keyboard shortcuts

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