mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-30 03:07:33 +00:00
To decide whether an input's sighash commits its amount, the amount check reads the input's script type, and telling nested segwit from legacy p2sh reads the input's redeem and witness scripts. Those scripts were verified only later, in _parse_inputs. So a witness-only nested segwit input missing one of its scripts read as legacy p2sh and was refused with PSBTInputAmountVerificationError, graded as an attack, instead of PSBTMissingInputScriptError. The script check now runs inside the amount check's loop: after the checks on an input's previous transaction, so a forged one is still refused as an attack, and before the check that reads the scripts. The method is renamed _verify_input_amounts_and_scripts to match, and the per-type utxo requirements move to the comment on UNCOMMITTED_AMOUNT_SCRIPT_TYPES. The foreign nested segwit input in the every-input test now carries a witness_utxo alone, so its missing-redeem-script case takes the witness-only path. The test fails on the previous order.
Running Tests
The tests are designed to be run on non-Raspi hardware.
Setup
On your testing machine you'll have to install:
# general dependencies
pip3 install -r requirements.txt
# test suite dependencies
pip3 install -r tests/requirements.txt
Then make the seedsigner python module visible/importable to the tests by installing it:
pip3 install -e .
Running all tests, calculating overall test coverage
tldr: just run the convenience script from the project root:
./tests/run_full_coverage.sh
Running tests manually
Run the whole test suite:
pytest
Run a specific test file:
pytest tests/test_this_file.py
Run a specific test:
pytest tests/test_this_file.py::test_this_specific_test
Force pytest to show logging output:
pytest tests/test_this_file.py::test_this_specific_test -o log_cli=1
# or (same result)
pytest tests/test_this_file.py::test_this_specific_test --log-cli-level=DEBUG
Annoying complications:
- If you want to see
print()statements that are in a test file, add-s - Better idea: use a proper logger in the test file and use one of the above options to display logs
Screenshot generator
The screenshot generator is meant to mostly be a utility and not really part of the test suite. However,
it is actually implemented to be run by pytest.
see: Screenshot generator README
Generate coverage manually
Run tests and generate test coverage
coverage run -m pytest
The screenshots can generate their own separate coverage report:
coverage run -m pytest tests/screenshot_generator/generator.py --locale es
Show the resulting test coverage details:
coverage report
Generate the interactive html report:
coverage html