Skip to content

Commit

Permalink
Refactor, merge files.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Aug 5, 2024
1 parent 5f79ab8 commit 4e86545
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 156 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/check_data.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ jobs:
cd $GITHUB_WORKSPACE/cmd/rosetta && go build .
cd $GITHUB_WORKSPACE/systemtests && go build ./proxyToObserverAdapter.go
- name: Run scenario
- name: check:data
run: |
PYTHONPATH=. python3 ./systemtests/check_construction_native.py --network testnet
PYTHONPATH=. python3 ./systemtests/check.py --mode=data --network=testnet
- name: check:construction
run: |
PYTHONPATH=. python3 ./systemtests/check.py --mode=construction --network=testnet
53 changes: 49 additions & 4 deletions systemtests/check_data.py → systemtests/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
import requests

from systemtests import constants
from systemtests.check_shared import (get_current_epoch,
run_proxy_to_observer_adapter)
from systemtests.config import CONFIGURATIONS, Configuration


def main() -> int:
parser = ArgumentParser()
parser.add_argument("--mode", choices=["data", "construction"], required=True)
parser.add_argument("--network", choices=CONFIGURATIONS.keys(), required=True)
args = parser.parse_args()

mode = args.mode
configuration = CONFIGURATIONS[args.network]

process_rosetta = run_rosetta(configuration)
process_adapter = run_proxy_to_observer_adapter(configuration)
process_checker = run_rosetta_checker(configuration)
process_checker = run_rosetta_checker(mode, configuration)

# Handle termination signals
def signal_handler(sig: Any, frame: Any):
Expand Down Expand Up @@ -73,7 +73,46 @@ def run_rosetta(configuration: Configuration):
return subprocess.Popen(command)


def run_rosetta_checker(configuration: Configuration):
def run_proxy_to_observer_adapter(configuration: Configuration):
command = [
str(constants.PATH_PROXY_TO_OBSERVER_ADAPTER),
f"--proxy={configuration.proxy_url}",
f"--shard={configuration.network_shard}",
f"--sleep={constants.ADAPTER_DELAY_IN_MILLISECONDS}"
]

return subprocess.Popen(command)


def run_rosetta_checker(mode: str, configuration: Configuration):
if mode == "data":
return run_rosetta_checker_with_check_data(configuration)
elif mode == "construction":
return run_rosetta_checker_with_check_construction(configuration)
else:
raise ValueError(f"Unknown mode: {mode}")


def run_rosetta_checker_with_check_construction(configuration: Configuration):
"""
E.g.
rosetta-cli check:construction --configuration-file devnet-construction.json \
--online-url=http://localhost:7091 --offline-url=http://localhost:7091
"""

command = [
"rosetta-cli",
"check:construction",
f"--configuration-file={configuration.check_construction_configuration_file}",
f"--online-url=http://localhost:{constants.PORT_ROSETTA}",
f"--offline-url=http://localhost:{constants.PORT_ROSETTA}",
]

return subprocess.Popen(command)


def run_rosetta_checker_with_check_data(configuration: Configuration):
"""
E.g.
Expand All @@ -99,6 +138,12 @@ def run_rosetta_checker(configuration: Configuration):
return subprocess.Popen(command)


def get_current_epoch(configuration: Configuration) -> int:
response = requests.get(f"{configuration.proxy_url}/network/status/{configuration.network_shard}")
response.raise_for_status()
return response.json()["data"]["status"]["erd_epoch_number"]


def get_start_of_epoch(configuration: Configuration, epoch: int) -> int:
response = requests.get(f"{configuration.proxy_url}/network/epoch-start/{configuration.network_shard}/by-epoch/{epoch}")
response.raise_for_status()
Expand Down
94 changes: 0 additions & 94 deletions systemtests/check_construction_native.py

This file was deleted.

23 changes: 0 additions & 23 deletions systemtests/check_shared.py

This file was deleted.

0 comments on commit 4e86545

Please sign in to comment.