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

viable_for_head_roots_and_weights format changed #20

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/core/pyspec/eth2spec/test/helpers/fork_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ def output_store_checks(spec, store, test_steps, with_viable_for_head_weights=Fa
leaves_viable_for_head = [root for root in filtered_block_roots
if not any(c for c in filtered_block_roots if store.blocks[c].parent_root == root)]

viable_for_head_roots_and_weights = {
encode_hex(viable_for_head_root): int(spec.get_weight(store, viable_for_head_root))
viable_for_head_roots_and_weights = [
{
'root': encode_hex(viable_for_head_root),
'weight': int(spec.get_weight(store, viable_for_head_root))
}
for viable_for_head_root in leaves_viable_for_head
}
]
checks['viable_for_head_roots_and_weights'] = viable_for_head_roots_and_weights

test_steps.append({'checks': checks})
Expand Down
2 changes: 2 additions & 0 deletions tests/generators/fork_choice_generated/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Preliminary research has been also performed in this [repo](https://github.com/t

To simplfy adoption of the tests, we follow the test format described in the [fork choice test formats documentation](../../formats/fork_choice/README.md), with a minor exception (new check added).

This work was supported by a grant from the Ethereum Foundation.

# Pre-requisites

Install requirements (preferrably, in a dedicated Python environment)
Expand Down
3 changes: 2 additions & 1 deletion tests/generators/fork_choice_generated/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def run_test(test_info):
str(viable_for_head_root): int(spec.get_weight(store, viable_for_head_root))
for viable_for_head_root in leaves_viable_for_head
}
assert value == viable_for_head_roots_and_weights
expected = { kv['root']: kv['weight'] for kv in value}
assert expected == viable_for_head_roots_and_weights
else:
assert False
else:
Expand Down
Loading