Documentation
¶
Index ¶
- func Identifier(chain *Chain, tx *types.Transaction, rcpt *types.Receipt) inbox.Identifier
- func SetBlockTimeForChainA(blockTime uint64) setupOption
- func SetBlockTimeForChainB(blockTime uint64) setupOption
- func WithActIncludeTx(includeTxAction helpers.Action) func(*AdvanceL1Opts)
- func WithIdentifier(ident inbox.Identifier) func(opts *ExecuteOpts)
- func WithL1BlockCrossUnsafe() func(*AddL2BlockOpts)
- func WithL2BlockTransactions(mkTxs ...TransactionCreator) func(*AddL2BlockOpts)
- func WithL2BlocksUntilTimestamp(timestamp uint64) func(*AddL2BlockOpts)
- func WithPayload(payload []byte) func(opts *ExecuteOpts)
- func WithPendingMessage(emitter *EmitterContract, chain *Chain, number uint64, logIndex int, ...) func(opts *ExecuteOpts)
- func WithSingleBatch() func(*AdvanceSafeHeadsOpts)
- func WithSkipCrossSafeUpdate() func(*SubmitBatchDataOpts)
- type AddL2BlockOpts
- type AdvanceL1Opts
- type AdvanceSafeHeadsOpts
- type Chain
- type ChainOpts
- type DSLUser
- type EmitterContract
- type ExecuteOpts
- type GeneratedTransaction
- func (m *GeneratedTransaction) CheckIncluded()
- func (m *GeneratedTransaction) CheckNotIncluded()
- func (m *GeneratedTransaction) Identifier() inbox.Identifier
- func (m *GeneratedTransaction) Include()
- func (m *GeneratedTransaction) IncludeDepositOK(l1User *DSLUser, depositTxOpts *bind.TransactOpts, l1Miner *helpers.L1Miner)
- func (m *GeneratedTransaction) IncludeOK()
- func (m *GeneratedTransaction) MessagePayload() []byte
- func (m *GeneratedTransaction) PendingIdentifier(chain *Chain, logIndex int) inbox.Identifier
- type InboxContract
- type InteropActors
- type InteropDSL
- func (d *InteropDSL) AddL2Block(chain *Chain, optionalArgs ...func(*AddL2BlockOpts))
- func (d *InteropDSL) AdvanceL1(optionalArgs ...func(*AdvanceL1Opts))
- func (d *InteropDSL) AdvanceL2ToLastBlockOfOrigin(chain *Chain, l1OriginHeight uint64)
- func (d *InteropDSL) AdvanceSafeHeads(optionalArgs ...func(*AdvanceSafeHeadsOpts))
- func (d *InteropDSL) CreateUser() *DSLUser
- func (d *InteropDSL) DepSet() *depset.StaticConfigDependencySet
- func (d *InteropDSL) DeployEmitterContracts() *EmitterContract
- func (d *InteropDSL) ProcessCrossSafe(optionalArgs ...func(*ProcessCrossSafeOpts))
- func (d *InteropDSL) SubmitBatchData(optionalArgs ...func(*SubmitBatchDataOpts))
- type InteropSetup
- type Message
- func (m *Message) ActEmitDeposit(l1User *DSLUser) helpers.Action
- func (m *Message) CheckEmitted()
- func (m *Message) CheckExecuted()
- func (m *Message) CheckNotEmitted()
- func (m *Message) CheckNotExecuted()
- func (m *Message) Emit() *Message
- func (m *Message) EmitDeposit(l1User *DSLUser) *Message
- func (m *Message) ExecuteIdentifier() inbox.Identifier
- func (m *Message) ExecuteOn(target *Chain, execOpts ...func(*ExecuteOpts)) *Message
- func (m *Message) ExecutePayload() []byte
- func (m *Message) ExecutePendingOn(target *Chain, pendingMessageBlockNumber uint64, ...) *Message
- type OutputRootSource
- type Outputs
- func (d *Outputs) OptimisticBlockAtTimestamp(chain *Chain, timestamp uint64) types.OptimisticBlock
- func (d *Outputs) OutputRootAtTimestamp(chain *Chain, timestamp uint64) *eth.OutputResponse
- func (d *Outputs) SuperRoot(timestamp uint64) eth.Super
- func (d *Outputs) TransitionState(timestamp uint64, step uint64, pendingProgress ...types.OptimisticBlock) *types.TransitionState
- type ProcessCrossSafeOpts
- type SubmitBatchDataOpts
- type SuperRootSource
- type SupervisorActor
- type TransactionCreator
- type TxIncluder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Identifier ¶
func Identifier(chain *Chain, tx *types.Transaction, rcpt *types.Receipt) inbox.Identifier
func SetBlockTimeForChainA ¶ added in v1.12.0
func SetBlockTimeForChainA(blockTime uint64) setupOption
func SetBlockTimeForChainB ¶ added in v1.12.0
func SetBlockTimeForChainB(blockTime uint64) setupOption
func WithActIncludeTx ¶
func WithActIncludeTx(includeTxAction helpers.Action) func(*AdvanceL1Opts)
func WithIdentifier ¶
func WithIdentifier(ident inbox.Identifier) func(opts *ExecuteOpts)
func WithL1BlockCrossUnsafe ¶
func WithL1BlockCrossUnsafe() func(*AddL2BlockOpts)
func WithL2BlockTransactions ¶
func WithL2BlockTransactions(mkTxs ...TransactionCreator) func(*AddL2BlockOpts)
func WithL2BlocksUntilTimestamp ¶
func WithL2BlocksUntilTimestamp(timestamp uint64) func(*AddL2BlockOpts)
func WithPayload ¶
func WithPayload(payload []byte) func(opts *ExecuteOpts)
func WithPendingMessage ¶
func WithPendingMessage(emitter *EmitterContract, chain *Chain, number uint64, logIndex int, msg string) func(opts *ExecuteOpts)
func WithSingleBatch ¶ added in v1.12.1
func WithSingleBatch() func(*AdvanceSafeHeadsOpts)
func WithSkipCrossSafeUpdate ¶
func WithSkipCrossSafeUpdate() func(*SubmitBatchDataOpts)
Types ¶
type AddL2BlockOpts ¶
type AddL2BlockOpts struct {
BlockIsNotCrossUnsafe bool
TransactionCreators []TransactionCreator
UntilTimestamp uint64
}
type AdvanceL1Opts ¶
type AdvanceSafeHeadsOpts ¶ added in v1.12.1
type AdvanceSafeHeadsOpts struct {
SingleBatch bool
}
type Chain ¶
type Chain struct {
ChainID eth.ChainID
RollupCfg *rollup.Config
L2Genesis *core.Genesis
BatcherAddr common.Address
Sequencer *helpers.L2Sequencer
SequencerEngine *helpers.L2Engine
Batcher *helpers.L2Batcher
}
Chain holds the most common per-chain action-test data and actors
type DSLUser ¶
type DSLUser struct {
// contains filtered or unexported fields
}
func (*DSLUser) TransactOpts ¶
type EmitterContract ¶
type EmitterContract struct {
EmittedMessages []*GeneratedTransaction
// contains filtered or unexported fields
}
func NewEmitterContract ¶
func NewEmitterContract(t helpers.Testing) *EmitterContract
func (*EmitterContract) Deploy ¶
func (c *EmitterContract) Deploy(user *DSLUser) TransactionCreator
func (*EmitterContract) EmitMessage ¶
func (c *EmitterContract) EmitMessage(user *DSLUser, message string) TransactionCreator
func (*EmitterContract) LastEmittedMessage ¶
func (c *EmitterContract) LastEmittedMessage() *GeneratedTransaction
type ExecuteOpts ¶
type ExecuteOpts struct {
Identifier *inbox.Identifier
Payload *[]byte
}
type GeneratedTransaction ¶
type GeneratedTransaction struct {
// contains filtered or unexported fields
}
func NewGeneratedTransaction ¶
func NewGeneratedTransaction(t helpers.Testing, chain *Chain, tx *types.Transaction, from common.Address) *GeneratedTransaction
func (*GeneratedTransaction) CheckIncluded ¶
func (m *GeneratedTransaction) CheckIncluded()
func (*GeneratedTransaction) CheckNotIncluded ¶
func (m *GeneratedTransaction) CheckNotIncluded()
func (*GeneratedTransaction) Identifier ¶
func (m *GeneratedTransaction) Identifier() inbox.Identifier
func (*GeneratedTransaction) Include ¶
func (m *GeneratedTransaction) Include()
func (*GeneratedTransaction) IncludeDepositOK ¶
func (m *GeneratedTransaction) IncludeDepositOK(l1User *DSLUser, depositTxOpts *bind.TransactOpts, l1Miner *helpers.L1Miner)
IncludeDepositOK includes the GeneratedTransaction via a user deposit transaction.
func (*GeneratedTransaction) IncludeOK ¶
func (m *GeneratedTransaction) IncludeOK()
func (*GeneratedTransaction) MessagePayload ¶
func (m *GeneratedTransaction) MessagePayload() []byte
func (*GeneratedTransaction) PendingIdentifier ¶
func (m *GeneratedTransaction) PendingIdentifier(chain *Chain, logIndex int) inbox.Identifier
type InboxContract ¶
type InboxContract struct {
Transactions []*GeneratedTransaction
// contains filtered or unexported fields
}
func NewInboxContract ¶
func NewInboxContract(t helpers.Testing) *InboxContract
func (*InboxContract) Execute ¶
func (i *InboxContract) Execute(user *DSLUser, initTx *GeneratedTransaction, args ...func(opts *ExecuteOpts)) TransactionCreator
func (*InboxContract) LastTransaction ¶
func (i *InboxContract) LastTransaction() *GeneratedTransaction
type InteropActors ¶
type InteropActors struct {
L1Miner *helpers.L1Miner
Supervisor *SupervisorActor
ChainA *Chain
ChainB *Chain
}
InteropActors holds a bundle of global actors and actors of 2 chains.
func (*InteropActors) PrepareChainState ¶
func (actors *InteropActors) PrepareChainState(t helpers.Testing)
type InteropDSL ¶
type InteropDSL struct {
Actors *InteropActors
Outputs *Outputs
InboxContract *InboxContract
// contains filtered or unexported fields
}
InteropDSL provides a high-level API to drive interop action tests so that the actual test reads more declaratively and is separated from the details of how each action is actually executed. DSL methods will typically:
- Check (and if needed, wait) for any required preconditions
- Perform the action, allowing components to fully process the effects of it
- Assert that the action completed. These are intended to be a sanity check to ensure tests fail fast if something doesn't work as expected. Options may be provided to perform more detailed or specific assertions
Optional inputs can be used to control lower level details of the operation. While it is also possible to directly access the Actors and low level actions, this should only be required when specifically testing low level details of that functionality. It is generally preferable to use optional inputs to the DSL methods to achieve the desired result rather than having to use the low level APIs directly.
Methods may also be provided specifically to verify some state. Methods may return some data from the system (e.g. OutputRootAtTimestamp) but it is generally preferred to provide an assertion method rather than a getter where that is viable. Assertion methods allow the DSL to provide more helpful information in failure messages and ensure the comparison is done correctly and consistently across tests rather than duplicating the assertion code in many tests.
Required inputs to methods are specified as normal parameters, so type checking enforces their presence. Optional inputs to methods are specified by a config struct and accept a vararg of functions that can update that struct. This is roughly inline with the typical opts pattern in Golang but with significantly reduced boilerplate code since so many methods wil define their own config. With* methods are only provided for the most common optional args and tests will normally supply a custom function that sets all the optional values they need at once. Common options can be extracted to a reusable struct (e.g. ChainOpts above) which may expose helper methods to aid test readability and reduce boilerplate.
func NewInteropDSL ¶
func NewInteropDSL(t helpers.Testing, opts ...setupOption) *InteropDSL
func (*InteropDSL) AddL2Block ¶
func (d *InteropDSL) AddL2Block(chain *Chain, optionalArgs ...func(*AddL2BlockOpts))
AddL2Block adds a new unsafe block to the specified chain and fully processes it in the supervisor
func (*InteropDSL) AdvanceL1 ¶
func (d *InteropDSL) AdvanceL1(optionalArgs ...func(*AdvanceL1Opts))
AdvanceL1 adds a new L1 block with the specified transactions and ensures it is processed by the specified chains and the supervisor.
func (*InteropDSL) AdvanceL2ToLastBlockOfOrigin ¶
func (d *InteropDSL) AdvanceL2ToLastBlockOfOrigin(chain *Chain, l1OriginHeight uint64)
AdvanceL2ToLastBlockOfOrigin advances the chain to the last block of the epoch at the specified L1 origin.
func (*InteropDSL) AdvanceSafeHeads ¶ added in v1.12.1
func (d *InteropDSL) AdvanceSafeHeads(optionalArgs ...func(*AdvanceSafeHeadsOpts))
AdvanceSafeHeads advances the safe heads for all chains by adding a new L2 block and submitting batch data for each chain. By default, submits batch data for each chain in separate L1 blocks.
func (*InteropDSL) CreateUser ¶
func (d *InteropDSL) CreateUser() *DSLUser
func (*InteropDSL) DepSet ¶
func (d *InteropDSL) DepSet() *depset.StaticConfigDependencySet
func (*InteropDSL) DeployEmitterContracts ¶
func (d *InteropDSL) DeployEmitterContracts() *EmitterContract
DeployEmitterContracts deploys an emitter contract on both chains
func (*InteropDSL) ProcessCrossSafe ¶
func (d *InteropDSL) ProcessCrossSafe(optionalArgs ...func(*ProcessCrossSafeOpts))
ProcessCrossSafe processes evens in the supervisor and nodes to ensure the cross-safe head is fully updated.
func (*InteropDSL) SubmitBatchData ¶
func (d *InteropDSL) SubmitBatchData(optionalArgs ...func(*SubmitBatchDataOpts))
SubmitBatchData submits batch data to L1 and processes the new L1 blocks, advancing the safe heads. By default, submits all batch data for all chains.
type InteropSetup ¶
type InteropSetup struct {
Log log.Logger
Deployment *interopgen.WorldDeployment
Out *interopgen.WorldOutput
DepSet *depset.StaticConfigDependencySet
Keys devkeys.Keys
T helpers.Testing
}
InteropSetup holds the chain deployment and config contents, before instantiating any services.
func SetupInterop ¶
func SetupInterop(t helpers.Testing, opts ...setupOption) *InteropSetup
SetupInterop creates an InteropSetup to instantiate actors on, with 2 L2 chains.
func (*InteropSetup) CreateActors ¶
func (is *InteropSetup) CreateActors() *InteropActors
type Message ¶ added in v1.12.1
type Message struct {
// contains filtered or unexported fields
}
func NewMessage ¶ added in v1.12.1
func NewMessage(dsl *InteropDSL, chain *Chain, emitter *EmitterContract, message string) *Message
func (*Message) ActEmitDeposit ¶ added in v1.12.2
ActEmitDeposit returns an action that emits a message via a user deposit transaction.
func (*Message) CheckEmitted ¶ added in v1.12.1
func (m *Message) CheckEmitted()
func (*Message) CheckExecuted ¶ added in v1.12.1
func (m *Message) CheckExecuted()
func (*Message) CheckNotEmitted ¶ added in v1.12.1
func (m *Message) CheckNotEmitted()
func (*Message) CheckNotExecuted ¶ added in v1.12.1
func (m *Message) CheckNotExecuted()
func (*Message) EmitDeposit ¶ added in v1.12.2
EmitDeposit emits a message via a user deposit transaction.
func (*Message) ExecuteIdentifier ¶ added in v1.12.1
func (m *Message) ExecuteIdentifier() inbox.Identifier
func (*Message) ExecuteOn ¶ added in v1.12.1
func (m *Message) ExecuteOn(target *Chain, execOpts ...func(*ExecuteOpts)) *Message
func (*Message) ExecutePayload ¶ added in v1.12.1
func (*Message) ExecutePendingOn ¶ added in v1.12.2
func (m *Message) ExecutePendingOn(target *Chain, pendingMessageBlockNumber uint64, execOpts ...func(*ExecuteOpts)) *Message
ExecutePendingOn executes a message that may not have been emitted yet.
type OutputRootSource ¶
type Outputs ¶
type Outputs struct {
// contains filtered or unexported fields
}
func (*Outputs) OptimisticBlockAtTimestamp ¶
func (d *Outputs) OptimisticBlockAtTimestamp(chain *Chain, timestamp uint64) types.OptimisticBlock
func (*Outputs) OutputRootAtTimestamp ¶
func (d *Outputs) OutputRootAtTimestamp(chain *Chain, timestamp uint64) *eth.OutputResponse
func (*Outputs) TransitionState ¶
func (d *Outputs) TransitionState(timestamp uint64, step uint64, pendingProgress ...types.OptimisticBlock) *types.TransitionState
type ProcessCrossSafeOpts ¶
type ProcessCrossSafeOpts struct {
ChainOpts
}
type SubmitBatchDataOpts ¶
type SuperRootSource ¶
type SuperRootSource struct {
// contains filtered or unexported fields
}
SuperRootSource is a testing helper to create a Super Root from a set of rollup clients
func NewSuperRootSource ¶
func NewSuperRootSource(ctx context.Context, sources ...OutputRootSource) (*SuperRootSource, error)
func (*SuperRootSource) CreateSuperRoot ¶
type SupervisorActor ¶
type SupervisorActor struct {
sources.SupervisorClient
// contains filtered or unexported fields
}
SupervisorActor represents a supervisor, instrumented to run synchronously for action-test purposes.
func NewSupervisor ¶
func NewSupervisor(t helpers.Testing, logger log.Logger, depSet depset.DependencySetSource) *SupervisorActor
NewSupervisor creates a new SupervisorActor, to action-test the supervisor with.
func (*SupervisorActor) ProcessFull ¶
func (sa *SupervisorActor) ProcessFull(t helpers.Testing)
func (*SupervisorActor) SignalFinalizedL1 ¶
func (sa *SupervisorActor) SignalFinalizedL1(t helpers.Testing)
func (*SupervisorActor) SignalLatestL1 ¶
func (sa *SupervisorActor) SignalLatestL1(t helpers.Testing)
type TransactionCreator ¶
type TransactionCreator func(chain *Chain) *GeneratedTransaction