Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-structured functional tests. #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qlrd
Copy link
Contributor

@qlrd qlrd commented Mar 7, 2025

Improves #252

What is the purpose of this pull request?

  • Bug fix
  • Documentation update
  • New feature
  • Test
  • Other:

Which crates are being modified?

  • floresta-chain
  • floresta-cli
  • floresta-common
  • floresta-compact-filters
  • floresta-electrum
  • floresta-watch-only
  • floresta-wire
  • floresta
  • florestad
  • Other: .

Description

This re-structure aims to optmize developer flow and the experience with tests tool through 1) a replacement of the current python package management; 2) a more organized folder tree strucutre inside tests/; and 3) changes in tests/run_tests.py, tests/prepare.sh and tests/run.sh to comply with the already mentioned changes.

The replacement in python package management is from poetry to uv (a rust-based python management tool); this approach have some PROS: (i) built with rust; (ii) faster than poetry; (iii) cleanup some unecessary python dependencies; (iv) more readable pyproject.toml; (v) compatible with python pip install -r approach (for old-school pythonists). Until now, a CON is: (i) this remove some poetry macros. Still seems like a good replacement.

The folder structure organization allows you to define test suites in separate folders (e.g. "florestad", "floresta-cli") without needing to define each of them in pyproject.toml. Files ending with "-test.py" in each folder will be recognized and executed.

To comply with above mentioned changes, tests/run_tests.py was modified to inlcude an argument --test-suite that will search for a folder tests/<test-suite>. It was also necessary to change tests/prepare.sh and tests/run.sh to replace poetry to uv.

Notes to the reviewers

A better context about this change is available in #252 (comment) and #391. Tested this approach in https://github.com/qlrd/Floresta/actions/runs/13722793641/job/38381971781

Checklist

  • I've signed all my commits
  • I ran just lint
  • I ran cargo test
  • I've checked the integration tests
  • I've followed the contribution guidelines
  • I'm linking the issue being fixed by this PR (if any)

@Davidson-Souza Davidson-Souza added dependencies Pull requests that update a dependency file code quality Generally improves code readability and maintainability functional tests labels Mar 7, 2025
@qlrd qlrd force-pushed the uv-dep-management branch 2 times, most recently from 94d6357 to 9fef5fc Compare March 7, 2025 20:48
Copy link
Collaborator

@Davidson-Souza Davidson-Souza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv sounds promising, it really is faster than alternatives. If this indeed fixes our nix setup, more than happy to make this change.

Just some minor nits from me. I've ran the tests and works fine

README.md Outdated
# recomended way
pipx install poetry
# create a virtual environment
# (it's good to not messing up with your OS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's good to not mess up with your os

# official isntaller (windows - powershell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
# Alternatively, you can synchronize it
uv sync
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't uv pip install -r pyproject.toml redundant with uv sync?

Copy link
Contributor Author

@qlrd qlrd Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what i understood in docs:

  • uv pip install -r pyproject.toml installs dependencies listed in pyproject.toml (in local development environment, it do not remove existing packages).

  • uv sync uses the uv.lock file to enforce reproducible installations.

So the sync reproduced what i made here. Maybe it's better add this warning?


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add that to run all tests, just omit --test-suite.

Also, is there a way to list all available ones?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the same suggestion to @qlrd while he was at casavinteum. And looks like he already implemented.

When tests.py are invoked without -t or --test-suite set, it computes every subfolder of tests/ as a suite. test_framework isnt added as suite.

See https://github.com/vinteumorg/Floresta/pull/402/files#diff-88fd88a13f19bfeedc205c137e4fa94c7cd34be808ad01dab5e5d69641e60e0cR57

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with davidson, a uv run tests/run_tests.py --list-suites would be nice, one that is debugging our python tests can use this command to undersand what run_tests.py see as a suite.

Copy link
Contributor Author

@qlrd qlrd Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@jaoleal, i improved it and i think is more clear. I added here a --list-suite and will do a rebase.

from test_framework.test_framework import FlorestaTestFramework
from test_framework.electrum_client import ElectrumClient
from test_framework.floresta_rpc import REGTEST_RPC_SERVER
from tests.test_framework.test_framework import FlorestaTestFramework
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a way to set the root dir to /tests/. Not a roadblocker, but a minor annoyance to need this tests.*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, i will need try here @Davidson-Souza.

@qlrd qlrd force-pushed the uv-dep-management branch from 9fef5fc to edf697e Compare March 10, 2025 17:00
This commit aims to optmize developer flow and the experience
with tests tool through 1) a replacement of the current python package
management; 2) a more organized folder tree strucutre inside tests/; and
3) changes in tests/run_tests.py, tests/prepare.sh and tests/run.sh
to comply with the already mentioned changes.

The replacement in python package management is from poetry to uv (a
rust-based
python management tool); this approach have some PROS: (i) built with
rust;
(ii) faster than poetry; (iii) cleanup some unecessary python
dependencies;
(iv) more readable pyproject.toml; (v) compatible with python pip
install -r
approach (for old-school pythonists). Until now, a CON is: (i) this
remove
some poetry macros. Still seems like a good replacement.

The folder structure organization allows you to define test suites in
separate
folders (e.g. "florestad", "floresta-cli") without needing to define
each of
them in pyproject.toml. Files ending with "-test.py" in each folder will
be
recognized and executed.

To comply with above mentioned changes, tests/run_tests.py was modified
to
inlcude an argument `--test-suite` that will search for a folder
`tests/<test-suite>`. It was also necessary to change `tests/prepare.sh`
and `tests/run.sh` to replace poetry to uv.

The README helps the developer to: (i) install uv; (ii) configure
functional test
environment; (iii) format code; (iv) lint code; (v) run tests.

It also updated .gitignore so it can help to avoid add .venv folder that
is created by uv tool.

updated run_tests.py

updated README

updated run_tests.py
@qlrd qlrd force-pushed the uv-dep-management branch from edf697e to 0565a6c Compare March 10, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Generally improves code readability and maintainability dependencies Pull requests that update a dependency file functional tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants