Have simulator not rely on chia_root as originally implemented. & fix simulator tests (#15157)

* fix parent path issue

* Update default_root.py

* remove fstring

* Update test-single.yml

* allow for multiple parallel runs
This commit is contained in:
Jack Nelson 2023-05-17 13:55:12 -04:00 committed by GitHub
parent d6d8eaa984
commit f2cc1f2ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -120,6 +120,7 @@ jobs:
env:
CHIA_ROOT: ${{ github.workspace }}/.chia/mainnet
CHIA_SIMULATOR_ROOT: ${{ github.workspace }}/.chia/simulator
JOB_FILE_NAME: tests_${{ matrix.os.file_name }}_python-${{ matrix.python.file_name }}_${{ matrix.configuration.name }}
BLOCKS_AND_PLOTS_VERSION: 0.29.0

View File

@ -7,6 +7,4 @@ DEFAULT_ROOT_PATH = Path(os.path.expanduser(os.getenv("CHIA_ROOT", "~/.chia/main
DEFAULT_KEYS_ROOT_PATH = Path(os.path.expanduser(os.getenv("CHIA_KEYS_ROOT", "~/.chia_keys"))).resolve()
SIMULATOR_ROOT_PATH = Path(
os.path.expanduser(os.getenv("CHIA_SIMULATOR_ROOT", f"{DEFAULT_ROOT_PATH.parent}/simulator"))
).resolve()
SIMULATOR_ROOT_PATH = Path(os.path.expanduser(os.getenv("CHIA_SIMULATOR_ROOT", "~/.chia/simulator"))).resolve()

View File

@ -1,5 +1,6 @@
from __future__ import annotations
from pathlib import Path
from shutil import rmtree
from click.testing import CliRunner, Result
@ -15,11 +16,24 @@ fingerprint = 2640131813
std_farming_address = "txch1mh4qanzyawn3v4uphgaj2cg6hrjazwyp0sx653fhn9apg6mfajlqtj0ztp"
burn_address = "txch1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqm6ksh7qddh" # 0x0...dead
SIMULATOR_ROOT_PATH.mkdir(parents=True, exist_ok=True) # this simplifies code later
def get_profile_path(starting_string: str) -> str:
"""
Returns the name of a profile that does not exist yet.
"""
i = 0
while Path(SIMULATOR_ROOT_PATH / (starting_string + str(i))).exists():
i += 1
return starting_string + str(i)
def test_every_simulator_command() -> None:
starting_str = "ci_test"
simulator_name = get_profile_path(starting_str)
runner: CliRunner = CliRunner()
address = std_farming_address
simulator_name = "ci_test"
start_result: Result = runner.invoke(cli, ["dev", "sim", "-n", simulator_name, "create", "-bm", mnemonic])
assert start_result.exit_code == 0
assert f"Farming & Prefarm reward address: {address}" in start_result.output
@ -35,7 +49,8 @@ def test_every_simulator_command() -> None:
def test_custom_farming_address() -> None:
runner: CliRunner = CliRunner()
address = burn_address
simulator_name = "ci_address_test"
starting_str = "ci_address_test"
simulator_name = get_profile_path(starting_str)
start_result: Result = runner.invoke(
cli, ["dev", "sim", "-n", simulator_name, "create", "-bm", mnemonic, "--reward-address", address]
)