Skip to content

Commit

Permalink
Problem: update icahost enabled is not tested
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 24, 2023
1 parent 648decd commit 169b726
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 23 deletions.
18 changes: 18 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ def sign_batch_multisig_tx(
)
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):
def __init__(self, *args, **kwargs):
Expand All @@ -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()
64 changes: 41 additions & 23 deletions integration_tests/test_gov.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,33 @@ def test_param_proposal(cluster, vote_option):
},
)
assert rsp["code"] == 0, rsp["raw_log"]
amount = approve_proposal(cluster, rsp, vote_option)
new_max_validators = cluster.staking_params()["max_validators"]
if vote_option == "yes":
assert new_max_validators == max_validators + 1
else:
assert new_max_validators == max_validators

if vote_option == "no_with_veto":
# deposit only get burnt for vetoed proposal
assert cluster.balance(cluster.address("ecosystem")) == amount - 100000000
else:
# refunded, no matter passed or rejected
assert cluster.balance(cluster.address("ecosystem")) == amount


def approve_proposal(cluster, rsp, vote_option="yes"):
# 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["messages"][0]["content"]["changes"] == [
{
"subspace": "staking",
"key": "MaxValidators",
"value": str(max_validators + 1),
}
], proposal
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

Expand All @@ -78,25 +84,12 @@ def test_param_proposal(cluster, vote_option):
wait_for_block_time(
cluster, isoparse(proposal["voting_end_time"]) + timedelta(seconds=5)
)

proposal = cluster.query_proposal(proposal_id)
if vote_option == "yes":
assert proposal["status"] == "PROPOSAL_STATUS_PASSED", proposal
else:
assert proposal["status"] == "PROPOSAL_STATUS_REJECTED", proposal

new_max_validators = cluster.staking_params()["max_validators"]
if vote_option == "yes":
assert new_max_validators == max_validators + 1
else:
assert new_max_validators == max_validators

if vote_option == "no_with_veto":
# deposit only get burnt for vetoed proposal
assert cluster.balance(cluster.address("ecosystem")) == amount - 100000000
else:
# refunded, no matter passed or rejected
assert cluster.balance(cluster.address("ecosystem")) == amount
return amount


def test_deposit_period_expires(cluster):
Expand Down Expand Up @@ -313,3 +306,28 @@ def test_inherit_vote(cluster):
"abstain_count": "0",
"no_with_veto_count": "0",
}


def test_host_enabled(cluster):
cli = cluster.cosmos_cli()
p = cluster.cosmos_cli().query_host_params()
assert p["host_enabled"]
rsp = cluster.gov_propose_legacy(
"community",
"param-change",
{
"title": "Update icahost enabled",
"description": "ditto",
"changes": [
{
"subspace": "icahost",
"key": "HostEnabled",
"value": False,
}
],
},
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(cluster, rsp)
p = cli.query_host_params()
assert not p["host_enabled"]

0 comments on commit 169b726

Please sign in to comment.