810468a57f
* test_: create private group tests * test_: set privileged False for jenkins * test_: run baseline tests in rpc suite * test_: address review comments * test_: address review comments |
||
---|---|---|
.. | ||
clients | ||
resources | ||
schemas | ||
tests | ||
utils | ||
.pre-commit-config.yaml | ||
Dockerfile | ||
Dockerfile.tests-rpc | ||
README.MD | ||
config.json | ||
conftest.py | ||
docker-compose.anvil.dev.yml | ||
docker-compose.anvil.yml | ||
docker-compose.status-go.local.yml | ||
docker-compose.test.status-go.yml | ||
entrypoint.sh | ||
pytest.ini | ||
requirements.txt |
README.MD
Overview
Functional tests for status-go
Table of Contents
How to Install
- Install Docker and Docker Compose
- Install Python 3 (tested with 3.10 and 3.12 and it works with both)
- Set up a virtual environment (required for linting):
- In
./tests-functional
, run:python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt pre-commit install
- Important: The virtual environment must be created in the
./tests-functional
directory for pre-commit linting and type-checking tools like Pyright to work correctly. - Optional (for test development): Use Python virtual environment for better dependency management. You can follow the guide here
- In
How to Run
Running dev RPC (anvil with contracts)
- In
./tests-functional
rundocker compose -f docker-compose.anvil.yml up --remove-orphans --build
, as result:- an anvil container with ChainID 31337 exposed on
0.0.0.0:8545
will start running - Status-im contracts will be deployed to the network
- an anvil container with ChainID 31337 exposed on
Run tests
- In
./tests-functional
rundocker compose -f docker-compose.anvil.yml -f docker-compose.test.status-go.yml -f docker-compose.status-go.local.yml up --build --remove-orphans
, as result:- a container with status-backend will be created with endpoint exposed on
0.0.0.0:3333
- status-go will use anvil as RPCURL with ChainID 31337
- Status-im contracts will be deployed to the network
- a container with status-backend will be created with endpoint exposed on
- In
./tests-functional/tests
directory runpytest -m rpc
- To run tests against binary run
pytest -m <your mark> --url=http:<binary_url>:<binary_port> --user_dir=/<path>
Implementation details
- Functional tests are implemented in
./tests-functional/tests
based on pytest - Every test has two types of verifications:
verify_is_valid_json_rpc_response()
checks for status code 200, non-empty response, JSON-RPC structure, presence of theresult
field, and expected ID.jsonschema.validate()
is used to check that the response contains expected data, including required fields and types. Schemas are stored in/schemas/wallet_MethodName
- New schemas can be generated using
./tests-functional/utils/schema_builder.py
by passing a response to theCustomSchemaBuilder(schema_name).create_schema(response.json())
method, should be used only on test creation phase, please searchhow to create schema:
to see an example in a test
Known issues
Docker permission denied
When running tests with auto-creating status-backend containers, you might face this:
sock.connect(self.unix_socket)
PermissionError: [Errno 13] Permission denied
Please follow this fix: https://github.com/docker/compose/issues/10299#issuecomment-1438247730
If you're on MacOS and /var/run/docker.sock
doesn't exist, you need to create a symlink to the docker socket:
sudo ln -s $HOME/.docker/run/docker.sock /var/run/docker.sock