Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Aug 7, 2023
1 parent 4c6e9be commit b10c2ee
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
18 changes: 16 additions & 2 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ def create_account(self, name, mnemonic=None):
def migrate_keystore(self):
return self.raw("keys", "migrate", home=self.data_dir)

def migrate_sdk_genesis(self, version, path):
return json.loads(self.raw("migrate", version, path))

def migrate_cronos_genesis(self, version, path):
return json.loads(
self.raw(
"tx",
"cronos",
"migrate",
version,
path,
)
)

def init(self, moniker):
"the node's config is already added"
return self.raw(
Expand All @@ -120,8 +134,8 @@ def init(self, moniker):
home=self.data_dir,
)

def validate_genesis(self):
return self.raw("validate-genesis", home=self.data_dir)
def validate_genesis(self, path):
return self.raw("validate-genesis", path)

def add_genesis_account(self, addr, coins, **kwargs):
return self.raw(
Expand Down
28 changes: 27 additions & 1 deletion integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,24 @@ def custom_cronos(tmp_path_factory):
)


def test_cosmovisor_upgrade(custom_cronos: Cronos):
def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):
"""
- propose an upgrade and pass it
- wait for it to happen
- it should work transparently
"""
cli = custom_cronos.cosmos_cli()
# export genesis from cronos v0.8.x
custom_cronos.supervisorctl("stop", "all")
migrate = tmp_path_factory.mktemp("migrate")
file_path0 = Path(migrate / "v0.8.json")
with open(file_path0, "w") as fp:
json.dump(json.loads(cli.export()), fp)
fp.flush()

custom_cronos.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1")
wait_for_port(ports.evmrpc_port(custom_cronos.base_port(0)))

height = cli.block_height()
target_height = height + 15
print("upgrade height", target_height)
Expand Down Expand Up @@ -184,3 +195,18 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos):
{"from": ADDRS["validator"]}
)["gas"]
)

# migrate to sdk v0.46
custom_cronos.supervisorctl("stop", "all")
sdk_version = "v0.46"
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)))

0 comments on commit b10c2ee

Please sign in to comment.