Skip to content

Commit

Permalink
Merge pull request #20 from ericsson49/fc-compliance2
Browse files Browse the repository at this point in the history
viable_for_head_roots_and_weights format changed
  • Loading branch information
mkalinin authored Jul 3, 2024
2 parents 4a0745b + 1854266 commit 925f954
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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

0 comments on commit 925f954

Please sign in to comment.