2019-10-28 07:53:10 +00:00
|
|
|
# Eth2 Executable Python Spec (PySpec)
|
2019-03-27 16:28:20 +00:00
|
|
|
|
2019-10-28 07:53:10 +00:00
|
|
|
The executable Python spec is built from the Eth2 specification,
|
2019-03-27 16:43:56 +00:00
|
|
|
complemented with the necessary helper functions for hashing, BLS, and more.
|
|
|
|
|
|
|
|
With this executable spec,
|
|
|
|
test-generators can easily create test-vectors for client implementations,
|
2019-05-06 15:30:32 +00:00
|
|
|
and the spec itself can be verified to be consistent and coherent through sanity tests implemented with pytest.
|
2019-03-27 16:43:56 +00:00
|
|
|
|
2019-04-17 07:47:56 +00:00
|
|
|
|
2019-03-28 16:51:49 +00:00
|
|
|
## Building
|
|
|
|
|
|
|
|
All the dynamic parts of the spec can be build at once with `make pyspec`.
|
|
|
|
|
|
|
|
Alternatively, you can build a sub-set of the pyspec: `make phase0`.
|
|
|
|
|
2019-05-06 15:30:32 +00:00
|
|
|
Or, to build a single file, specify the path, e.g. `make test_libs/pyspec/eth2spec/phase0/spec.py`.
|
2019-03-28 16:51:49 +00:00
|
|
|
|
2019-04-17 07:47:56 +00:00
|
|
|
|
|
|
|
## Py-tests
|
|
|
|
|
2019-05-06 15:30:32 +00:00
|
|
|
After building, you can install the dependencies for running the `pyspec` tests with `make install_test`.
|
2019-04-20 01:33:15 +00:00
|
|
|
|
2019-04-17 07:47:56 +00:00
|
|
|
These tests are not intended for client-consumption.
|
|
|
|
These tests are sanity tests, to verify if the spec itself is consistent.
|
|
|
|
|
|
|
|
### How to run tests
|
|
|
|
|
|
|
|
#### Automated
|
|
|
|
|
2019-06-16 23:38:48 +00:00
|
|
|
Run `make test` from the root of the specs repository (after running `make install_test` if have not before).
|
2019-04-17 07:47:56 +00:00
|
|
|
|
|
|
|
#### Manual
|
|
|
|
|
|
|
|
From within the `pyspec` folder:
|
|
|
|
|
|
|
|
Install dependencies:
|
|
|
|
```bash
|
|
|
|
python3 -m venv venv
|
|
|
|
. venv/bin/activate
|
2019-04-24 17:59:13 +00:00
|
|
|
pip3 install -r requirements-testing.txt
|
2019-04-17 07:47:56 +00:00
|
|
|
```
|
2019-05-06 15:30:32 +00:00
|
|
|
*Note*: Make sure to run `make -B pyspec` from the root of the specs repository,
|
2019-04-17 07:47:56 +00:00
|
|
|
to build the parts of the pyspec module derived from the markdown specs.
|
2019-04-20 01:33:15 +00:00
|
|
|
The `-B` flag may be helpful to force-overwrite the `pyspec` output after you made a change to the markdown source files.
|
2019-04-17 07:47:56 +00:00
|
|
|
|
|
|
|
Run the tests:
|
|
|
|
```
|
2019-05-08 16:14:47 +00:00
|
|
|
pytest --config=minimal eth2spec
|
2019-04-17 07:47:56 +00:00
|
|
|
```
|
2019-05-08 16:14:47 +00:00
|
|
|
Note the package-name, this is to locate the tests.
|
2019-04-17 07:47:56 +00:00
|
|
|
|
2019-06-16 23:38:48 +00:00
|
|
|
### How to view code coverage report
|
|
|
|
|
|
|
|
Run `make open_cov` from the root of the specs repository after running `make test` to open the html code coverage report.
|
|
|
|
|
2019-04-17 07:47:56 +00:00
|
|
|
|
2019-03-28 16:51:49 +00:00
|
|
|
## Contributing
|
|
|
|
|
2019-03-27 16:43:56 +00:00
|
|
|
Contributions are welcome, but consider implementing your idea as part of the spec itself first.
|
|
|
|
The pyspec is not a replacement.
|
2019-04-17 07:47:56 +00:00
|
|
|
|
2019-03-27 16:43:56 +00:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2020-01-10 18:42:55 +00:00
|
|
|
Same as the spec itself; see [LICENSE](../../../LICENSE) file in the specs repository root.
|