Skip to content

Commit 27c4733

Browse files
committed
fix upgrade
1 parent e56bd17 commit 27c4733

File tree

5 files changed

+25
-33
lines changed

5 files changed

+25
-33
lines changed

tests/integration_tests/configs/cosmovisor.jsonnet

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ config {
66
'minimum-gas-prices': '100000000000aphoton',
77
},
88
genesis+: {
9+
consensus_params: {
10+
block: {
11+
max_bytes: '1048576',
12+
max_gas: '81500000',
13+
},
14+
},
915
app_state+: {
1016
feemarket+: {
1117
params+: {
1218
base_fee:: super.base_fee,
1319
},
1420
},
1521
gov: {
16-
voting_params: {
22+
params: {
1723
voting_period: '10s',
18-
},
19-
deposit_params: {
2024
max_deposit_period: '10s',
2125
min_deposit: [
2226
{

tests/integration_tests/cosmoscli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,10 @@ def edit_validator(
640640
)
641641
)
642642

643-
def gov_propose(self, proposer, kind, proposal, **kwargs):
644-
method = "submit-proposal"
643+
def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
644+
method = "submit-legacy-proposal"
645645
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
646-
kwargs.setdefault("broadcast_mode", "block")
646+
kwargs.setdefault("gas", DEFAULT_GAS)
647647
if kind == "software-upgrade":
648648
return json.loads(
649649
self.raw(
@@ -653,6 +653,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs):
653653
kind,
654654
proposal["name"],
655655
"-y",
656+
"--no-validate",
656657
from_=proposer,
657658
# content
658659
title=proposal.get("title"),
@@ -706,7 +707,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs):
706707
def gov_vote(self, voter, proposal_id, option, **kwargs):
707708
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
708709
kwargs.setdefault("broadcast_mode", "sync")
709-
return json.loads(
710+
rsp = json.loads(
710711
self.raw(
711712
"tx",
712713
"gov",
@@ -719,6 +720,9 @@ def gov_vote(self, voter, proposal_id, option, **kwargs):
719720
**kwargs,
720721
)
721722
)
723+
if rsp["code"] == 0:
724+
rsp = self.event_query_tx_for(rsp["txhash"])
725+
return rsp
722726

723727
def gov_deposit(self, depositor, proposal_id, amount):
724728
return json.loads(

tests/integration_tests/test_fee_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def update_feemarket_param(node, tmp_path, new_multiplier=2, new_denominator=200
187187
proposal.write_text(json.dumps(proposal_src))
188188
rsp = cli.submit_gov_proposal(proposal, from_="community")
189189
assert rsp["code"] == 0, rsp["raw_log"]
190-
approve_proposal(node, rsp)
190+
approve_proposal(node, rsp, status=3)
191191
print("check params have been updated now")
192192
p = cli.get_params("feemarket")["params"]
193193
assert p["base_fee"] == new_base_fee

tests/integration_tests/test_upgrade.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
import json
33
import re
44
import subprocess
5-
import time
65
from pathlib import Path
76

87
import pytest
9-
from dateutil.parser import isoparse
108
from pystarport import ports
119
from pystarport.cluster import SUPERVISOR_CONFIG_FILE
1210

1311
from .network import Ethermint, setup_custom_ethermint
1412
from .utils import (
1513
ADDRS,
1614
CONTRACTS,
15+
approve_proposal,
1716
deploy_contract,
18-
parse_events,
1917
send_transaction,
2018
wait_for_block,
21-
wait_for_block_time,
2219
wait_for_port,
2320
)
2421

@@ -94,7 +91,6 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
9491
- it should work transparently
9592
- check that queries on legacy blocks still works after upgrade.
9693
"""
97-
time.sleep(6)
9894
cli = custom_ethermint.cosmos_cli()
9995
w3 = custom_ethermint.w3
10096
contract, _ = deploy_contract(w3, CONTRACTS["TestERC20A"])
@@ -108,7 +104,7 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
108104
print("upgrade height", target_height)
109105

110106
plan_name = "integration-test-upgrade"
111-
rsp = cli.gov_propose(
107+
rsp = cli.gov_propose_legacy(
112108
"community",
113109
"software-upgrade",
114110
{
@@ -120,20 +116,7 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
120116
},
121117
)
122118
assert rsp["code"] == 0, rsp["raw_log"]
123-
124-
# get proposal_id
125-
ev = parse_events(rsp["logs"])["submit_proposal"]
126-
proposal_id = ev["proposal_id"]
127-
128-
rsp = cli.gov_vote("validator", proposal_id, "yes")
129-
assert rsp["code"] == 0, rsp["raw_log"]
130-
# rsp = custom_ethermint.cosmos_cli(1).gov_vote("validator", proposal_id, "yes")
131-
# assert rsp["code"] == 0, rsp["raw_log"]
132-
133-
proposal = cli.query_proposal(proposal_id)
134-
wait_for_block_time(cli, isoparse(proposal["voting_end_time"]))
135-
proposal = cli.query_proposal(proposal_id)
136-
assert proposal["status"] == "PROPOSAL_STATUS_PASSED", proposal
119+
approve_proposal(custom_ethermint, rsp)
137120

138121
# update cli chain binary
139122
custom_ethermint.chain_binary = (

tests/integration_tests/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,9 @@ def find_log_event_attrs(events, ev_type, cond=None):
327327
return None
328328

329329

330-
def approve_proposal(n, rsp, event_query_tx=True):
330+
def approve_proposal(n, rsp, status="PROPOSAL_STATUS_PASSED"):
331331
cli = n.cosmos_cli()
332-
if event_query_tx:
333-
rsp = cli.event_query_tx_for(rsp["txhash"])
332+
rsp = cli.event_query_tx_for(rsp["txhash"])
334333
# get proposal_id
335334

336335
def cb(attrs):
@@ -342,11 +341,13 @@ def cb(attrs):
342341
rsp = n.cosmos_cli(i).gov_vote("validator", proposal_id, "yes", gas=100000)
343342
assert rsp["code"] == 0, rsp["raw_log"]
344343
wait_for_new_blocks(cli, 1)
344+
res = cli.query_tally(proposal_id)
345+
res = res.get("tally") if res.get("tally") else res
345346
assert (
346-
int(cli.query_tally(proposal_id)["tally"]["yes_count"]) == cli.staking_pool()
347+
int(res["yes_count"]) == cli.staking_pool()
347348
), "all validators should have voted yes"
348349
print("wait for proposal to be activated")
349350
proposal = cli.query_proposal(proposal_id)
350351
wait_for_block_time(cli, isoparse(proposal["voting_end_time"]))
351352
proposal = cli.query_proposal(proposal_id)
352-
assert proposal["status"] == 3, proposal
353+
assert proposal["status"] == status, proposal

0 commit comments

Comments
 (0)