Integration tests can be run against a running localnet. They are also run automatically from a Circle CI job called integration
when a branch lands to the commands
repo master branch. The Circle CI job can also be run using tagged builds from a branch. Details on how to do that can be found inside the ./circle/config.yml
file in the commands
repo.
- Install python3.6 or later
- Install
pipenv
:pip3 install pipenv
- Install
pytest
:pip3 install pytest
- Install
toml
:pip3 install toml
- Install
msgpack
:pip3 install msgpack
- Make sure you have your
NDAUHOME
environment variable set. e.g. when running against localnet, you could useexport NDAUHOME=$HOME/.localnet/data/ndau-0
- Clone this repo into
~/go/src/github.com/ndau
so that it is next to thendau
repo cd
into the repo root- Install dependencies:
pipenv sync
- Load the environment:
pipenv shell
Tests are handled via the pytest
unit-testing tool. To run the entire test suite, simply execute the pytest -v
command from the repo root; it'll take care of everything else. If you'd like the testing to stop at failure X, run the command pytest -v --maxfail=X
. If you'd like to run a particular test, run the command pytest test_mod.py::test_func
. There are several command-line flags available:
--runslow
if set runs tests which have been marked as slow. None of these tests are particularly speedy due to the heavy fixtures in play, but some are particularly poky.--skipmeta
if set skips metatests. Metatests are tests which verify that the fixtures in use to fetch and build the various dependencies are all working properly.--keeptemp
if set keeps temp files and directories around to help debug test failures. Normally all files and directories created during testing will be removed at the end of the tests. Temporary files will normally be named in the form of /tmp/XXXXXX_YYYYYYYY, where X's are the tool or component name, and Y's are a randomly generated string.--ip
set to the IP of thelocalnet-0
node. If omitted, it defaults tolocalhost
. This is used by the integration tests to send requests to the network. Only one node is needed for integration tests to run against.
Tests are written in Python using pytest and hypothesis.
There is no support for running integration tests against non-local networks.
Rationale:
- We can be sure to start with the latest "generated" genesis snapshot automatically
- We don't rely on any pre-built snapshot hosted on S3
- Tests can be written to rely on a known initial state
- Tests don't have to worry about being compatible with "whatever's on devnet" when they run
- On localnet, this is achieved by running
bin/reset.sh
from thecommands
repo - On Circle CI, the
integration
job starts the test nodes with a fresh genesis snapshot
- It avoids inflating ndau issuance beyond realistic values
- Anyone testing the wallet against devnet won't be affected
- The integration tests can be run from Circle CI before we push and deploy a build to devnet
- If the tests fail, the push and deploy are skipped