Skip to content

Commit

Permalink
revert integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Dec 5, 2024
1 parent 8809e23 commit 3cf9150
Show file tree
Hide file tree
Showing 10 changed files with 1,169 additions and 1,495 deletions.
35 changes: 0 additions & 35 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,41 +1437,6 @@ def ica_query_account(self, connid, owner, **kwargs):
)
)

def icaauth_register_account(self, connid, event_query_tx=True, **kwargs):
default_kwargs = {
"home": self.data_dir,
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
}
args = ["icaauth", "register-account"]
rsp = json.loads(
self.raw(
"tx",
*args,
connid,
"-y",
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0 and event_query_tx:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def icaauth_query_account(self, connid, owner, **kwargs):
default_kwargs = {
"node": self.node_rpc,
"output": "json",
}
args = ["icaauth", "interchain-account-address", connid, owner]
return json.loads(
self.raw(
"q",
*args,
**(default_kwargs | kwargs),
)
)

def query_ica_params(self, **kwargs):
default_kwargs = {
"node": self.node_rpc,
Expand Down
4 changes: 0 additions & 4 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ def prepare_network(
grantee=None,
need_relayer_caller=False,
relayer=cluster.Relayer.HERMES.value,
post_init=None,
chain_binary=None,
):
print("incentivized", incentivized)
print("is_relay", is_relay)
Expand All @@ -164,8 +162,6 @@ def prepare_network(
tmp_path,
26700,
Path(__file__).parent / file,
post_init=post_init,
chain_binary=chain_binary,
relayer=relayer,
) as cronos:
cli = cronos.cosmos_cli()
Expand Down
10 changes: 1 addition & 9 deletions integration_tests/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,7 @@ def setup_custom_cronos(
if wait_port:
wait_for_port(ports.evmrpc_port(base_port))
wait_for_port(ports.evmrpc_ws_port(base_port))
chain_binary = (
"cronosd"
if chain_binary is None
else next(
(b.strip() for b in chain_binary.split(",") if "cronosd" in b),
"cronosd",
)
)
c = Cronos(path / "cronos_777-1", chain_binary=chain_binary)
c = Cronos(path / "cronos_777-1", chain_binary=chain_binary or "cronosd")
w3_wait_for_block(c.w3, 1)
yield c
finally:
Expand Down
2,425 changes: 1,076 additions & 1,349 deletions integration_tests/poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration_tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ eth-bloom = "^3.0"
eth-hash = "^0"
pyyaml = "^6.0.2rc1"
pytest-timeout = "^2.3.1"
rpds-py = "0.17.1"

[tool.poetry.dev-dependencies]

Expand Down
93 changes: 86 additions & 7 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
import pytest
import requests
from pystarport import ports
from pystarport.cluster import SUPERVISOR_CONFIG_FILE

from .network import Cronos, setup_custom_cronos
from .utils import (
ADDRS,
CONTRACTS,
approve_proposal,
assert_gov_params,
deploy_contract,
do_upgrade,
edit_ini_sections,
get_consensus_params,
get_send_enable,
post_init,
send_transaction,
wait_for_block,
wait_for_new_blocks,
wait_for_port,
)
Expand All @@ -42,6 +44,42 @@ def get_txs(base_port, end):
return res


def init_cosmovisor(home):
"""
build and setup cosmovisor directory structure in each node's home directory
"""
cosmovisor = home / "cosmovisor"
cosmovisor.mkdir()
(cosmovisor / "upgrades").symlink_to("../../../upgrades")
(cosmovisor / "genesis").symlink_to("./upgrades/genesis")


def post_init(path, base_port, config):
"""
prepare cosmovisor for each node
"""
chain_id = "cronos_777-1"
data = path / chain_id
cfg = json.loads((data / "config.json").read_text())
for i, _ in enumerate(cfg["validators"]):
home = data / f"node{i}"
init_cosmovisor(home)

edit_ini_sections(
chain_id,
data / SUPERVISOR_CONFIG_FILE,
lambda i, _: {
"command": f"cosmovisor run start --home %(here)s/node{i}",
"environment": (
"DAEMON_NAME=cronosd,"
"DAEMON_SHUTDOWN_GRACE=1m,"
"UNSAFE_SKIP_BACKUP=true,"
f"DAEMON_HOME=%(here)s/node{i}"
),
},
)


def setup_cronos_test(tmp_path_factory):
path = tmp_path_factory.mktemp("upgrade")
port = 26200
Expand Down Expand Up @@ -125,11 +163,52 @@ def exec(c, tmp_path_factory):
wait_for_port(ports.evmrpc_port(base_port))
wait_for_new_blocks(cli, 1)

def do_upgrade(plan_name, target, mode=None):
print(f"upgrade {plan_name} height: {target}")
if plan_name == "v1.4.0-rc5-testnet":
rsp = cli.software_upgrade(
"community",
{
"name": plan_name,
"title": "upgrade test",
"note": "ditto",
"upgrade-height": target,
"summary": "summary",
"deposit": "10000basetcro",
},
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp["events"])
else:
rsp = cli.gov_propose_legacy(
"community",
"software-upgrade",
{
"name": plan_name,
"title": "upgrade test",
"description": "ditto",
"upgrade-height": target,
"deposit": "10000basetcro",
},
mode=mode,
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp["logs"][0]["events"])

# update cli chain binary
c.chain_binary = (
Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd"
)
# block should pass the target height
wait_for_block(c.cosmos_cli(), target + 2, timeout=480)
wait_for_port(ports.rpc_port(base_port))
return c.cosmos_cli()

# test migrate keystore
cli.migrate_keystore()
height = cli.block_height()
target_height0 = height + 15
cli = do_upgrade(c, "v1.1.0", target_height0, "block")
cli = do_upgrade("v1.1.0", target_height0, "block")
check_basic_tx(c)

height = cli.block_height()
Expand All @@ -152,7 +231,7 @@ def exec(c, tmp_path_factory):
)
print("old values", old_height, old_balance, old_base_fee)

cli = do_upgrade(c, "v1.2", target_height1)
cli = do_upgrade("v1.2", target_height1)
check_basic_tx(c)

# deploy contract should still work
Expand Down Expand Up @@ -208,11 +287,11 @@ def exec(c, tmp_path_factory):

height = cli.block_height()
txs = get_txs(base_port, height)
cli = do_upgrade(c, "v1.3", height + 15)
cli = do_upgrade("v1.3", height + 15)
assert txs == get_txs(base_port, height)

gov_param = cli.query_params("gov")
cli = do_upgrade(c, "v1.4", cli.block_height() + 15)
cli = do_upgrade("v1.4", cli.block_height() + 15)

assert_evm_params(cli, e0, target_height0 - 1)
assert_evm_params(cli, e1, target_height1 - 1)
Expand All @@ -223,7 +302,7 @@ def exec(c, tmp_path_factory):
cli.query_params("icaauth")
assert_gov_params(cli, gov_param)

cli = do_upgrade(c, "v1.4.0-rc5-testnet", cli.block_height() + 15)
cli = do_upgrade("v1.4.0-rc5-testnet", cli.block_height() + 15)
check_basic_tx(c)


Expand Down
82 changes: 1 addition & 81 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
from eth_account import Account
from eth_utils import abi, to_checksum_address
from hexbytes import HexBytes
from pystarport import ledger, ports
from pystarport.cluster import SUPERVISOR_CONFIG_FILE
from pystarport import ledger
from web3._utils.contracts import abi_to_signature, find_matching_event_abi
from web3._utils.events import get_event_data
from web3._utils.method_formatters import receipt_formatter
Expand Down Expand Up @@ -787,82 +786,3 @@ def assert_gov_params(cli, old_param):
expedited_param = get_expedited_params(old_param)
for key, value in expedited_param.items():
assert param[key] == value, param


def init_cosmovisor(home):
"""
build and setup cosmovisor directory structure in each node's home directory
"""
cosmovisor = home / "cosmovisor"
cosmovisor.mkdir()
(cosmovisor / "upgrades").symlink_to("../../../upgrades")
(cosmovisor / "genesis").symlink_to("./upgrades/genesis")


def post_init(path, base_port, config):
"""
prepare cosmovisor for each node
"""
chain_id = "cronos_777-1"
data = path / chain_id
cfg = json.loads((data / "config.json").read_text())
for i, _ in enumerate(cfg["validators"]):
home = data / f"node{i}"
init_cosmovisor(home)

edit_ini_sections(
chain_id,
data / SUPERVISOR_CONFIG_FILE,
lambda i, _: {
"command": f"cosmovisor run start --home %(here)s/node{i}",
"environment": (
"DAEMON_NAME=cronosd,"
"DAEMON_SHUTDOWN_GRACE=1m,"
"UNSAFE_SKIP_BACKUP=true,"
f"DAEMON_HOME=%(here)s/node{i}"
),
},
)


def do_upgrade(c, plan_name, target, mode=None):
print(f"upgrade {plan_name} height: {target}")
cli = c.cosmos_cli()
if plan_name == "v1.4.0-rc5-testnet":
rsp = cli.software_upgrade(
"community",
{
"name": plan_name,
"title": "upgrade test",
"note": "ditto",
"upgrade-height": target,
"summary": "summary",
"deposit": "10000basetcro",
},
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp["events"])
else:
rsp = cli.gov_propose_legacy(
"community",
"software-upgrade",
{
"name": plan_name,
"title": "upgrade test",
"description": "ditto",
"upgrade-height": target,
"deposit": "10000basetcro",
},
mode=mode,
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp["logs"][0]["events"])

# update cli chain binary
c.chain_binary = (
Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd"
)
# block should pass the target height
wait_for_block(c.cosmos_cli(), target + 2, timeout=480)
wait_for_port(ports.rpc_port(c.base_port(0)))
return c.cosmos_cli()
4 changes: 2 additions & 2 deletions nix/rocksdb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

stdenv.mkDerivation (finalAttrs: {
pname = "rocksdb";
version = "9.8.4";
version = "9.7.4";

src = fetchFromGitHub {
owner = "facebook";
repo = finalAttrs.pname;
rev = "v${finalAttrs.version}";
hash = "sha256-A6Gx4FqoGlxITUUz9k6tkDjUcLtMUBK9JS8vuAS96H0=";
hash = "sha256-u5uuShM2SxHc9/zL4UU56IhCcR/ZQbzde0LgOYS44bM=";
};

nativeBuildInputs = [
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
"homepage": "",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "f554d27c1544d9c56e5f1f8e2b8aff399803674e",
"sha256": "04nvlp0lp2kxycdywq0avzxpvyj69iij8xvl6havjmpm26dpbcqp",
"rev": "4eb2ac54029af42a001c9901194e9ce19cbd8a40",
"sha256": "16fi71fpywiqsya1z99kkb14dansyrmkkrb2clzs3b5qqx673wf4",
"type": "tarball",
"url": "https://github.com/nix-community/poetry2nix/archive/f554d27c1544d9c56e5f1f8e2b8aff399803674e.tar.gz",
"url": "https://github.com/nix-community/poetry2nix/archive/4eb2ac54029af42a001c9901194e9ce19cbd8a40.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"relayer": {
Expand Down
4 changes: 0 additions & 4 deletions nix/testenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ poetry2nix.mkPoetryEnv {
flake8-isort = [ "hatchling" ];
pyunormalize = [ "setuptools" ];
eth-bloom = [ "setuptools" ];
docker = [
"hatchling"
"hatch-vcs"
];
};
in
lib.mapAttrs (
Expand Down

0 comments on commit 3cf9150

Please sign in to comment.