Skip to content

Commit

Permalink
cleanup test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Sep 15, 2023
1 parent ee17511 commit d0ff507
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 124 deletions.
46 changes: 0 additions & 46 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,29 +1253,6 @@ def transfer_tokens(self, from_, to, amount, **kwargs):
)
)

def ica_register_account(self, connid, **kwargs):
"execute on host chain to attach an account to the connection"
default_kwargs = {
"home": self.data_dir,
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
}
rsp = json.loads(
self.raw(
"tx",
"ica",
"controller",
"register",
connid,
"-y",
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def icaauth_register_account(self, connid, **kwargs):
"execute on host chain to attach an account to the connection"
default_kwargs = {
Expand All @@ -1298,29 +1275,6 @@ def icaauth_register_account(self, connid, **kwargs):
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def ica_submit_tx(self, connid, tx, **kwargs):
default_kwargs = {
"home": self.data_dir,
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
}
rsp = json.loads(
self.raw(
"tx",
"ica",
"controller",
"send-tx",
connid,
tx,
"-y",
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def icaauth_submit_tx(self, connid, tx, **kwargs):
default_kwargs = {
"home": self.data_dir,
Expand Down
166 changes: 94 additions & 72 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,87 @@ class IBCNetwork(NamedTuple):
proc: subprocess.Popen[bytes] | None


def call_hermes_cmd(
hermes,
connection_only,
incentivized,
version,
):
if connection_only:
subprocess.check_call(
[
"hermes",
"--config",
hermes.configpath,
"create",
"connection",
"--a-chain",
"cronos_777-1",
"--b-chain",
"chainmain-1",
]
)
else:
subprocess.check_call(
[
"hermes",
"--config",
hermes.configpath,
"create",
"channel",
"--a-port",
"transfer",
"--b-port",
"transfer",
"--a-chain",
"cronos_777-1",
"--b-chain",
"chainmain-1",
"--new-client-connection",
"--yes",
]
+ (
[
"--channel-version",
json.dumps(version),
]
if incentivized
else []
)
)


def call_rly_cmd(path, version):
cmd = [
"rly",
"pth",
"new",
"chainmain-1",
"cronos_777-1",
"chainmain-cronos",
"--home",
str(path),
]
subprocess.check_call(cmd)
cmd = [
"rly",
"tx",
"connect",
"chainmain-cronos",
"--src-port",
"transfer",
"--dst-port",
"transfer",
"--order",
"unordered",
"--version",
json.dumps(version),
"--home",
str(path),
]
subprocess.check_call(cmd)


def prepare_network(
tmp_path,
file,
Expand All @@ -41,6 +122,10 @@ def prepare_network(
connection_only=False,
relayer=cluster.Relayer.HERMES.value,
):
print("incentivized", incentivized)
print("is_relay", is_relay)
print("connection_only", connection_only)
print("relayer", relayer)
is_hermes = relayer == cluster.Relayer.HERMES.value
hermes = None
file = f"configs/{file}.jsonnet"
Expand All @@ -57,81 +142,18 @@ def prepare_network(
wait_for_port(ports.grpc_port(cronos.base_port(0))) # cronos grpc

version = {"fee_version": "ics29-1", "app_version": "ics20-1"}
incentivized_args = (
[
"--channel-version",
json.dumps(version),
]
if incentivized
else []
)
path = cronos.base_dir.parent / "relayer"
if is_hermes:
hermes = Hermes(cronos.base_dir.parent / "relayer.toml")
if connection_only:
subprocess.check_call(
[
"hermes",
"--config",
hermes.configpath,
"create",
"connection",
"--a-chain",
"cronos_777-1",
"--b-chain",
"chainmain-1",
]
)
else:
subprocess.check_call(
[
"hermes",
"--config",
hermes.configpath,
"create",
"channel",
"--a-port",
"transfer",
"--b-port",
"transfer",
"--a-chain",
"cronos_777-1",
"--b-chain",
"chainmain-1",
"--new-client-connection",
"--yes",
]
+ incentivized_args
)
hermes = Hermes(path.with_suffix(".toml"))
call_hermes_cmd(
hermes,
connection_only,
incentivized,
version,
)
else:
cmd = [
"rly",
"pth",
"new",
"chainmain-1",
"cronos_777-1",
"chainmain-cronos",
"--home",
str(path),
]
subprocess.check_call(cmd)
cmd = [
"rly",
"tx",
"connect",
"chainmain-cronos",
"--src-port",
"transfer",
"--dst-port",
"transfer",
"--order",
"unordered",
"--version",
json.dumps(version),
"--home",
str(path),
]
subprocess.check_call(cmd)
call_rly_cmd(path, version)

proc = None
if incentivized:
# register fee payee
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def ibc(request, tmp_path_factory):
incentivized = request.param
name = "ibc"
path = tmp_path_factory.mktemp(name)
network = prepare_network(path, name, incentivized)
network = prepare_network(path, name, incentivized=incentivized)
yield from network


Expand Down
3 changes: 0 additions & 3 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def ibc(request, tmp_path_factory):
for network in prepare_network(
path,
"ibc",
incentivized=True,
is_relay=True,
connection_only=False,
relayer=cluster.Relayer.RLY.value,
):
if network.proc:
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_ibc_update_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def ibc(request, tmp_path_factory):
"prepare-network"
name = "ibc"
path = tmp_path_factory.mktemp(name)
network = prepare_network(path, name, True, False)
network = prepare_network(path, name, is_relay=False)
yield from network


Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def ibc(request, tmp_path_factory):
"prepare-network"
name = "ibc"
path = tmp_path_factory.mktemp(name)
network = prepare_network(path, name, connection_only=True)
network = prepare_network(path, name, incentivized=False, connection_only=True)
yield from network


Expand Down

0 comments on commit d0ff507

Please sign in to comment.