Open kodemartin opened 3 months ago
A hack to get the cli help for each supported task is try to run single task with <task> --help
. The test will fail with the usage output.
For example, create a file init.move
inside iota-graphql-e2e-tests/tests/
with
//# init --help
Running the test will fail, but will also produce
Usage: task init [OPTIONS]
Options:
--accounts <ACCOUNTS>...
--protocol-version <PROTOCOL_VERSION>
--max-gas <MAX_GAS>
--shared-object-deletion <SHARED_OBJECT_DELETION>
[possible values: true, false]
--simulator
--custom-validator-account
--reference-gas-price <REFERENCE_GAS_PRICE>
--default-gas-price <DEFAULT_GAS_PRICE>
--object-snapshot-min-checkpoint-lag <OBJECT_SNAPSHOT_MIN_CHECKPOINT_LAG>
--object-snapshot-max-checkpoint-lag <OBJECT_SNAPSHOT_MAX_CHECKPOINT_LAG>
--flavor <FLAVOR>
--addresses <NAMED_ADDRESSES>...
Description
Transactional tests simulate network operations through the framework exposed in iota-transactional-test-runner. The framework is actually built on top of the more generic move-transactional-test-runner.
This currently used in the following tests:
Syntax
The framework introduces an ad-hoc syntax for defining network related operations/tasks as an extension to
move/mvir
files. The syntax uses comments with the//#
prefix that bring about additional syntax rules for parsing additional arguments for the tasks. For example,Motivation
It seems that this syntax is not documented, and hence if one were to actually read or write new transactional tests, one should reverse engineer the syntax rules.
It will be thus helpful to identify and document the set of tasks that can be defined in transactional tests.
Get started
Parsing
Parsing takes place through the
taskify
function that accepts a genericCommand
type.https://github.com/iotaledger/iota/blob/e6f96d540956ca7c445051cd6cd455d37a8f0a92/external-crates/move/crates/move-transactional-test-runner/src/tasks.rs#L33
Generic commands
The generic
Command
type used is the following:https://github.com/iotaledger/iota/blob/e6f96d540956ca7c445051cd6cd455d37a8f0a92/external-crates/move/crates/move-transactional-test-runner/src/tasks.rs#L261-L273
This defines a set of main tasks:
init
run
publish
print-bytecode
and a general class of sub-commands
subcommand
that can be extended in implementors.Concrete implementation
print-bytecode
uses the following typehttps://github.com/iotaledger/iota/blob/e6f96d540956ca7c445051cd6cd455d37a8f0a92/external-crates/move/crates/move-transactional-test-runner/src/tasks.rs#L206-L212
For the rest of the tasks the parsing details are defined in
IotaTestAdapter
which implementsMoveTestAdapter
trait:https://github.com/iotaledger/iota/blob/e6f96d540956ca7c445051cd6cd455d37a8f0a92/crates/iota-transactional-test-runner/src/test_adapter.rs#L173-L178
The set of subcommands is defined through
https://github.com/iotaledger/iota/blob/e6f96d540956ca7c445051cd6cd455d37a8f0a92/crates/iota-transactional-test-runner/src/args.rs#L207-L223
Requirements
data
segment of the command block (see #1998).