Skip to content

Commit 41ef44c

Browse files
committed
test both
1 parent 020f73f commit 41ef44c

File tree

8 files changed

+298
-17
lines changed

8 files changed

+298
-17
lines changed

integration_tests/configs/cosmovisor.jsonnet

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ config {
1010
genesis+: {
1111
app_state+: {
1212
bank+: {
13-
send_enabled+: [
13+
params: {
14+
send_enabled: [
1415
{
1516
denom: 'stake',
1617
enabled: true,
@@ -21,12 +22,27 @@ config {
2122
},
2223
],
2324
},
25+
},
2426
feemarket+: {
2527
params+: {
2628
no_base_fee: false,
2729
base_fee:: super.base_fee,
2830
},
2931
},
32+
gov: {
33+
voting_params: {
34+
voting_period: '10s',
35+
},
36+
deposit_params: {
37+
max_deposit_period: '10s',
38+
min_deposit: [
39+
{
40+
denom: 'basetcro',
41+
amount: '1',
42+
},
43+
],
44+
},
45+
},
3046
},
3147
},
3248
},
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local config = import 'default.jsonnet';
2+
3+
config {
4+
'cronos_777-1'+: {
5+
'app-config'+: {
6+
'app-db-backend': 'rocksdb',
7+
'minimum-gas-prices': '100000000000basetcro',
8+
'iavl-lazy-loading':: super['iavl-lazy-loading'],
9+
},
10+
genesis+: {
11+
app_state+: {
12+
bank+: {
13+
send_enabled+: [
14+
{
15+
denom: 'stake',
16+
enabled: true,
17+
},
18+
{
19+
denom: 'basetcro',
20+
enabled: false,
21+
},
22+
],
23+
},
24+
feemarket+: {
25+
params+: {
26+
no_base_fee: false,
27+
base_fee:: super.base_fee,
28+
},
29+
},
30+
},
31+
},
32+
},
33+
}

integration_tests/configs/upgrade-test-package.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ let
77
shortRev = builtins.substring 0 7 rev;
88
};
99
}).defaultNix;
10-
# v1.1.0-rc1
11-
released = (fetchFlake "crypto-org-chain/cronos" "e61acd9193ac455098987e578ee6374ecc249836").default;
10+
# v1.0.12
11+
released = (fetchFlake "crypto-org-chain/cronos" "a54d8a9659a98b917d3fc1ae39489fbc0699df60").default;
1212
current = pkgs.callPackage ../../. { };
1313
in
1414
pkgs.linkFarm "upgrade-test-package" [
1515
{ name = "genesis"; path = released; }
16-
{ name = "v1.1.0-testnet"; path = current; }
16+
# { name = "v1.1.0"; path = current; }
17+
{ name = "v1.1.0"; path = "/opt/homebrew/Cellar/go/1.21.1/libexec/"; }
1718
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let
2+
pkgs = import ../../nix { };
3+
fetchFlake = repo: rev: (pkgs.flake-compat {
4+
src = {
5+
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
6+
inherit rev;
7+
shortRev = builtins.substring 0 7 rev;
8+
};
9+
}).defaultNix;
10+
# v1.1.0-rc1
11+
released = (fetchFlake "crypto-org-chain/cronos" "e61acd9193ac455098987e578ee6374ecc249836").default;
12+
current = pkgs.callPackage ../../. { };
13+
in
14+
pkgs.linkFarm "upgrade-test-package" [
15+
{ name = "genesis"; path = released; }
16+
# { name = "v1.1.0-testnet"; path = current; }
17+
{ name = "v1.1.0-testnet"; path = "/opt/homebrew/Cellar/go/1.21.1/libexec/"; }
18+
]

integration_tests/cosmoscli.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,11 @@ def edit_validator(
667667
)
668668
)
669669

670-
def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
670+
def gov_propose_legacy(self, proposer, kind, proposal, mode="block", **kwargs):
671671
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
672672
kwargs.setdefault("gas", DEFAULT_GAS)
673-
# kwargs.setdefault("broadcast_mode", "block")
673+
if mode:
674+
kwargs.setdefault("broadcast_mode", mode)
674675
if kind == "software-upgrade":
675676
rsp = json.loads(
676677
self.raw(
@@ -694,7 +695,7 @@ def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
694695
**kwargs,
695696
)
696697
)
697-
if rsp["code"] == 0:
698+
if rsp["code"] == 0 and mode is None:
698699
rsp = self.event_query_tx_for(rsp["txhash"])
699700
return rsp
700701
elif kind == "cancel-software-upgrade":
@@ -740,7 +741,7 @@ def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
740741
rsp = self.event_query_tx_for(rsp["txhash"])
741742
return rsp
742743

