Documentation ¶
Overview ¶
Package testutil contains mock deployers for interacting with the mock backend
Index ¶
- Constants
- Variables
- func EmitEvents(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend, ...) error
- func GetLogsUntilNoneLeft(ctx context.Context, testDB db.EventDB, filter db.LogFilter) ([]*types.Log, error)
- func GetReceiptsUntilNoneLeft(ctx context.Context, testDB db.EventDB, filter db.ReceiptFilter) ([]types.Receipt, error)
- func GetTxBlockNumber(ctx context.Context, chain backends.SimulatedTestBackend, ...) (uint64, error)
- func MakeRandomLog(txHash common.Hash) types.Log
- func NewTestContractDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func PopulateChainsWithLogs(ctx context.Context, t *testing.T, chainBackends map[uint32]geth.Backend, ...) (map[uint32]*TestChainHandler, map[uint32][]backend.ScribeBackend, error)
- func ReachBlockHeight(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend, ...) error
- func StartOmnirpcServer(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend) string
- type DeployManager
- type TestChainHandler
- type TestContractDeployer
Constants ¶
const ( // TestContractType is the type of the test contract. TestContractType contractTypeImpl = iota )
Variables ¶
var AllContractTypes []contractTypeImpl
AllContractTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.
Functions ¶
func EmitEvents ¶ added in v0.0.207
func EmitEvents(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend, desiredBlockHeight uint64, testChainHandler *TestChainHandler) error
EmitEvents emits events from the test contracts until the desired block height is reached.
func GetLogsUntilNoneLeft ¶ added in v0.0.207
func GetLogsUntilNoneLeft(ctx context.Context, testDB db.EventDB, filter db.LogFilter) ([]*types.Log, error)
GetLogsUntilNoneLeft gets all receipts from the database until there are none left (iterates page num).
func GetReceiptsUntilNoneLeft ¶ added in v0.0.207
func GetReceiptsUntilNoneLeft(ctx context.Context, testDB db.EventDB, filter db.ReceiptFilter) ([]types.Receipt, error)
GetReceiptsUntilNoneLeft gets all receipts from the database until there are none left (iterates page num).
func GetTxBlockNumber ¶ added in v0.0.207
func GetTxBlockNumber(ctx context.Context, chain backends.SimulatedTestBackend, tx *types.Transaction) (uint64, error)
GetTxBlockNumber gets the block number of a transaction.
func MakeRandomLog ¶ added in v0.0.207
MakeRandomLog makes a random log.
func NewTestContractDeployer ¶
func NewTestContractDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
NewTestContractDeployer creates a new test contract deployer.
func PopulateChainsWithLogs ¶ added in v0.0.207
func PopulateChainsWithLogs(ctx context.Context, t *testing.T, chainBackends map[uint32]geth.Backend, desiredBlockHeight uint64, managers []*DeployManager, handler metrics.Handler) (map[uint32]*TestChainHandler, map[uint32][]backend.ScribeBackend, error)
PopulateChainsWithLogs creates scribe backends for each chain backend and emits events from various contracts on each chain.
func ReachBlockHeight ¶ added in v0.0.207
func ReachBlockHeight(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend, desiredBlockHeight uint64) error
ReachBlockHeight reaches a block height on a backend.
func StartOmnirpcServer ¶ added in v0.0.207
func StartOmnirpcServer(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend) string
StartOmnirpcServer starts an omnirpc server and returns the url to it.
Types ¶
type DeployManager ¶
type DeployManager struct {
*manager.DeployerManager
}
DeployManager wraps DeployManager and allows typed contract handles to be returned.
func NewDeployManager ¶
func NewDeployManager(t *testing.T) *DeployManager
NewDeployManager creates a deploy manager.
func (*DeployManager) GetTestContract ¶
func (d *DeployManager) GetTestContract(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *testcontract.TestContractRef)
GetTestContract gets the test contract.
type TestChainHandler ¶ added in v0.0.207
type TestChainHandler struct { Addresses []common.Address ContractStartBlocks map[common.Address]uint64 ContractRefs map[common.Address]*testcontract.TestContractRef EventsEmitted map[common.Address]uint64 }
TestChainHandler is a handler for interacting with test contracts on a chain to aid in building extensive tests. It is returned when emitting events with the test contracts in the PopulateWithLogs function.
func PopulateWithLogs ¶ added in v0.0.207
func PopulateWithLogs(ctx context.Context, t *testing.T, backend backends.SimulatedTestBackend, desiredBlockHeight uint64, managers []*DeployManager) (*TestChainHandler, error)
PopulateWithLogs populates a backend with logs until it reaches a desired block height.
nolint:cyclop
type TestContractDeployer ¶
type TestContractDeployer struct {
*deployer.BaseDeployer
}
TestContractDeployer deploys a test contract.
func (TestContractDeployer) Deploy ¶
func (t TestContractDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
Deploy deploys the test contract.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testcontract contains a contract used for testing event and transaction emission.
|
Package testcontract contains a contract used for testing event and transaction emission. |