Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jan 17, 2025
1 parent 5f7deb4 commit 31a0cb1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
6 changes: 3 additions & 3 deletions integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ let
# release/v1.3.x
released1_3 =
(fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
# release/v1.4.x
# release/v1.4.2
released1_4 =
(fetchFlake "crypto-org-chain/cronos" "ce797fa995000530ee53cd1fbeb3c67180648002").default;
(fetchFlake "crypto-org-chain/cronos" "65f7de91b6fa981c6c8f0d4eace41296d66d8636").default;
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
Expand All @@ -48,7 +48,7 @@ pkgs.linkFarm "upgrade-test-package" [
path = released1_4;
}
{
name = "v1.4.0-rc5-testnet";
name = "v1.5";
path = current;
}
]
4 changes: 2 additions & 2 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,12 @@ def ibc_denom_trace(self, path, node):
self.raw(
"query",
"ibc-transfer",
"denom",
"denom-trace",
denom_hash,
node=node,
output="json",
)
)["denom"]
)["denom_trace"]

def export(self, **kwargs):
return self.raw("export", home=self.data_dir, **kwargs)
Expand Down
18 changes: 5 additions & 13 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ def prepare_network(
cronos.supervisorctl("start", "relayer-demo")
if is_hermes:
port = hermes.port
else:
port = 5183 # mmsqe
yield IBCNetwork(cronos, chainmain, hermes, incentivized)
if port:
wait_for_port(port)
Expand Down Expand Up @@ -353,7 +351,7 @@ def find_duplicate(attributes):
return None


def ibc_transfer(ibc, transfer_fn=hermes_transfer):
def ibc_transfer(ibc, transfer_fn=rly_transfer):
src_amount = transfer_fn(ibc)
dst_amount = src_amount * RATIO # the decimal places difference
dst_denom = "basetcro"
Expand Down Expand Up @@ -423,11 +421,8 @@ def assert_trace_balance(addr):
else:
return False

denom_trace = chains[0].ibc_denom_trace(path, ibc.chainmain.node_rpc(0))
assert denom_trace == {
"base": denom0,
"trace": [{"port_id": "transfer", "channel_id": channel1}],
}
denom_trace = chains[1].ibc_denom_trace(path, ibc.chainmain.node_rpc(0))
assert denom_trace == {"path": f"transfer/{channel1}", "base_denom": denom0}
for i, _ in enumerate(users):
wait_for_fn("assert balance", lambda: assert_trace_balance(addrs1[i]))

Expand Down Expand Up @@ -531,11 +526,8 @@ def check_fee():
assert user0_balances == expected, user0_balances
path = f"transfer/{dst_channel}/{base_denom0}"
denom_hash = ibc_denom(dst_channel, base_denom0)
denom_trace = chains[0].ibc_denom_trace(path, ibc.chainmain.node_rpc(0))
assert denom_trace == {
"base": base_denom0,
"trace": [{"port_id": "transfer", "channel_id": dst_channel}],
}
denom_trace = chains[1].ibc_denom_trace(path, ibc.chainmain.node_rpc(0))
assert denom_trace == {"path": f"transfer/{dst_channel}", "base_denom": base_denom0}
user1_balances = get_balances(ibc.chainmain, user1)
expected = [
{"denom": base_denom1, "amount": f"{old_user1_base}"},
Expand Down
29 changes: 21 additions & 8 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
method_name_map = get_method_map(contract_info, by_name=True)
method_with_seq = ["RecvPacket", "WriteAcknowledgement", "AcknowledgePacket"]
cronos_signer2 = ADDRS["signer2"]
port_id = "transfer"
src_amount = 10
src_denom = "basecro"
dst_amount = src_amount * RATIO # the decimal places difference
Expand Down Expand Up @@ -70,7 +71,7 @@ def amount_dict(amt, denom):
]


def token_dict(amt, denom):
def token_dict(amt, denom, trace):
if amt == 0:
return []
return [
Expand All @@ -80,7 +81,7 @@ def token_dict(amt, denom):
"denom": AttributeDict(
{
"base": denom,
"trace": [],
"trace": trace,
}
),
}
Expand Down Expand Up @@ -116,8 +117,8 @@ def distribute_fee(receiver, fee):
}


def fungible(dst, src, amt, denom):
return {"receiver": dst, "sender": src, "tokens": token_dict(amt, denom)}
def fungible(dst, src, amt, denom, trace=[]):
return {"receiver": dst, "sender": src, "tokens": token_dict(amt, denom, trace)}


