From 2b171b19c410d4242b8d750708e45111c1935d09 Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 20 Apr 2019 12:18:56 +1000 Subject: [PATCH 1/4] fix generator --- test_generators/operations/deposits.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_generators/operations/deposits.py b/test_generators/operations/deposits.py index 454c6f22d..bd9c392a5 100644 --- a/test_generators/operations/deposits.py +++ b/test_generators/operations/deposits.py @@ -29,7 +29,7 @@ def build_deposit_data(state, message_hash=signing_root(deposit_data), privkey=privkey, domain=spec.get_domain( - state.fork, + state, spec.get_current_epoch(state), spec.DOMAIN_DEPOSIT, ) From 55aa12d7bd5bb4a9d8324b4f26fd3c9d3df8b173 Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 20 Apr 2019 12:23:10 +1000 Subject: [PATCH 2/4] parallelism support for make gen_yaml_tests --- Makefile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index b39538791..0a3e03e33 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ clean: rm -rf $(PY_SPEC_ALL_TARGETS) # "make gen_yaml_tests" to run generators -gen_yaml_tests: $(YAML_TEST_DIR) $(YAML_TEST_TARGETS) +gen_yaml_tests: $(YAML_TEST_TARGETS) # runs a limited set of tests against a minimal config test: $(PY_SPEC_ALL_TARGETS) @@ -48,24 +48,30 @@ CURRENT_DIR = ${CURDIR} # The function that builds a set of suite files, by calling a generator for the given type (param 1) define build_yaml_tests - $(info running generator $(1)) - # Create the output - mkdir -p $(YAML_TEST_DIR)$(1) - - # 1) Create a virtual environment - # 2) Activate the venv, this is where dependencies are installed for the generator - # 3) Install all the necessary requirements - # 4) Run the generator. The generator is assumed to have an "main.py" file. - # 5) We output to the tests dir (generator program should accept a "-o " argument. - cd $(GENERATOR_DIR)$(1); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt; python3 main.py -o $(CURRENT_DIR)/$(YAML_TEST_DIR)$(1) -c $(CURRENT_DIR)/$(CONFIGS_DIR) - - $(info generator $(1) finished) + # Started! + # Create output directory + # Navigate to the generator + # Create a virtual environment, if it does not exist already + # Activate the venv, this is where dependencies are installed for the generator + # Install all the necessary requirements + # Run the generator. The generator is assumed to have an "main.py" file. + # We output to the tests dir (generator program should accept a "-o " argument. + echo "generator $(1) started"; \ + mkdir -p $(YAML_TEST_DIR)$(1); \ + cd $(GENERATOR_DIR)$(1); \ + if test -d venv; then python3 -m venv venv; fi; \ + . venv/bin/activate; \ + pip3 install -r requirements.txt; \ + python3 main.py -o $(CURRENT_DIR)/$(YAML_TEST_DIR)$(1) -c $(CURRENT_DIR)/$(CONFIGS_DIR); \ + echo "generator $(1) finished" endef # The tests dir itself is simply build by creating the directory (recursively creating deeper directories if necessary) $(YAML_TEST_DIR): $(info creating directory, to output yaml targets to: ${YAML_TEST_TARGETS}) mkdir -p $@ +$(YAML_TEST_DIR)/: + $(info ignoring duplicate yaml tests dir) # For any target within the tests dir, build it using the build_yaml_tests function. # (creation of output dir is a dependency) From 69ab4140decb7f98a1143dcd4582a2b872de18c9 Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 20 Apr 2019 12:25:24 +1000 Subject: [PATCH 3/4] Add note on parallelism --- test_generators/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_generators/README.md b/test_generators/README.md index 743157aae..66534e5a8 100644 --- a/test_generators/README.md +++ b/test_generators/README.md @@ -28,9 +28,12 @@ make clean This runs all the generators. ```bash -make gen_yaml_tests +make -j 4 gen_yaml_tests ``` +The `-j N` flag makes the generators run in parallel, with `N` being the amount of cores. + + ### Running a single generator The make file auto-detects generators in the `test_generators/` directory, From 14ff452314d566a595ccbdaf2f4cca9fc161c69e Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 20 Apr 2019 12:28:50 +1000 Subject: [PATCH 4/4] move yaml output target --- .gitignore | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ce047240a..3dd86fc80 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ venv build/ output/ -yaml_tests/ +eth2.0-spec-tests/ .pytest_cache # Dynamically built from Markdown spec diff --git a/Makefile b/Makefile index 0a3e03e33..b93c7ea95 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SPEC_DIR = ./specs SCRIPT_DIR = ./scripts TEST_LIBS_DIR = ./test_libs PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec -YAML_TEST_DIR = ./yaml_tests +YAML_TEST_DIR = ./eth2.0-spec-tests/tests GENERATOR_DIR = ./test_generators CONFIGS_DIR = ./configs