From 00bf7904b2b59b01876766018e2d2b5454c45f26 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 24 Oct 2023 12:44:57 +0800 Subject: [PATCH] Problem: update icahost enabled is not tested --- integration_tests/cosmoscli.py | 18 ++++++++++ integration_tests/test_basic.py | 60 ++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index fbeec6f97..0fcaa70d1 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -170,6 +170,21 @@ def sign_batch_multisig_tx( node=self.node_rpc, ) return r.decode("utf-8") + + def query_host_params(self): + kwargs = { + "node": self.node_rpc, + "output": "json", + } + return json.loads( + self.raw( + "q", + "interchain-accounts", + "host", + "params", + **kwargs, + ) + ) class ClusterCLI(cluster.ClusterCLI): @@ -195,3 +210,6 @@ def transfer(self, from_, to, coins, i=0, generate_only=False, **kwargs): def sign_batch_multisig_tx(self, *args, i=0, **kwargs): return self.cosmos_cli(i).sign_batch_multisig_tx(*args, **kwargs) + + def query_host_params(self, i=0): + return self.cosmos_cli(i).query_host_params() diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index d041165ab..41bc55d32 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -1,6 +1,8 @@ +from datetime import timedelta import pytest -from .utils import wait_for_block +from dateutil.parser import isoparse +from .utils import parse_events, wait_for_block, wait_for_block_time, wait_for_new_blocks pytestmark = pytest.mark.normal @@ -108,3 +110,59 @@ def test_statesync(cluster): # discovery_time is set to 5 seconds, add extra seconds for processing wait_for_block(cluster.cosmos_cli(i), 10) print("succesfully syncing") + + +def test_host_enabled(cluster, tmp_path): + cli = cluster.cosmos_cli() + p = cluster.cosmos_cli().query_host_params() + default_param = {"host_enabled": True, "allow_messages": []} + assert p == default_param, "unexpected default" + changes = [ + { + "subspace": "icahost", + "key": "HostEnabled", + "value": False, + } + ] + + rsp = cluster.gov_propose_legacy( + "community", + "param-change", + { + "title": "Update icahost enabled", + "description": "ditto", + "changes": changes, + }, + ) + assert rsp["code"] == 0, rsp["raw_log"] + + # get proposal_id + ev = parse_events(rsp["logs"])["submit_proposal"] + assert ev["proposal_messages"] == ",/cosmos.gov.v1.MsgExecLegacyContent", rsp + proposal_id = ev["proposal_id"] + + proposal = cluster.query_proposal(proposal_id) + assert proposal["status"] == "PROPOSAL_STATUS_DEPOSIT_PERIOD", proposal + + amount = cluster.balance(cluster.address("ecosystem")) + rsp = cluster.gov_deposit("ecosystem", proposal_id, "1cro") + assert rsp["code"] == 0, rsp["raw_log"] + assert cluster.balance(cluster.address("ecosystem")) == amount - 100000000 + + proposal = cluster.query_proposal(proposal_id) + assert proposal["status"] == "PROPOSAL_STATUS_VOTING_PERIOD", proposal + + + for i in range(len(cluster.config["validators"])): + rsp = cluster.cosmos_cli(i).gov_vote("validator", proposal_id, "yes") + assert rsp["code"] == 0, rsp["raw_log"] + + wait_for_block_time( + cluster, isoparse(proposal["voting_end_time"]) + timedelta(seconds=5) + ) + + proposal = cluster.query_proposal(proposal_id) + assert proposal["status"] == "PROPOSAL_STATUS_PASSED", proposal + + p = cli.query_host_params() + assert p["host_enabled"] == False \ No newline at end of file