Skip to content

Commit

Permalink
Problem: ibc integration test can't run standalone (#1037)
Browse files Browse the repository at this point in the history
Solution:
- dynamically calculate the expected ibc denom, becuase the contract address rely on current account nonce.
  • Loading branch information
yihuang authored May 25, 2023
1 parent 81e9eea commit 37a840a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import hashlib

import pytest

from .ibc_utils import (
Expand Down Expand Up @@ -230,11 +232,11 @@ def test_cronos_transfer_source_tokens(ibc):
assert_ready(ibc)
# deploy crc21 contract
w3 = ibc.cronos.w3
contract, _ = setup_token_mapping(ibc.cronos, "TestERC21Source", "DOG")
contract, denom = setup_token_mapping(ibc.cronos, "TestERC21Source", "DOG")
# send token to crypto.org
print("send to crypto.org")
chainmain_receiver = ibc.chainmain.cosmos_cli().address("signer2")
dest_denom = "ibc/C096BF05DB995A975931166766E0E2585A4C3818290C7E737ACE82A39DD6ECDE"
dest_denom = ibc_denom("channel-0", denom)
amount = 1000

# check and record receiver balance
Expand Down Expand Up @@ -336,7 +338,7 @@ def test_cronos_transfer_source_tokens_with_proxy(ibc):
# send token to crypto.org
print("send to crypto.org")
chainmain_receiver = ibc.chainmain.cosmos_cli().address("signer2")
dest_denom = "ibc/67AC4BFF3CECEE5779A56B79301E0AECEACF21C531FF2979982970F6DFA25925"
dest_denom = ibc_denom("channel-0", denom)
amount = 1000
sender = ADDRS["validator"]

Expand Down Expand Up @@ -403,3 +405,8 @@ def check_contract_balance_change():

wait_for_fn("check contract balance change", check_contract_balance_change)
assert cronos_balance_after_send == amount


def ibc_denom(channel, denom):
h = hashlib.sha256(f"transfer/{channel}/{denom}".encode()).hexdigest().upper()
return f"ibc/{h}"

0 comments on commit 37a840a

Please sign in to comment.