-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
66 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,58 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import pytest | ||
import tomlkit | ||
from pystarport import ports | ||
|
||
from .network import setup_custom_cronos | ||
from .utils import wait_for_port | ||
|
||
|
||
def test_config_client_id(cronos): | ||
@pytest.fixture(scope="module") | ||
def custom_cronos(tmp_path_factory): | ||
path = tmp_path_factory.mktemp("cronos") | ||
yield from setup_custom_cronos( | ||
path, | ||
26800, | ||
Path(__file__).parent / "configs/default.jsonnet", | ||
) | ||
|
||
|
||
def test_config_client_id(custom_cronos): | ||
n0 = "cronos_777-1-node0" | ||
cronos.supervisorctl("stop", n0) | ||
cli = cronos.cosmos_cli(0) | ||
home = cli.data_dir | ||
file = "config/client.toml" | ||
p0 = custom_cronos.base_port(0) | ||
w3 = custom_cronos.w3 | ||
custom_cronos.supervisorctl("stop", n0) | ||
cli = custom_cronos.cosmos_cli(0) | ||
dir = cli.data_dir / "config" | ||
|
||
def edit_client_cfg(chain_id): | ||
node0 = tomlkit.parse((home / file).read_text()) | ||
client_cfg = dir / "client.toml" | ||
node0 = tomlkit.parse(client_cfg.read_text()) | ||
node0["chain-id"] = chain_id | ||
(home / file).write_text(tomlkit.dumps(node0)) | ||
client_cfg.write_text(tomlkit.dumps(node0)) | ||
|
||
def edit_gensis_cfg(chain_id): | ||
genesis_cfg = dir / "genesis.json" | ||
genesis = json.loads(genesis_cfg.read_text()) | ||
genesis["chain_id"] = chain_id | ||
genesis_cfg.write_text(json.dumps(genesis)) | ||
|
||
# empty fallback chain_id from genesis | ||
edit_client_cfg("") | ||
with pytest.raises(Exception): | ||
cronos.supervisorctl("start", n0) | ||
edit_gensis_cfg("cronos_778-1") | ||
custom_cronos.supervisorctl("start", n0) | ||
wait_for_port(ports.evmrpc_port(p0)) | ||
assert w3.eth.chain_id == 778 | ||
custom_cronos.supervisorctl("stop", n0) | ||
|
||
edit_client_cfg("cronos_777-1") | ||
cronos.supervisorctl("start", n0) | ||
wait_for_port(ports.rpc_port(cronos.base_port(0))) | ||
custom_cronos.supervisorctl("start", n0) | ||
wait_for_port(ports.evmrpc_port(p0)) | ||
assert w3.eth.chain_id == 777 | ||
|
||
wait_for_port(ports.rpc_port(p0)) | ||
# transfer without chain-id flag should work | ||
rsp = cli.transfer("signer1", cli.address("validator"), "1basetcro") | ||
assert rsp["code"] == 0, rsp["raw_log"] |