Skip to content

Commit 4e74598

Browse files
committed
upgrade test
1 parent bec1dbc commit 4e74598

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

tests/integration_tests/configs/upgrade-test-package.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ let
88
};
99
}).defaultNix;
1010
released = (fetchFlake "crypto-org-chain/ethermint" "b216a320ac6a60b019c1cbe5a6b730856482f071").default;
11+
sdk50 = (fetchFlake "crypto-org-chain/ethermint" "21bd7ce300e825f5b58639920df142a84f4c8637").default;
1112
current = pkgs.callPackage ../../../. { };
1213
in
1314
pkgs.linkFarm "upgrade-test-package" [
1415
{ name = "genesis"; path = released; }
15-
{ name = "sdk50"; path = current; }
16+
{ name = "sdk50"; path = sdk50; }
17+
{ name = "sdk53"; path = current; }
1618
]

tests/integration_tests/cosmoscli.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,35 @@ def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
695695
)
696696
)
697697

698+
def software_upgrade(self, proposer, proposal, **kwargs):
699+
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
700+
kwargs.setdefault("gas", DEFAULT_GAS)
701+
rsp = json.loads(
702+
self.raw(
703+
"tx",
704+
"upgrade",
705+
"software-upgrade",
706+
proposal["name"],
707+
"-y",
708+
"--no-validate",
709+
from_=proposer,
710+
# content
711+
title=proposal.get("title"),
712+
note=proposal.get("note"),
713+
upgrade_height=proposal.get("upgrade-height"),
714+
upgrade_time=proposal.get("upgrade-time"),
715+
upgrade_info=proposal.get("upgrade-info"),
716+
summary=proposal.get("summary"),
717+
deposit=proposal.get("deposit"),
718+
# basic
719+
home=self.data_dir,
720+
**kwargs,
721+
)
722+
)
723+
if rsp["code"] == 0:
724+
rsp = self.event_query_tx_for(rsp["txhash"])
725+
return rsp
726+
698727
def gov_vote(self, voter, proposal_id, option, **kwargs):
699728
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
700729
kwargs.setdefault("broadcast_mode", "sync")

tests/integration_tests/test_upgrade.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,44 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint, tmp_path):
202202
]:
203203
res = contract.caller.getBlockHash(h).hex()
204204
assert f"0x{res}" == "0x" + "0" * 64, res
205+
206+
target_height = w3.eth.block_number + 10
207+
print("upgrade height", target_height)
208+
209+
plan_name = "sdk53"
210+
rsp = cli.software_upgrade(
211+
"community",
212+
{
213+
"name": plan_name,
214+
"title": "upgrade test",
215+
"note": "ditto",
216+
"upgrade-height": target_height,
217+
"summary": "summary",
218+
"deposit": "10000aphoton",
219+
},
220+
)
221+
assert rsp["code"] == 0, rsp["raw_log"]
222+
approve_proposal(custom_ethermint, rsp)
223+
224+
# update cli chain binary
225+
custom_ethermint.chain_binary = (
226+
Path(custom_ethermint.chain_binary).parent.parent.parent
227+
/ f"{plan_name}/bin/ethermintd"
228+
)
229+
cli = custom_ethermint.cosmos_cli()
230+
231+
# block should pass the target height
232+
wait_for_block(cli, target_height + 1, timeout=480)
233+
wait_for_port(ports.rpc_port(custom_ethermint.base_port(0)))
234+
235+
# check basic tx works
236+
receipt = send_transaction(
237+
custom_ethermint.w3,
238+
{
239+
"to": ADDRS["community"],
240+
"value": 1000,
241+
"maxFeePerGas": 10000000000000,
242+
"maxPriorityFeePerGas": 10000,
243+
},
244+
)
245+
assert receipt.status == 1

0 commit comments

Comments
 (0)