Skip to content

Commit

Permalink
poc: Move test vector generation out of unit tests
Browse files Browse the repository at this point in the history
Remove the TEST_VECTOR and TEST_VECTOR_PATH environment variables and
move test vector generation logic into a new tool, `gen_test_vec.py`.

The test vectors are complete with the following exceptions:

1. We currently don't have test vectors for Prio3MultihotCountVec. This
   VDAF is new as of draft 10, but we neglected to add test vectors for
   it. This change checks in the test vectors.

2. The test vector for IdpfBBCGGI21 was regenerated after this IDPF was
   renamed. Also, as of 01291c2, we are
   generating this with a proper nonce rather than an adhoc binder. To
   confirm that nothing has changed, you can modify
   `gen_test_vec_for_idpf()` by replacing Lines

    ```
    nonce = gen_rand(idpf.NONCE_SIZE)
    ```

    with

    ```
    nonce = bytes([0x73,0x6f,0x6d,0x65,0x20,0x6e,0x6f,0x6e,0x63,0x65])
    ```

Also, this change opts in `gen_test_vec.py` and
`plot_prio3_multiproof_robustness.py` into linting and type checking.
  • Loading branch information
cjpatton committed Aug 2, 2024
1 parent 8355b5c commit 4d7694e
Show file tree
Hide file tree
Showing 14 changed files with 530 additions and 343 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:

- name: Run pyflakes
working-directory: poc
run: pyflakes vdaf_poc/*.py tests/*.py
run: pyflakes *.py vdaf_poc/*.py tests/*.py

- name: Run autopep8
working-directory: poc
run: autopep8 --diff --exit-code vdaf_poc/*.py tests/*.py
run: autopep8 --diff --exit-code *.py vdaf_poc/*.py tests/*.py

- name: Run isort
working-directory: poc
run: isort --check .

- name: Run pylint
working-directory: poc
run: pylint --disable=all --enable=redefined-outer-name vdaf_poc/*.py tests/*.py
run: pylint --disable=all --enable=redefined-outer-name *.py vdaf_poc/*.py tests/*.py
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:

- name: Enforce type hints
working-directory: poc
run: sage -python -m mypy vdaf_poc/*.py tests/*.py
run: sage -python -m mypy *.py vdaf_poc/*.py tests/*.py
10 changes: 4 additions & 6 deletions poc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ sage -python -m unittest

## Generating test vectors

To generate test vectors, set environment variable `TEST_VECTOR` to
be `TRUE` when running tests:
To generate test vectors, run:

```
TEST_VECTOR=TRUE sage -python -m unittest --quiet
sage -python gen_test_vec.py
```

Users can also specify a custom path to generate the test vectors in
environment variable `TEST_VECTOR_PATH`. For example, to generate
test vectors for Prio3 VDAFs into path `test_vec/00`:
environment variable `TEST_VECTOR_PATH`:

```
TEST_VECTOR=TRUE TEST_VECTOR_PATH=test_vec/00 sage -python -m unittest --quiet tests/test_vdaf_prio3.py
TEST_VECTOR_PATH=path/to/test_vec sage -python gen_test_vec.py
```
Loading

0 comments on commit 4d7694e

Please sign in to comment.