743-
def gov_vote(self, voter, proposal_id, option, **kwargs):
744+
def gov_vote(self, voter, proposal_id, option, event_query_tx=True, **kwargs):
744745
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
745746
rsp = json.loads(
746747
self.raw(
@@ -755,7 +756,7 @@ def gov_vote(self, voter, proposal_id, option, **kwargs):
755756
**kwargs,
756757
)
757758
)
758-
if rsp["code"] == 0:
759+
if rsp["code"] == 0 and event_query_tx:
759760
rsp = self.event_query_tx_for(rsp["txhash"])
760761
return rsp
761762

integration_tests/test_upgrade.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
deploy_contract,
1616
edit_ini_sections,
1717
get_consensus_params,
18+
get_send_enable,
1819
send_transaction,
1920
wait_for_block,
2021
wait_for_new_blocks,
@@ -86,13 +87,13 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
8687
{"denom": "basetcro", "enabled": False},
8788
{"denom": "stake", "enabled": True},
8889
]
89-
p = cli.query_bank_send()
90+
p = get_send_enable(port)
9091
assert sorted(p, key=lambda x: x["denom"]) == send_enable
9192

92-
# export genesis from cronos v1.1.0-rc1
93+
# export genesis from cronos v0.8.x
9394
custom_cronos.supervisorctl("stop", "all")
9495
migrate = tmp_path_factory.mktemp("migrate")
95-
file_path0 = Path(migrate / "v1.1.0-rc1.json")
96+
file_path0 = Path(migrate / "v0.8.json")
9697
with open(file_path0, "w") as fp:
9798
json.dump(json.loads(cli.export()), fp)
9899
fp.flush()
@@ -115,7 +116,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
115116
)
116117
print("old values", old_height, old_balance, old_base_fee)
117118

118-
plan_name = "v1.1.0-testnet"
119+
plan_name = "v1.1.0"
119120
rsp = cli.gov_propose_legacy(
120121
"community",
121122
"software-upgrade",
@@ -178,16 +179,30 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
178179

179180
rsp = cli.query_params("icaauth")
180181
assert rsp["params"]["min_timeout_duration"] == "3600s", rsp
181-
max_callback_gas = cli.query_params()["max_callback_gas"]
182-
assert max_callback_gas == "50000", max_callback_gas
182+
assert cli.query_params()["max_callback_gas"] == "50000", rsp
183+
184+
# migrate to sdk v0.47
185+
custom_cronos.supervisorctl("stop", "all")
186+
sdk_version = "v0.47"
187+
file_path1 = Path(migrate / f"{sdk_version}.json")
188+
with open(file_path1, "w") as fp:
189+
json.dump(cli.migrate_sdk_genesis(sdk_version, str(file_path0)), fp)
190+
fp.flush()
191+
# migrate to cronos v1.0.x
192+
cronos_version = "v1.0"
193+
file_path2 = Path(migrate / f"{cronos_version}.json")
194+
with open(file_path2, "w") as fp:
195+
json.dump(cli.migrate_cronos_genesis(cronos_version, str(file_path1)), fp)
196+
fp.flush()
197+
print(cli.validate_genesis(str(file_path2)))
183198

184199
# update the genesis time = current time + 5 secs
185200
newtime = datetime.utcnow() + timedelta(seconds=5)
186201
newtime = newtime.replace(tzinfo=None).isoformat("T") + "Z"
187202
config = custom_cronos.config
188203
config["genesis-time"] = newtime
189204
for i, _ in enumerate(config["validators"]):
190-
genesis = json.load(open(file_path0))
205+
genesis = json.load(open(file_path2))
191206
genesis["genesis_time"] = config.get("genesis-time")
192207
file = custom_cronos.cosmos_cli(i).data_dir / "config/genesis.json"
193208
file.write_text(json.dumps(genesis))

0 commit comments

Comments
 (0)