Documentation ¶
Index ¶
Constants ¶
const IDEFlag = "IDE"
IDEFlag is used as an environnment variable to allow tests to run that are designed not to run in CI todo (@matt) - come up with a better method, perhaps using directory-based ignore/include mechanism for `ci` dir only
const (
LogFileKey contextKey = 0
)
Variables ¶
This section is empty.
Functions ¶
func EnsureTestLogsSetUp ¶
EnsureTestLogsSetUp calls Setup if it hasn't already been called (some tests run tests within themselves, we don't want the log folder flipping around for every subtest, so we assume this is called for the top level test that is running and ignore subsequent calls
func NodeHealthCheck ¶
func Run ¶
func Run(testName string, t *testing.T, env Environment, action Action)
Run provides a standardised way to run tests and provides a single place for changing logging/output styles, etc.
The tests in `/tests` should typically only contain a single line, executing this method. The Environment and NetworkTest implementations and how they're configured define the test to be run.
Example usage:
networktest.Run(t, env.DevTestnet(), tests.smokeTest()) networktest.Run(t, env.LocalDevNetwork(WithNumValidators(8)), traffic.RunnerTest(traffic.NativeFundsTransfers(), 30*time.Second)
func TestOnlyRunsInIDE ¶
Types ¶
type Action ¶
type Action interface { Run(ctx context.Context, network NetworkConnector) (context.Context, error) Verify(ctx context.Context, network NetworkConnector) error }
Action is any step in a test, they will typically be either minimally small steps in the test or they will be containers that coordinate the running of multiple sub-actions (e.g. SeriesAction/ParallelAction)
With these action containers a tree of actions is built to form a test.
A test will call Run on an action (triggering the run of the tree of subactions), and then Verify (orchestrating the verification step on all sub actions)
Conventions:
- if an action name begins with `Verify` then its `Run` method will be a no-op, these should be at the end of a test run (since they only test the post-test state)
type Environment ¶
type Environment interface {
Prepare() (NetworkConnector, func(), error)
}
Environment abstraction allows the test runner to prepare the network connector with optional config and steps and to handle the clean-up so that different types of NetworkConnector can be configured in the same style (see runner.go) (local network requires setup and teardown for example, whereas a connector to a Testnet is ready to go)
type NetworkConnector ¶
type NetworkConnector interface { ChainID() int64 // AllocateFaucetFunds uses the networks default faucet mechanism for allocating funds to a test account AllocateFaucetFunds(ctx context.Context, account common.Address) error SequencerRPCAddress() string ValidatorRPCAddress(idx int) string NumValidators() int GetSequencerNode() NodeOperator GetValidatorNode(idx int) NodeOperator GetL1Client() (ethadapter.EthClient, error) }
NetworkConnector represents the network being tested against, e.g. testnet, dev-testnet, dev-sim
It provides network details (standard contract addresses) and easy client setup for sim users
type NodeOperator ¶
type NodeOperator interface { Start() error Stop() error StartEnclave() error StopEnclave() error StartHost() error StopHost() error HostRPCAddress() string }
NodeOperator is used by the DevNetwork for orchestrating different scenarios
It attempts to encapsulate the data, monitoring and possible actions that would be available to a real NodeOperator in a live permissionless Obscuro network