Documentation
¶
Index ¶
- Constants
- type IOshaModule
- type Service
- type Snapshot
- type TestManager
- func (m *TestManager) AdvanceSlots(slots uint, includeBlocks bool) error
- func (m *TestManager) Close() error
- func (m *TestManager) CommitBlock() error
- func (m *TestManager) CreateSnapshot() (string, error)
- func (m *TestManager) DependsOn(dependency func(*testing.T), snapshotName *string, t *testing.T) error
- func (m *TestManager) GetBeaconClient() beacon.IBeaconClient
- func (m *TestManager) GetBeaconMockManager() *manager.BeaconMockManager
- func (m *TestManager) GetDockerMockManager() *docker.DockerMockManager
- func (m *TestManager) GetExecutionClient() eth.IExecutionClient
- func (m *TestManager) GetHardhatRpcClient() *rpc.Client
- func (m *TestManager) GetLogger() *slog.Logger
- func (m *TestManager) GetRegisteredModules() []IOshaModule
- func (m *TestManager) GetTestDir() string
- func (m *TestManager) RegisterModule(module IOshaModule)
- func (m *TestManager) RevertSnapshot(snapshotName string) error
- func (m *TestManager) RevertToBaseline() error
- func (m *TestManager) SetBeaconHeadSlot(slot uint64)
- func (m *TestManager) SetMiningInterval(interval uint) error
- func (m *TestManager) ToggleAutoMine(enabled bool) error
Constants ¶
const ( // The environment variable for the locally running Hardhat instance HardhatEnvVar string = "HARDHAT_URL" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IOshaModule ¶ added in v0.4.0
type IOshaModule interface { GetModuleName() string CloseModule() error TakeModuleSnapshot() (any, error) RevertModuleToSnapshot(moduleState any) error }
Interface representing individual module snapshots that compose an entire Snapshot
type Service ¶ added in v0.2.0
type Service int
Service represents a service provided by OSHA
const ( // Represents the Execution client and Beacon node services Service_EthClients Service = 1 << iota // Represents the Docker client and compose services Service_Docker // Represents the underlying filesystem Service_Filesystem // Represents all of the services provided by OSHA Service_All Service = Service_EthClients | Service_Docker | Service_Filesystem )
type Snapshot ¶ added in v0.4.0
type Snapshot struct {
// contains filtered or unexported fields
}
Struct representing an entire snapshot for a given test case
type TestManager ¶
type TestManager struct {
// contains filtered or unexported fields
}
TestManager provides bootstrapping and a test service provider, useful for testing
func NewTestManager ¶
func NewTestManager() (*TestManager, error)
Creates a new TestManager instance
func (*TestManager) AdvanceSlots ¶
func (m *TestManager) AdvanceSlots(slots uint, includeBlocks bool) error
Advances the chain by a number of slots. If includeBlocks is true, an EL block will be mined for each slot and the slot will reference that block. If includeBlocks is false, each slot (until the last one) will be "missed", so no EL block will be mined for it.
func (*TestManager) Close ¶ added in v0.2.0
func (m *TestManager) Close() error
Cleans up the test environment, including the testing folder that houses any generated files
func (*TestManager) CommitBlock ¶
func (m *TestManager) CommitBlock() error
Commits a new block in the EC and BN, advancing the chain
func (*TestManager) CreateSnapshot ¶ added in v0.4.0
func (m *TestManager) CreateSnapshot() (string, error)
Takes a snapshot of the service states
func (*TestManager) DependsOn ¶ added in v0.4.0
func (m *TestManager) DependsOn(dependency func(*testing.T), snapshotName *string, t *testing.T) error
Manages test dependencies for running individual unit tests when previous snapshots are not available
func (*TestManager) GetBeaconClient ¶
func (m *TestManager) GetBeaconClient() beacon.IBeaconClient
func (*TestManager) GetBeaconMockManager ¶
func (m *TestManager) GetBeaconMockManager() *manager.BeaconMockManager
func (*TestManager) GetDockerMockManager ¶ added in v0.2.0
func (m *TestManager) GetDockerMockManager() *docker.DockerMockManager
func (*TestManager) GetExecutionClient ¶
func (m *TestManager) GetExecutionClient() eth.IExecutionClient
func (*TestManager) GetHardhatRpcClient ¶
func (m *TestManager) GetHardhatRpcClient() *rpc.Client
func (*TestManager) GetLogger ¶
func (m *TestManager) GetLogger() *slog.Logger
func (*TestManager) GetRegisteredModules ¶ added in v0.4.0
func (m *TestManager) GetRegisteredModules() []IOshaModule
Returns a list of registered modules
func (*TestManager) GetTestDir ¶
func (m *TestManager) GetTestDir() string
Get the path of the test directory - use this to store whatever files you need for testing.
func (*TestManager) RegisterModule ¶ added in v0.4.0
func (m *TestManager) RegisterModule(module IOshaModule)
If a user registers a module with an existing name, it will be overwritten
func (*TestManager) RevertSnapshot ¶ added in v0.4.0
func (m *TestManager) RevertSnapshot(snapshotName string) error
func (*TestManager) RevertToBaseline ¶
func (m *TestManager) RevertToBaseline() error
Reverts the services to the baseline snapshot
func (*TestManager) SetBeaconHeadSlot ¶
func (m *TestManager) SetBeaconHeadSlot(slot uint64)
Set the highest slot (the head slot) of the Beacon chain, while keeping the local chain head on the client the same. Useful for simulating an unsynced client.
func (*TestManager) SetMiningInterval ¶ added in v0.3.0
func (m *TestManager) SetMiningInterval(interval uint) error
Set the interval for interval mining mode
func (*TestManager) ToggleAutoMine ¶ added in v0.3.0
func (m *TestManager) ToggleAutoMine(enabled bool) error
Toggle automining where each TX will automatically be mine into its own block