-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from daira/doc-and-tests
Doc and test improvements
- Loading branch information
Showing
16 changed files
with
408 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
[flake8] | ||
exclude = .git, __pycache__ | ||
ignore = E302 | ||
|
||
# Justifications for each ignored error or warning: | ||
# * E302: always requiring two blank lines rather than one between top-level items is too annoying and nitpicky. | ||
# * E402: we want imports for tests to go between the main code and the tests. | ||
# * W503, W504: these give false positives for the style of avoiding \ at the end of each line by using parens. | ||
# | ||
# References: | ||
# - https://flake8.pycqa.org/en/latest/user/error-codes.html | ||
# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes | ||
ignore = E302, E402, W503, W504 | ||
|
||
max-line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: tests | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install gnome-keyring | ||
# https://github.com/python-poetry/poetry/issues/2692 | ||
run: sudo apt-get install gnome-keyring | ||
|
||
- name: Install poetry | ||
run: pip install --user poetry | ||
|
||
- name: Install dependencies | ||
run: poetry install --no-root | ||
|
||
- name: Run tests | ||
# -p '[a-z]*.py' avoids running tests from __init__.py files twice. | ||
run: poetry run python -m unittest discover -s simtfl -t . -p '[a-z]*.py' --verbose --buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
*.swp | ||
*.save | ||
|
||
# API docs | ||
apidoc/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
cd -P -- "$(dirname -- "$(command -v -- "$0")")" | ||
|
||
echo Running flake8... | ||
poetry run flake8 | ||
|
||
echo | ||
echo Running unit tests... | ||
args="${*:---buffer}" | ||
poetry run python -m unittest discover -s simtfl -t . -p '[a-z]*.py' --verbose ${args} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Programming patterns | ||
|
||
The code makes use of the [simpy](https://simpy.readthedocs.io/en/latest/) | ||
discrete event simulation library. This means that functions representing | ||
processes are implemented as generators, so that the library can simulate | ||
timeouts and asynchronous communication (typically faster than real time). | ||
|
||
We use the convention of putting "(process)" in the doc comment of these | ||
functions. They either must use the `yield` construct, *or* return the | ||
result of calling another "(process)" function (not both). | ||
|
||
Objects that implement processes typically hold the `simpy.Environment` in | ||
an instance variable `self.env`. | ||
|
||
To wait for another process `f()` before continuing, use `yield from f()`. | ||
(If it is the last thing to do in a function with no other `yield` | ||
statements, `return f()` can be used as an optimization.) | ||
|
||
A "(process)" function that does nothing should `return skip()`, using | ||
`simtfl.util.skip`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
poetry run pdoc simtfl -o apidoc --no-include-undocumented -d markdown |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
This is an experimental simulator for research into a potential | ||
[Trailing Finality Layer](https://electric-coin-company.github.io/tfl-book/) | ||
for Zcash. | ||
See the [README](../README.md) for more information. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
""" | ||
Base classes for messages. | ||
""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Any | ||
|
||
|
||
@dataclass(frozen=True) | ||
class PayloadMessage: | ||
""" | ||
A message with an arbitrary payload. | ||
""" | ||
def __init__(self, payload): | ||
""" | ||
Constructs a `PayloadMessage` with the given payload. | ||
""" | ||
self.payload = payload | ||
|
||
def __str__(self): | ||
return f"{self.__class__.__name__}({self.payload})" | ||
payload: Any | ||
"""The payload.""" |
Oops, something went wrong.