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 00bf790
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
18 changes: 18 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ def sign_batch_multisig_tx(
node=self.node_rpc,
)
return r.decode("utf-8")

Check failure on line 173 in integration_tests/cosmoscli.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/cosmoscli.py:173:1: BLK100 Black would make changes.

Check failure on line 173 in integration_tests/cosmoscli.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/cosmoscli.py:173:1: W293 blank line contains whitespace
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):
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()
60 changes: 59 additions & 1 deletion integration_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import timedelta
import pytest

Check failure on line 2 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:2:1: I003 isort expected 1 blank line in imports, found 0

from .utils import wait_for_block
from dateutil.parser import isoparse

Check failure on line 4 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:4:1: I001 isort found an import in the wrong position
from .utils import parse_events, wait_for_block, wait_for_block_time, wait_for_new_blocks

Check failure on line 5 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:5:1: F401 '.utils.wait_for_new_blocks' imported but unused

Check failure on line 5 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:5:1: I001 isort found an import in the wrong position

Check failure on line 5 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:5:20: BLK100 Black would make changes.

Check failure on line 5 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:5:89: E501 line too long (89 > 88 characters)

Check failure on line 6 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:6:1: I005 isort found an unexpected missing import

Check failure on line 6 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / lint

./integration_tests/test_basic.py:6:1: I005 isort found an unexpected missing import
pytestmark = pytest.mark.normal

Expand Down Expand Up @@ -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

0 comments on commit 00bf790

Please sign in to comment.