def transfer(src, dst, amt, denom):
Expand Down Expand Up @@ -288,7 +289,7 @@ def test_ibc_incentivized_transfer(ibc):
amount, seq0, recv_fee, ack_fee = ibc_incentivized_transfer(ibc)
logs = get_logs_since(w3, CONTRACT, start)
fee_denom = "ibcfee"
transfer_denom = "transfer/channel-0/basetcro"
transfer_denom = f"{port_id}/{channel}/{dst_denom}"
dst_adr = ibc.chainmain.cosmos_cli().address("signer2")
src_relayer = ADDRS["signer1"]
checksum_dst_adr = to_checksum_address(bech32_to_eth(dst_adr))
Expand All @@ -306,7 +307,13 @@ def test_ibc_incentivized_transfer(ibc):
fungible(checksum_dst_adr, cronos_signer2, amount, dst_denom),
recv_packet(seq1, dst_adr, cronos_signer2, amount, transfer_denom),
*send_coins(escrow, cronos_signer2, amount, dst_denom),
fungible(cronos_signer2, checksum_dst_adr, amount, transfer_denom),
fungible(
cronos_signer2,
checksum_dst_adr,
amount,
dst_denom,
[AttributeDict({"portId": port_id, "channelId": channel})],
),
write_ack(seq1, dst_adr, cronos_signer2, amount, transfer_denom),
]
assert len(logs) == len(expected)
Expand Down Expand Up @@ -338,13 +345,19 @@ def assert_transfer_source_tokens_topics(ibc, fn):
checksum_dst_adr = to_checksum_address(bech32_to_eth(dst_adr))
cronos_addr = module_address("cronos")
cronos_denom = f"cronos{contract}"
transfer_denom = f"transfer/{channel}/{cronos_denom}"
transfer_denom = f"{port_id}/{channel}/{cronos_denom}"
expected = [
acknowledge_packet(seq0),
fungible(checksum_dst_adr, ADDRS["validator"], amount, cronos_denom),
recv_packet(seq1, dst_adr, cronos_signer2, amount, transfer_denom),
*send_coins(escrow, cronos_signer2, amount, cronos_denom),
fungible(cronos_signer2, checksum_dst_adr, amount, transfer_denom),
fungible(
cronos_signer2,
checksum_dst_adr,
amount,
cronos_denom,
[AttributeDict({"portId": port_id, "channelId": channel})],
),
*send_coins(cronos_signer2, cronos_addr, amount, cronos_denom),
coin_spent(cronos_addr, amount, cronos_denom),
burn(cronos_addr, amount, cronos_denom),
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def exec(c, tmp_path_factory):

def do_upgrade(plan_name, target, mode=None):
print(f"upgrade {plan_name} height: {target}")
if plan_name == "v1.4.0-rc5-testnet":
if plan_name == "v1.5":
rsp = cli.software_upgrade(
"community",
{
Expand Down Expand Up @@ -302,7 +302,7 @@ def do_upgrade(plan_name, target, mode=None):
cli.query_params("icaauth")
assert_gov_params(cli, gov_param)

cli = do_upgrade("v1.4.0-rc5-testnet", cli.block_height() + 15)
cli = do_upgrade("v1.5", cli.block_height() + 15)
check_basic_tx(c)


Expand Down
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"branch": "master",
"description": "Crypto.org Chain⛓: Croeseid Testnet and beyond development",
"homepage": "https://crypto.org",
"owner": "mmsqe",
"owner": "crypto-org-chain",
"repo": "chain-main",
"rev": "baf003849c2fef4ffa0d705079a3d16906fdd041",
"sha256": "0j0h47b24jh8h4jb9p42byn64wgypcphz50kinmy8my77vvijmni",
"rev": "1baff8aed447abcad5c8d2ea4f92d7ae00d8b8b3",
"sha256": "01cg1jfg4l2d6g2spxf3c2375zj0siv8wg1lssafv7ry51f3zyqz",
"type": "tarball",
"url": "https://github.com/mmsqe/chain-main/archive/baf003849c2fef4ffa0d705079a3d16906fdd041.tar.gz",
"url": "https://github.com/crypto-org-chain/chain-main/archive/1baff8aed447abcad5c8d2ea4f92d7ae00d8b8b3.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"dapptools": {
Expand Down Expand Up @@ -126,10 +126,10 @@
"homepage": "https://github.com/mmsqe/relayer",
"owner": "mmsqe",
"repo": "relayer",
"rev": "f1b0605a7f6f75946493e8577e45899aaf91bc04",
"sha256": "0gn5wdvhxd866pbhmcr18db63cz25mw3aa4lk24i582d1cpg7lzx",
"rev": "e7dccaa26661696c0c9b3a2eefb086eb5dc8f0db",
"sha256": "1gi9g7ncqzc4jlg7xyn9kwk26p7w5vclqmahralhbgjkl69a69cp",
"type": "tarball",
"url": "https://github.com/mmsqe/relayer/archive/f1b0605a7f6f75946493e8577e45899aaf91bc04.tar.gz",
"url": "https://github.com/mmsqe/relayer/archive/e7dccaa26661696c0c9b3a2eefb086eb5dc8f0db.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

0 comments on commit 31a0cb1

Please sign in to comment.