From 34286218981c0ea034c0acfe2a1fcd0e4d1853a4 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 26 Oct 2023 10:53:03 +0800 Subject: [PATCH 1/3] Problem: update voting_period is not tested --- integration_tests/cosmoscli.py | 17 +++++++++++++++++ integration_tests/test_gov.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 645b38afd..1fe262cca 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -186,6 +186,20 @@ def query_host_params(self): ) ) + def query_gov_params(self): + kwargs = { + "node": self.node_rpc, + "output": "json", + } + return json.loads( + self.raw( + "q", + "gov", + "params", + **kwargs, + ) + ) + class ClusterCLI(cluster.ClusterCLI): def __init__(self, *args, **kwargs): @@ -213,3 +227,6 @@ def sign_batch_multisig_tx(self, *args, i=0, **kwargs): def query_host_params(self, i=0): return self.cosmos_cli(i).query_host_params() + + def query_gov_params(self, i=0): + return self.cosmos_cli(i).query_gov_params() diff --git a/integration_tests/test_gov.py b/integration_tests/test_gov.py index b2bb950a3..e44c66c22 100644 --- a/integration_tests/test_gov.py +++ b/integration_tests/test_gov.py @@ -310,7 +310,7 @@ def test_inherit_vote(cluster): def test_host_enabled(cluster): cli = cluster.cosmos_cli() - p = cluster.cosmos_cli().query_host_params() + p = cli.query_host_params() assert p["host_enabled"] rsp = cluster.gov_propose_legacy( "community", @@ -331,3 +331,35 @@ def test_host_enabled(cluster): approve_proposal(cluster, rsp) p = cli.query_host_params() assert not p["host_enabled"] + + +def test_gov_voting(cluster): + """ + - change voting_period from default 10s to 216s + """ + cli = cluster.cosmos_cli() + + def assert_voting_period(voting_period_in_ns): + p = cli.query_gov_params() + assert p["voting_params"]["voting_period"] == voting_period_in_ns + + assert_voting_period("10000000000") + voting_period_in_ns = "216000000000" + rsp = cluster.gov_propose_legacy( + "community", + "param-change", + { + "title": "Update gov voting", + "description": "ditto", + "changes": [ + { + "subspace": "gov", + "key": "votingparams", + "value": {"voting_period": voting_period_in_ns}, + } + ], + }, + ) + assert rsp["code"] == 0, rsp["raw_log"] + approve_proposal(cluster, rsp) + assert_voting_period(voting_period_in_ns) From 3bff57eb51ce3037a798b55ef545315b92b16b26 Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 15 Aug 2024 16:27:12 +0800 Subject: [PATCH 2/3] Apply suggestions from code review Signed-off-by: yihuang --- integration_tests/cosmoscli.py | 2 +- integration_tests/test_gov.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 2c1e37612..c7bb5fa59 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -370,4 +370,4 @@ def query_host_params(self, i=0): return self.cosmos_cli(i).query_host_params() def query_params(self, mod, i=0): - return self.cosmos_cli(i).query_params(mod) \ No newline at end of file + return self.cosmos_cli(i).query_params(mod) diff --git a/integration_tests/test_gov.py b/integration_tests/test_gov.py index 4eb67adff..cf6ae3331 100644 --- a/integration_tests/test_gov.py +++ b/integration_tests/test_gov.py @@ -256,7 +256,7 @@ def test_gov_voting(cluster): cli = cluster.cosmos_cli() def assert_voting_period(voting_period_in_ns): - p = cli.query_gov_params() + p = cli.query_params("gov") assert p["voting_params"]["voting_period"] == voting_period_in_ns assert_voting_period("10000000000") From 2d7d5815b378f05f41026749a64ea9306a9a7540 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 15 Aug 2024 17:14:29 +0800 Subject: [PATCH 3/3] fix test --- integration_tests/test_gov.py | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/integration_tests/test_gov.py b/integration_tests/test_gov.py index cf6ae3331..e9b8e1248 100644 --- a/integration_tests/test_gov.py +++ b/integration_tests/test_gov.py @@ -249,33 +249,33 @@ def test_host_enabled(cluster, tmp_path): assert not p["host_enabled"] -def test_gov_voting(cluster): +def test_gov_voting(cluster, tmp_path): """ - - change voting_period from default 10s to 216s + - change voting_period from default 10s to 3m36s """ cli = cluster.cosmos_cli() - - def assert_voting_period(voting_period_in_ns): - p = cli.query_params("gov") - assert p["voting_params"]["voting_period"] == voting_period_in_ns - - assert_voting_period("10000000000") - voting_period_in_ns = "216000000000" - rsp = cluster.gov_propose_legacy( - "community", - "param-change", - { - "title": "Update gov voting", - "description": "ditto", - "changes": [ - { - "subspace": "gov", - "key": "votingparams", - "value": {"voting_period": voting_period_in_ns}, - } - ], - }, - ) + p = cli.query_params("gov") + assert p["params"]["voting_period"] == "10s" + updated = "3m36s" + p["params"]["voting_period"] = updated + proposal = tmp_path / "proposal.json" + authority = module_address("gov") + type = "/cosmos.gov.v1.MsgUpdateParams" + proposal_src = { + "messages": [ + { + "@type": type, + "authority": authority, + "params": p["params"], + } + ], + "deposit": "10000000basecro", + "title": "title", + "summary": "summary", + } + proposal.write_text(json.dumps(proposal_src)) + rsp = cluster.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cluster, rsp) - assert_voting_period(voting_period_in_ns) + approve_proposal(cluster, rsp, msg=f",{type}") + p = cli.query_params("gov") + assert p["params"]["voting_period"] == updated