diff --git a/lib/fixtures.py b/lib/fixtures.py index f75e568..78e6a63 100644 --- a/lib/fixtures.py +++ b/lib/fixtures.py @@ -8,6 +8,7 @@ from lib.instance_configs import DEFAULT_INSTANCE_CONFIG from lib.types import Fixture + def extract_fixtures(clients_to_test=SUPPORTED_CLIENTS) -> List[Fixture]: fixtures = [] for client in SUPPORTED_CLIENTS: @@ -24,6 +25,7 @@ def extract_fixtures(clients_to_test=SUPPORTED_CLIENTS) -> List[Fixture]: return fixtures + def setup_fixture(fixture: Fixture): for instance in fixture.instances: start_instance(instance) diff --git a/lib/instance_configs.py b/lib/instance_configs.py index 6b460af..e7bafc1 100644 --- a/lib/instance_configs.py +++ b/lib/instance_configs.py @@ -2,7 +2,7 @@ from sclients import ENR DEFAULT_BEACON_STATE_PATH = 'ssz/default.ssz' -DEFAULT_ENR = { +DEFAULT_ENR = { 'enr': 'enr:-LK4QJCIZoViytOOmAzAbdOJODwQ36PhjXwvXlTFTloTzpawVpvPRmtrM6UZdPmOGck5yPZ9AbgmwyZnE3jm4jX0Yx0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBGMkSJAAAAAf__________gmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQOnBq2PcxFfkFACZvJz91cd-UKaTPtLv7zYJSJyAtq60YN0Y3CCIyiDdWRwgiMp', 'enr_teku': 'enr:-KG4QF9w4w5DORl2-AtVaqK6n-VF3e-2p5fm4uqDLwlR8cQ4MVk2yJ68YkEUTASbbJJ123CKYDDY1KdfBWOuVrmsZtUChGV0aDKQGK5MywAAAAH__________4JpZIJ2NIJpcIR_AAABiXNlY3AyNTZrMaEDpwatj3MRX5BQAmbyc_dXHflCmkz7S7-82CUicgLautGDdGNwgiMog3VkcIIjKA', 'private_key': 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', diff --git a/lib/logging_tests.py b/lib/logging_tests.py index eee5701..fb49eec 100644 --- a/lib/logging_tests.py +++ b/lib/logging_tests.py @@ -4,6 +4,7 @@ LOGGING_TESTS_DIR = 'logging_tests' + def all_logging_test_files(): tests = [] for root, dirs, files in os.walk(LOGGING_TESTS_DIR): diff --git a/lib/runner.py b/lib/runner.py index 85eaeaf..a710796 100644 --- a/lib/runner.py +++ b/lib/runner.py @@ -7,6 +7,7 @@ TESTS_DIR = 'tests' + def all_test_files(): tests = [] for root, dirs, files in os.walk(TESTS_DIR): @@ -18,9 +19,11 @@ def all_test_files(): return tests + def file_to_module(script): return script.replace('/', '.')[0:-3] + def return_code_to_status(return_code): if return_code == 0: return color('\u2713', fg='green') @@ -28,6 +31,7 @@ def return_code_to_status(return_code): else: return color('\u2717', fg='red') + def run_module(module_str, args): module = importlib.import_module(module_str) @@ -39,9 +43,11 @@ def run_module(module_str, args): return (return_code, logs) + def file_matches_filter(file, file_filter): return file_filter is None or file == file_filter + def run_test_files(fixture_name, files, args): print(fixture_name) diff --git a/steth.py b/steth.py index 31b4973..0745646 100755 --- a/steth.py +++ b/steth.py @@ -10,6 +10,7 @@ from lib.runner import run_test_files, all_test_files, file_matches_filter from lib.logging_tests import all_logging_test_files + def run_test_cmd(args): clients = SUPPORTED_CLIENTS if args.client is None else [args.client] @@ -41,13 +42,14 @@ def run_logging_test(args): failed = False for client in SUPPORTED_CLIENTS: - return_code= run_test_files(client, test_files, {}) + return_code = run_test_files(client, test_files, {}) if return_code != 0: failed = True if failed: exit(1) + if __name__ == '__main__': steth = argparse.ArgumentParser(description='Stethoscope tool for running multi-client Eth2 scenarios') steth_sub = steth.add_subparsers() @@ -58,7 +60,8 @@ def run_logging_test(args): test.add_argument('-o', '--only', help='run specific tests by name') test.set_defaults(func=run_test_cmd) - test = steth_sub.add_parser('logging_test', help='Display example logs from ./steth.py test. Useful for testing CI integration') + test = steth_sub.add_parser( + 'logging_test', help='Display example logs from ./steth.py test. Useful for testing CI integration') test.set_defaults(func=run_logging_test) args = steth.parse_args() diff --git a/tests/reqresp/metadata.py b/tests/reqresp/metadata.py index 79428f3..8b15341 100644 --- a/tests/reqresp/metadata.py +++ b/tests/reqresp/metadata.py @@ -3,6 +3,7 @@ from ..utils import parse_chunk_response, with_rumor + class Metadata(Container): seq_number: uint64 attnets: Bitvector[64] diff --git a/tests/utils.py b/tests/utils.py index 7237b28..8a3d48d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,6 +4,7 @@ from eth2spec.utils.ssz.ssz_typing import Container from pyrum import SubprocessConn, Rumor + def with_rumor(async_run_fn): async def wrapped_run_fn(args): async with SubprocessConn(cmd='./bin/rumor bare --level=trace') as conn: @@ -18,12 +19,14 @@ async def wrapped_run_fn(args): return wrapped_run_fn + def parse_chunk_response(resp): if 'data' not in resp: return (None, [f"request error: 'data' field not in response"]) return (resp['data'], []) + def enr_to_fork_digest(enr): eth2 = enr.eth2 eth2 = eth2[2:] if eth2.startswith('0x') else eth2