Skip to content

Instantly share code, notes, and snippets.

@djrtwo
Last active March 12, 2019 13:54
Show Gist options
  • Save djrtwo/91b68809d108bad0a1e673c889241cf4 to your computer and use it in GitHub Desktop.
Save djrtwo/91b68809d108bad0a1e673c889241cf4 to your computer and use it in GitHub Desktop.
stub for state tests
import yaml
from sanity_check import (
create_genesis_state,
test_empty_block_transition,
)
def generate_yaml_test(pre_state, blocks, post_state, config, fields, root=False):
pass
# if config is empty:
# config = default config
# output config
# output serialized pre-state
# output blocks
# output subset of test_fields
# if len(fields) == 0:
# output entire state
# else:
# for field in fields:
# output resulting field
# if root, output root
def test_generator_wrapper(test_fn, start_state, config, fields, root=False):
blocks, post_state = test_fn(start_state)
generate_yaml_test(start_state, blocks, post_state, config, fields)
def generate_genesis_tests():
genesis_state = create_genesis_state(num_validators=100)
test_generator_wrapper(test_empty_block_transition, genesis_state, {}, ['slot'])
if __name__ == '__main__':
generate_genesis_tests()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment