Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: no doc for subspace param update #1345

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,31 @@ def gov_vote(self, voter, proposal_id, option, event_query_tx=True, **kwargs):
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def gov_deposit(self, depositor, proposal_id, amount):
def query_host_params(self):
kwargs = {
"node": self.node_rpc,
"output": "json",
}
return json.loads(
self.raw(
"q",
"interchain-accounts",
"controller",
"params",
**kwargs,
)
)

def gov_deposit(
self,
depositor,
proposal_id,
amount,
event_query_tx=True,
**kwargs,
):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
rsp = json.loads(
self.raw(
"tx",
"gov",
Expand All @@ -777,8 +800,12 @@ def gov_deposit(self, depositor, proposal_id, amount):
node=self.node_rpc,
keyring_backend="test",
chain_id=self.chain_id,
**kwargs,
)
)
if rsp["code"] == 0 and event_query_tx:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def query_proposals(self, depositor=None, limit=None, status=None, voter=None):
return json.loads(
Expand Down
92 changes: 92 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import subprocess
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import timedelta
from pathlib import Path

import pytest
import web3
from dateutil.parser import isoparse
from eth_bloom import BloomFilter
from eth_utils import abi, big_endian_to_int
from hexbytes import HexBytes
Expand All @@ -30,11 +32,101 @@
send_txs,
submit_any_proposal,
wait_for_block,
wait_for_block_time,
wait_for_new_blocks,
wait_for_port,
)


def find_log_event_attrs(logs, ev_type, cond=None):
for ev in logs[0]["events"]:
if ev["type"] == ev_type:
attrs = {attr["key"]: attr["value"] for attr in ev["attributes"]}
if cond is None or cond(attrs):
return attrs
return None


def get_proposal_id(rsp):
def cb(attrs):
return "proposal_id" in attrs

msg = ",/cosmos.gov.v1.MsgExecLegacyContent"
ev = find_log_event_attrs(rsp["logs"], "submit_proposal", cb)
assert ev["proposal_messages"] == msg, rsp
return ev["proposal_id"]


def approve_proposal_legacy(
node,
rsp,
vote_option="yes",
):
cluster = node.cosmos_cli()
proposal_id = get_proposal_id(rsp)
proposal = cluster.query_proposal(proposal_id)
assert proposal["status"] == "PROPOSAL_STATUS_DEPOSIT_PERIOD", proposal
amount = cluster.balance(cluster.address("community"))
rsp = cluster.gov_deposit("community", proposal_id, "1basetcro")
assert rsp["code"] == 0, rsp["raw_log"]
proposal = cluster.query_proposal(proposal_id)
assert proposal["status"] == "PROPOSAL_STATUS_VOTING_PERIOD", proposal

if vote_option is not None:
rsp = node.cosmos_cli(0).gov_vote("validator", proposal_id, vote_option)
assert rsp["code"] == 0, rsp["raw_log"]
rsp = node.cosmos_cli(1).gov_vote("validator", proposal_id, vote_option)
assert rsp["code"] == 0, rsp["raw_log"]
assert (
int(cluster.query_tally(proposal_id)[vote_option + "_count"])
== cluster.staking_pool()
), "all voted"
else:
assert cluster.query_tally(proposal_id) == {
"yes_count": "0",
"no_count": "0",
"abstain_count": "0",
"no_with_veto_count": "0",
}

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
return amount


def test_ica_enabled(cronos):
cli = cronos.cosmos_cli()
p = cli.query_host_params()
assert p["controller_enabled"]
rsp = cli.gov_propose_legacy(
"community",
"param-change",
{
"title": "Update icacontroller enabled",
"description": "ditto",
"changes": [
{
"subspace": "icacontroller",
"key": "ControllerEnabled",
"value": False,
}
],
},
mode="sync",
)
rsp = cli.event_query_tx_for(rsp["txhash"])

Check failure on line 123 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / integration_tests (unmarked)

test_ica_enabled[True] AssertionError: (cronosd query event-query-tx-for 73DC0885C0B621E4E4CD32D62F7BFD28B39DEEAAE0B3A770153960875FAF3D6B -y --home /tmp/pytest-of-runner/pytest-0/indexer0/cronos_777-1/node0)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal_legacy(cronos, rsp)
p = cli.query_host_params()
assert not p["controller_enabled"]


def test_basic(cluster):
w3 = cluster.w3
assert w3.eth.chain_id == 777
Expand Down
Loading