crates/aptos/e2e/README.md
This directory contains Python code to help with running the CLI test suite.
We use Poetry for packaging and dependency management:
curl -sSL https://install.python-poetry.org | python3 -
Once you have Poetry, you can install the dependencies for the testing framework like this:
poetry config virtualenvs.in-project true # This helps with IDE integration
poetry install
To learn how to use the CLI testing framework, run this:
poetry run python main.py -h
For example, using the CLI from an image:
poetry run python main.py --base-network mainnet --test-cli-tag nightly
Using the CLI from a local path:
poetry run python main.py -d --base-network mainnet --test-cli-path ~/aptos-core/target/debug/aptos
If you are get an error message similar to this:
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
Try running the poetry command with this env var:
DOCKER_DEFAULT_PLATFORM=linux/amd64 poetry run python main.py --base-network testnet --test-cli-path ~/aptos-core/target/debug/aptos
This makes the docker commands use the x86_64 images since we don't publish images for ARM.
If you see an error like this:
Traceback (most recent call last):
File "/Users/dport/a/core/crates/aptos/e2e/main.py", line 194, in <module>
if main():
File "/Users/dport/a/core/crates/aptos/e2e/main.py", line 156, in main
run_helper.prepare()
File "/Users/dport/a/core/crates/aptos/e2e/test_helpers.py", line 155, in prepare
self.prepare_cli()
File "/Users/dport/a/core/crates/aptos/e2e/test_helpers.py", line 189, in prepare_cli
raise RuntimeError(
RuntimeError: When using --test-cli-path you must use workspace configuration, try running `aptos config set-global-config --config-type workspace`
It is because you are using the --test-cli-path flag but have configured the CLI to use the global config type. This is not currently compatible, you must switch the config type to workspace prior to running the E2E tests:
aptos config set-global-config --config-type workspace
You might be getting output like this:
2023-06-22 20:27:07,533 - ERROR - These tests failed:
2023-06-22 20:27:07,533 - ERROR - test_move_compile_script ...
The best place to look is the test framework working directory, by default /tmp/aptos-cli-tests.
In this directory you will find lots of useful output. For example, you can see the stdout of one of the commands in a test case like this:
$ cat /tmp/aptos-cli-tests/out/007_test_move_compile_script.stdout
{
"Error": "Move compilation failed: Unable to resolve packages for package 'TwoByTwoTransfer': While resolving dependency 'AptosFramework' in package 'TwoByTwoTransfer': While processing dependency 'AptosFramework': Unable to find package manifest for 'AptosFramework' at \"Move.toml/move/scripts/two_by_two_transfer/../../../framework/aptos-framework\""
}
For each test there are the following files:
This file might also be present if the test threw an exception:
To write a new test case, follow these steps:
test_*.test_case decorator.RunHelper to invoke CLI commands. Follow the example of other test cases.run_tests function in main.py. Note that the order matters here, later tests are allowed (and encouraged) to depend on the results of earlier tests. This way we can test truly end-to-end, beyond the span of a single invocation.poetry run isort .
poetry run black .