-
Notifications
You must be signed in to change notification settings - Fork 146
Conversation
0f94d8f
to
4afba49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, but the code generally looks good.
) | ||
|
||
# Test files | ||
ROOT_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better do the path wrangling with pathlib
def get_test_case(file_names): | ||
all_test_cases = [] | ||
for file_name in file_names: | ||
with open(BASE_FIXTURE_PATH + '/' + file_name, 'U') as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: In py-ssz the file path and line number of yaml, supported by ruamel.yaml
, are passed into test_ids, so that devs can jump to the exact line of yaml file in the failing cases.
def make_test_id(filename, test_case):
return f"{filename}:{test_case.lc.line}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that if I use yaml = YAML(typ='unsafe')
, then I cannot use lc
feature. 😮
I chose lc
for debugging!
|
||
FILE_NAMES = [ | ||
"sanity-check_small-config_32-vals.yaml", | ||
"sanity-check_default-config_100-vals.yaml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the test is slow because loading 100-vals tests yaml file is too slow. I tried CLoader
and it can make loading 100-vals significantly faster.
from yaml import CLoader as Loader
with open("eth2-fixtures/state/sanity-check_default-config_100-vals.yaml") as f:
yaml.load(f, Loader=Loader)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ruamel.yaml
, could speed up with yaml = YAML(typ='unsafe')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i ran over this -- looks good, other than the feedback @ChihChengLiang left!
c94a515
to
8c07f4a
Compare
What was wrong?
v0.5.1 state-tests: https://github.com/ethereum/eth2.0-tests/tree/master/state
Add tests/eth2/beacon/state-fixtures/test_minimal_state.py for testing it.
How was it fixed?
ethereum/eth2.0-tests
BeaconStateMachine.__init__
for supporting settingpre_state
in state machine.validate_proposer_signature
interfaceHow to test it:
(And v0.6.0 tests are coming...)
Cute Animal Picture