These steps download the source package of ledgdex from PyPI, and run all the tests of ledgdex on your computer. Use them to make sure that a release works on your computer.
The source package has the tests and the test data. The normal installation (pip install "ledgdex[fast]") does not have them, so that it stays small.
You need Python 3.8 or later, git, and node 20 or later. The tests use git to publish to test repositories on your computer. They use node to compare the JavaScript core with the Python package. The tests do not use the internet. Only pip downloads packages.
The tests run on Linux, macOS and Windows. On Windows, install Git for Windows: the tests use its bash for the shell examples and the tutorial.
1. Make a new folder and a new Python environment:
mkdir ledgdex-test && cd ledgdex-test
python3 -m venv .venv
source .venv/bin/activateOn Windows, use python -m venv .venv and .venv\Scripts\activate. Windows 10 and later have tar.2. Download the source package of the version that you want, and open it:
pip download "ledgdex==1.0.20" --no-deps --no-binary ledgdex
tar -xzf ledgdex-1.0.20.tar.gz
cd ledgdex-1.0.203. Install ledgdex from this folder, with the fast extra:
pip install ".[fast]"4. Run the full test suite:
python run_tests.py --fullExpected output: one line for each part, and all tests passed at the end:
passed: Python tests, all, fast backend (cryptography) (200 s)
passed: JavaScript core against the shared vectors (5 s)
passed: Python tests, all, pure Ed25519, no verification cache (280 s)
passed: Differential fuzzing, Python against JavaScript (seed 1) (15 s)
all tests passedThe full suite takes approximately 10 minutes. The essential suite, python run_tests.py, takes approximately 30 seconds. It runs all Python tests with the fast backend, but not the docs examples and the tutorial. It also runs the JavaScript vectors. Use the essential suite after small changes. Use the full suite after larger changes and before a release.
If a part fails, run_tests.py shows the end of the output of that part, and stops with exit code 1. --verbose shows all the output. --seed N sets a different fuzzing seed.
The parts of the full suite:
- The Python tests: the format, the signatures, the ledgers and the state rules. Also the checks for tampering, the command line, the shop from a catalog, the 15 examples of the docs and the tutorial.
- The JavaScript vectors: the JavaScript core must give the same bytes, ids, signatures, state and pages as the Python package.
- The pure backend: the same Python tests with the built-in Ed25519 code, and with no verification cache.
- The fuzzing: random ledgers, damaged in many ways. Python and JavaScript must give the same result for each ledger.
The tests keep their keys in temporary folders. They do not change your keys in ~/.ledgdex.
To test a clone of the repository, run python run_tests.py --full in the clone. See Installation.