Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v5
# see more at
# https://docs.astral.sh/uv/guides/integration/github/
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
cache: "poetry"
cache-dependency-path: "./poetry.lock"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Prepare environment
run: poetry install --no-root
run: uv sync --all-extras --dev

- name: Run black formatting
run: poetry run poe format --check --verbose
run: uv run black --check --verbose ./tests

- name: Run pylint linter
run: poetry run poe lint --verbose
run: uv run pylint --verbose ./tests

- name: Cache Rust
uses: Swatinem/rust-cache@v2
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ config.toml
# IDE configurations
.idea/
.vscode/

# uv python management
.venv

# tests pycache
tests/**/__pycache__/*
71 changes: 50 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,53 +258,82 @@ cargo test --release

Additional functional tests are available (minimum python version: 3.12).

* Install [poetry dependencies manager](https://python-poetry.org/docs/#installation). There are many ways to do this:
* Recommended: install [uv: a rust-based python package and project manager](https://docs.astral.sh/uv/).

* Configure an isolated environment:

```bash
# recomended way
pipx install poetry
# create a virtual environment
# (it's good to not mess up with your os)
uv venv

# Alternatively, you can specify a python version (e.g, 3.12),
uv venv --python 3.12

# activate the python virtual environment
source .venv/bin/activate

# check if the python path was modified
which python
```

* Install module dependencies:

```bash
# official installer (linux / mac)
curl -sSL https://install.python-poetry.org | python3 -
```
# installs dependencies listed in pyproject.toml.
# in local development environment
# it do not remove existing packages.
uv pip install -r pyproject.toml

# if you're a old-school pythonist,
# install from requirements.txt
# without remove existing packages.
uv pip install -r tests/requirements.txt

```pwsh
# official isntaller (windows - powershell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
# Alternatively, you can synchronize it
# uses the uv.lock file to enforce
# reproducible installations.
uv sync
```

* Format code
```bash
# mannually
python3 -m venv $VENV_PATH
$VENV_PATH/bin/pip install -U pip setuptools
$VENV_PATH/bin/pip install poetry
uv run black ./tests

# if you want to just check
uv run black --check --verbose ./tests
```

* Configure an isolated environment and install module dependencies:

* Lint code
```bash
poetry install --no-root
uv run pylint ./tests
```

* Run tests:

Our tests are separated by "test suites". Suites are folders located in `./tests/<suite>` and the tests are the `./tests/<suite>/*-test.py` files. To run all suites, type:

```bash
uv run tests/run_tests.py
```

You can list all suites with:

```bash
poetry run poe tests
uv run tests/run_tests.py --list-suites
```

* Before run tests, check the pre-commit:
To run a specific suite:

```bash
poetry run poe pre-commit
uv run tests/run_tests.py --test-suite <suite>
```

* Manual way without poetry: install dependencies and run the test script. This is discouraged since that can lead to inconsistences between different python versions:
You can even add more:

```bash
pip3 install -r tests/requirements.txt
python tests/run_tests.py
uv run tests/run_tests.py --test-suite <suite_A> --test-suite <suite_B>
```

## Running Benchmarks
Expand Down
489 changes: 0 additions & 489 deletions poetry.lock

This file was deleted.

79 changes: 16 additions & 63 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,67 +1,20 @@
# With this the user can use a custom
# python environment, like those created
# with venv or pyenv. The default will be
# the system python.
[virtualenvs]
prefer-active-python = true

# This isn't really needed on pratical aspect
# since this is only for organize the functional tests
# but is necessary since its a requirement for poetry.
[tool.poetry]
[project]
name = "floresta-functional-tests"
version = "0.0.1"
description = "collection of tools to help with functional testing of Floresta"
authors = ["The Floresta Project Developers"]
license = "MIT"

# To add a new dependency, use `poetry add <package>`.
# To update, first find outdated packages with `poetry show --outdated`,
# then re-install with `poetry add <package>@<version>`.
[tool.poetry.dependencies]
python = ">=3.12"
jsonrpclib = "^0.2.1"
requests = "^2.32.3"
black = "^24.10.0"
pylint = "^3.3.2"
poethepoet = "^0.31.1"

# Here we can define some custom tasks
# (even bash or rust ones can be defined).
# All of them will run on virtualenv environment.
# For more information, see guidelines in https://poethepoet.natn.io
[tool.poe.tasks]
format = "black ./tests"
lint = "pylint ./tests"
example-test = "python tests/run_tests.py --test-name example_test"
restart-test = "python tests/run_tests.py --test-name restart"
florestacli-getblockchaininfo-test = "python tests/run_tests.py --test-name floresta_cli_getblockchaininfo"
florestacli-getblockhash-test = "python tests/run_tests.py --test-name floresta_cli_getblockhash"
florestacli-getblockheader-test = "python tests/run_tests.py --test-name floresta_cli_getblockheader"
florestacli-getblock-test = "python tests/run_tests.py --test-name floresta_cli_getblock"
florestacli-getpeerinfo-test = "python tests/run_tests.py --test-name floresta_cli_getpeerinfo"
florestacli-addnode-test = "python tests/run_tests.py --test-name floresta_cli_addnode"
florestacli-stop-test = "python tests/run_tests.py --test-name floresta_cli_stop"
florestacli-getroots-test = "python tests/run_tests.py --test-name floresta_cli_getroots"
florestacli-getrpcinfo-test = "python tests/run_tests.py --test-name floresta_cli_getrpcinfo"
florestacli-getmemoryinfo-test = "python tests/run_tests.py --test-name floresta_cli_getmemoryinfo"
florestacli-uptime-test = "python tests/run_tests.py --test-name floresta_cli_uptime"
tests = [
"restart-test",
"florestacli-getblockchaininfo-test",
"florestacli-getblockhash-test",
"florestacli-getblockheader-test",
"florestacli-getblock-test",
"florestacli-getpeerinfo-test",
"florestacli-addnode-test",
"florestacli-stop-test",
"florestacli-getroots-test",
"florestacli-getrpcinfo-test",
"florestacli-getmemoryinfo-test",
"florestacli-uptime-test"
version = "0.0.2"
description = "Collection of tools to help with functional testing of Floresta"
authors = [{name = "The Floresta Project Developers"}]
license = {text = "MIT"}
requires-python = ">=3.12"
dependencies = [
"jsonrpclib>=0.2.1",
"requests>=2.32.3",
"black>=24.10.0",
"pylint>=3.3.2",
]
pre-commit = ["format", "lint", "tests"]

[tool.hatch.build.targets.wheel]
packages = ["tests/test_framework"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
Empty file added tests/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions tests/example_test.py → tests/example/example-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
Any attempt to define a test without these methods will raise a TypeError.

Other methods are available to do more things. Some of them make sense only in `set_test_params`
and others make sense only in `run_tests`.
and others make sense only in `run_tests`.

- `add_node_settings`: register a node settings to create a node after. A node will be a spawned
`cargo run --features json-rpc --bin florestad -- --network <chain>` process.
In summary, its a `FlorestaRPC` instance.

The chain can be one of ["regtest", "signet", "testnet"].
You can pass some extra arguments with `extra_args` and it will be appended
to the process command. The `rpcserver` is a dictionary defining a "host",
"port", "username" and "password". The "data_dir" is optional and can be
used to create a temporary directory to store files. It will return an
integer pointing an index of a list of nodes.

- `get_node_settings`: get a registered node settings

- `run_node`: run a node for a registered node settings at some index,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ then
exit 1
fi

poetry -V &>/dev/null
uv -V &>/dev/null

if [ $? -ne 0 ]
then
echo "You must have poetry installed to run those tests!"
echo "You must have uv installed to run those tests!"
exit 1
fi

Expand Down
6 changes: 4 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
jsonrpclib==0.2.1
requests==2.32.3
jsonrpclib>=0.2.1
requests>=2.32.3
black>=24.10.0
pylint>=3.3.2
3 changes: 2 additions & 1 deletion tests/run.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ORIGINAL_PATH=$PATH
export PATH="$FLORESTA_BIN_DIR:$UTREEXO_BIN_DIR:$PATH"

# Actually runs the tests
poetry run poe tests
uv run tests/run_tests.py

# Restores the original PATH
export PATH=$ORIGINAL_PATH
Loading