Skip to content

Commit

Permalink
Problem: update send_enable params in proposal is not tested (crypto-…
Browse files Browse the repository at this point in the history
…org-chain#1208)

* Problem: update send_enable params in proposal is not tested

* Apply suggestions from code review

* Apply suggestions from code review

* fix typo
  • Loading branch information
mmsqe authored Oct 13, 2023
1 parent 9693ef8 commit f48d42e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
7 changes: 3 additions & 4 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from collections import namedtuple

import bech32
import requests
from dateutil.parser import isoparse
from pystarport.utils import build_cli_args_safe, format_doc_string, interact

Expand Down Expand Up @@ -1748,6 +1747,6 @@ def event_query_tx_for(self, hash):
)
)

def consensus_params(self, port, height):
url = f"http://127.0.0.1:{port}/consensus_params?height={height}"
return requests.get(url).json()["result"]["consensus_params"]
def query_bank_send(self):
res = json.loads(self.raw("q", "bank", "send-enabled", home=self.data_dir))
return res["send_enabled"]
34 changes: 34 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
KEYS,
Greeter,
RevertTestContract,
approve_proposal,
build_batch_tx,
contract_address,
contract_path,
Expand Down Expand Up @@ -852,3 +853,36 @@ def test_replay_protection(cronos):

def test_submit_any_proposal(cronos, tmp_path):
submit_any_proposal(cronos, tmp_path)


def test_submit_send_enabled(cronos, tmp_path):
# check bank send enable
cli = cronos.cosmos_cli()
p = cli.query_bank_send()
assert len(p) == 0, "should be empty"
proposal = tmp_path / "proposal.json"
# governance module account as signer
signer = "crc10d07y265gmmuvt4z0w9aw880jnsr700jdufnyd"
send_enable = [
{"denom": "basetcro", "enabled": False},
{"denom": "stake", "enabled": True},
]
proposal_src = {
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSetSendEnabled",
"authority": signer,
"sendEnabled": send_enable,
}
],
"deposit": "1basetcro",
"title": "title",
"summary": "summary",
}
proposal.write_text(json.dumps(proposal_src))
rsp = cli.submit_gov_proposal(proposal, from_="community")
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(cronos, rsp)
print("check params have been updated now")
p = cli.query_bank_send()
assert sorted(p, key=lambda x: x["denom"]) == send_enable
3 changes: 2 additions & 1 deletion integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
approve_proposal,
deploy_contract,
edit_ini_sections,
get_consensus_params,
send_transaction,
wait_for_block,
wait_for_new_blocks,
Expand Down Expand Up @@ -160,7 +161,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
)
# check consensus params
port = ports.rpc_port(custom_cronos.base_port(0))
res = cli.consensus_params(port, w3.eth.get_block_number())
res = get_consensus_params(port, w3.eth.get_block_number())
assert res["block"]["max_gas"] == "60000000"

rsp = cli.query_params("icaauth")
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import bech32
import eth_utils
import pytest
import requests
import rlp
import toml
from dateutil.parser import isoparse
Expand Down Expand Up @@ -716,3 +717,8 @@ def get_logs_since(w3, addr, start):
"address": [addr],
}
)


def get_consensus_params(port, height):
url = f"http://127.0.0.1:{port}/consensus_params?height={height}"
return requests.get(url).json()["result"]["consensus_params"]

0 comments on commit f48d42e

Please sign in to comment.