Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test format docs #1189

Merged
merged 9 commits into from
Jun 19, 2019
4 changes: 2 additions & 2 deletions specs/test_formats/operations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Operations:

| *`operation-name`* | *`operation-object`* | *`input name`* | *`processing call`* |
|-------------------------|----------------------|----------------------|--------------------------------------------------------|
| `attestation` | `Attestation` | `attestation` | `process_attestation(state, attestation)` |
| `attester_slashing` | `AttesterSlashing` | `attester_slashing` | `process_attester_slashing(state, attester_slashing)` |
| `attestation` | `Attestation` | `attestation` | `process_attestation(state, attestation)` |
| `attester_slashing` | `AttesterSlashing` | `attester_slashing` | `process_attester_slashing(state, attester_slashing)` |
| `block_header` | `Block` | `block` | `process_block_header(state, block)` |
| `deposit` | `Deposit` | `deposit` | `process_deposit(state, deposit)` |
| `proposer_slashing` | `ProposerSlashing` | `proposer_slashing` | `process_proposer_slashing(state, proposer_slashing)` |
Expand Down
24 changes: 15 additions & 9 deletions specs/test_formats/shuffling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Clients may take different approaches to shuffling, for optimizing,
and supporting advanced lookup behavior back in older history.

For implementers, possible test runners implementing testing can include:
1) Just test permute-index, run it for each index `i` in `range(count)`, and check against expected `output[i]` (default spec implementation).
2) Test un-permute-index (the reverse lookup; implemented by running the shuffling rounds in reverse, from `round_count-1` to `0`).
3) Test the optimized complete shuffle, where all indices are shuffled at once; test output in one go.
4) Test complete shuffle in reverse (reverse rounds, same as #2).
1) Just test `get_shuffled_index`.
2) Test the reverse lookup; implemented by running the shuffling rounds in reverse, from `round_count-1` to `0`.
3) Test the optimized complete shuffle, where all indices are shuffled at once
protolambda marked this conversation as resolved.
Show resolved Hide resolved
4) Test complete shuffle in reverse (reverse rounds, similar to #2).
protolambda marked this conversation as resolved.
Show resolved Hide resolved

## Test case format

Expand All @@ -20,13 +20,19 @@ count: int
shuffled: List[int]
```

- The `bytes32` is encoded a string, hexadecimal encoding, prefixed with `0x`.
- The `bytes32` is encoded as a string, hexadecimal encoding, prefixed with `0x`.
- Integers are validator indices. These are `uint64`, but realistically they are not as big.

The `count` specifies the validator registry size. One should compute the shuffling for indices `0, 1, 2, 3, ..., count (exclusive)`.
Seed is the raw shuffling seed, passed to permute-index (or optimized shuffling approach).
The `count` specifies the count of validators being shuffled (i.e. active validators during committee computation).

## Condition
One should test the shuffling for indices `0, 1, 2, 3, ..., count (exclusive)`.

`shuffled` is a mapping from `i` to `get_shuffled_index(i)`.
protolambda marked this conversation as resolved.
Show resolved Hide resolved
- `i` here is the index within committee-partitioned space. `i...i+N (excl.)` is used to get the validators for a committee of size `N`.
- `get_shuffled_index(i)` here is the index within the active-validators space. Pointing to the validator assigned to the committee corresponding to `i`.
protolambda marked this conversation as resolved.
Show resolved Hide resolved

The resulting list should match the expected output `shuffled` after shuffling the implied input, using the given `seed`.
Seed is the raw shuffling seed, passed to shuffling function.
protolambda marked this conversation as resolved.
Show resolved Hide resolved

## Condition

For the `get_shuffled_index` implementation (or list-wise equivalent): `get_shuffled_index(i) == shuffled[i]`
protolambda marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 8 additions & 2 deletions specs/test_formats/ssz_generic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ Test format documentation can be found here: [uint test format](./uint.md).
*Note*: The current Phase 0 spec does not use larger uints, and uses byte vectors (fixed length) instead to represent roots etc.
The exact uint lengths to support may be redefined in the future.

Extension of the SSZ tests collection is planned, with an update to the new spec-maintained `minimal_ssz.py`;
see CI/testing issues for progress tracking.
## Recommendation

For SSZ testing directly applicable to test-networks, refer to the [`ssz_static`](../ssz_static/README.md) tests,
which cover SSZ behavior for phase-0, for all container types.
protolambda marked this conversation as resolved.
Show resolved Hide resolved
With serialization, hash-tree-root and signing-root all covered.
Note that deserialization can be tested using this same data,
but be cautious about the serialized data only covering the valid-input side.
protolambda marked this conversation as resolved.
Show resolved Hide resolved
SSZ implementations should be hardened against invalid offsets, invalid boolean values, etc. in a non-testing setting.
6 changes: 4 additions & 2 deletions test_generators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ This directory contains all the generators for YAML tests, consumed by Eth 2.0 c

Any issues with the generators and/or generated tests should be filed in the repository that hosts the generator outputs, here: [ethereum/eth2.0-spec-tests](https://github.com/ethereum/eth2.0-spec-tests).

Whenever a release is made, the new tests are automatically built, and
[eth2TestGenBot](https://github.com/eth2TestGenBot) commits the changes to the test repository.
Test-vectors are generated and published by the release-publishers for every release.

Spec-tests are unified with the executable spec: these tests are PyTest compatible, run in CI, but also enable special settings.
Settings include BLS on/off, and the option to output the relevant data into a test-vector in "generator mode".
protolambda marked this conversation as resolved.
Show resolved Hide resolved

## How to run generators

Expand Down