Skip to content

Commit

Permalink
test both
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 6, 2023
1 parent 020f73f commit 41ef44c
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 17 deletions.
18 changes: 17 additions & 1 deletion integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ config {
genesis+: {
app_state+: {
bank+: {
send_enabled+: [
params: {
send_enabled: [
{
denom: 'stake',
enabled: true,
Expand All @@ -21,12 +22,27 @@ config {
},
],
},
},
feemarket+: {
params+: {
no_base_fee: false,
base_fee:: super.base_fee,
},
},
gov: {
voting_params: {
voting_period: '10s',
},
deposit_params: {
max_deposit_period: '10s',
min_deposit: [
{
denom: 'basetcro',
amount: '1',
},
],
},
},
},
},
},
Expand Down
33 changes: 33 additions & 0 deletions integration_tests/configs/cosmovisor_testnet.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local config = import 'default.jsonnet';

config {
'cronos_777-1'+: {
'app-config'+: {
'app-db-backend': 'rocksdb',
'minimum-gas-prices': '100000000000basetcro',
'iavl-lazy-loading':: super['iavl-lazy-loading'],
},
genesis+: {
app_state+: {
bank+: {
send_enabled+: [
{
denom: 'stake',
enabled: true,
},
{
denom: 'basetcro',
enabled: false,
},
],
},
feemarket+: {
params+: {
no_base_fee: false,
base_fee:: super.base_fee,
},
},
},
},
},
}
7 changes: 4 additions & 3 deletions integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ let
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
# v1.1.0-rc1
released = (fetchFlake "crypto-org-chain/cronos" "e61acd9193ac455098987e578ee6374ecc249836").default;
# v1.0.12
released = (fetchFlake "crypto-org-chain/cronos" "a54d8a9659a98b917d3fc1ae39489fbc0699df60").default;
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = released; }
{ name = "v1.1.0-testnet"; path = current; }
# { name = "v1.1.0"; path = current; }
{ name = "v1.1.0"; path = "/opt/homebrew/Cellar/go/1.21.1/libexec/"; }
]
18 changes: 18 additions & 0 deletions integration_tests/configs/upgrade-testnet-test-package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let
pkgs = import ../../nix { };
fetchFlake = repo: rev: (pkgs.flake-compat {
src = {
outPath = builtins.fetchTarball "/~https://github.com/${repo}/archive/${rev}.tar.gz";
inherit rev;
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
# v1.1.0-rc1
released = (fetchFlake "crypto-org-chain/cronos" "e61acd9193ac455098987e578ee6374ecc249836").default;
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = released; }
# { name = "v1.1.0-testnet"; path = current; }
{ name = "v1.1.0-testnet"; path = "/opt/homebrew/Cellar/go/1.21.1/libexec/"; }
]
11 changes: 6 additions & 5 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,11 @@ def edit_validator(
)
)

def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
def gov_propose_legacy(self, proposer, kind, proposal, mode="block", **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", DEFAULT_GAS)
# kwargs.setdefault("broadcast_mode", "block")
if mode:
kwargs.setdefault("broadcast_mode", mode)
if kind == "software-upgrade":
rsp = json.loads(
self.raw(
Expand All @@ -694,7 +695,7 @@ def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
**kwargs,
)
)
if rsp["code"] == 0:
if rsp["code"] == 0 and mode is None:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp
elif kind == "cancel-software-upgrade":
Expand Down Expand Up @@ -740,7 +741,7 @@ def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def gov_vote(self, voter, proposal_id, option, **kwargs):
def gov_vote(self, voter, proposal_id, option, event_query_tx=True, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
rsp = json.loads(
self.raw(
Expand All @@ -755,7 +756,7 @@ def gov_vote(self, voter, proposal_id, option, **kwargs):
**kwargs,
)
)
if rsp["code"] == 0:
if rsp["code"] == 0 and event_query_tx:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

Expand Down
29 changes: 22 additions & 7 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
deploy_contract,
edit_ini_sections,
get_consensus_params,
get_send_enable,
send_transaction,
wait_for_block,
wait_for_new_blocks,
Expand Down Expand Up @@ -86,13 +87,13 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
{"denom": "basetcro", "enabled": False},
{"denom": "stake", "enabled": True},
]
p = cli.query_bank_send()
p = get_send_enable(port)
assert sorted(p, key=lambda x: x["denom"]) == send_enable

# export genesis from cronos v1.1.0-rc1
# export genesis from cronos v0.8.x
custom_cronos.supervisorctl("stop", "all")
migrate = tmp_path_factory.mktemp("migrate")
file_path0 = Path(migrate / "v1.1.0-rc1.json")
file_path0 = Path(migrate / "v0.8.json")
with open(file_path0, "w") as fp:
json.dump(json.loads(cli.export()), fp)
fp.flush()
Expand All @@ -115,7 +116,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
)
print("old values", old_height, old_balance, old_base_fee)

plan_name = "v1.1.0-testnet"
plan_name = "v1.1.0"
rsp = cli.gov_propose_legacy(
"community",
"software-upgrade",
Expand Down Expand Up @@ -178,16 +179,30 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):

rsp = cli.query_params("icaauth")
assert rsp["params"]["min_timeout_duration"] == "3600s", rsp
max_callback_gas = cli.query_params()["max_callback_gas"]
assert max_callback_gas == "50000", max_callback_gas
assert cli.query_params()["max_callback_gas"] == "50000", rsp

# migrate to sdk v0.47
custom_cronos.supervisorctl("stop", "all")
sdk_version = "v0.47"
file_path1 = Path(migrate / f"{sdk_version}.json")
with open(file_path1, "w") as fp:
json.dump(cli.migrate_sdk_genesis(sdk_version, str(file_path0)), fp)
fp.flush()
# migrate to cronos v1.0.x
cronos_version = "v1.0"
file_path2 = Path(migrate / f"{cronos_version}.json")
with open(file_path2, "w") as fp:
json.dump(cli.migrate_cronos_genesis(cronos_version, str(file_path1)), fp)
fp.flush()
print(cli.validate_genesis(str(file_path2)))

# update the genesis time = current time + 5 secs
newtime = datetime.utcnow() + timedelta(seconds=5)
newtime = newtime.replace(tzinfo=None).isoformat("T") + "Z"
config = custom_cronos.config
config["genesis-time"] = newtime
for i, _ in enumerate(config["validators"]):
genesis = json.load(open(file_path0))
genesis = json.load(open(file_path2))
genesis["genesis_time"] = config.get("genesis-time")
file = custom_cronos.cosmos_cli(i).data_dir / "config/genesis.json"
file.write_text(json.dumps(genesis))
Expand Down
Loading

0 comments on commit 41ef44c

Please sign in to comment.