From 68ab0fe156ed90a73f89fb099fd45b9582411c3c Mon Sep 17 00:00:00 2001 From: Thomas Nguy Date: Tue, 6 Sep 2022 16:01:46 +0900 Subject: [PATCH] add legacy send_to_ibc test --- .../contracts/contracts/TestERC21Source.sol | 12 +++++++++++- integration_tests/test_ibc.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/integration_tests/contracts/contracts/TestERC21Source.sol b/integration_tests/contracts/contracts/TestERC21Source.sol index 3b2cbf4eb0..917f61583b 100644 --- a/integration_tests/contracts/contracts/TestERC21Source.sol +++ b/integration_tests/contracts/contracts/TestERC21Source.sol @@ -7,6 +7,7 @@ contract TestERC21Source is ERC20 { string denom; bool isSource; + event __CronosSendToIbc(address sender, string recipient, uint256 amount); event __CronosSendToIbc(address sender, string recipient, uint256 amount, string channel_id, bytes extraData); event __CronosSendToEvmChain(address sender, address recipient, uint256 chain_id, uint256 amount, uint256 bridge_fee, bytes extraData); event __CronosCancelSendToEvmChain(address sender, uint256 id); @@ -57,7 +58,16 @@ contract TestERC21Source is ERC20 { **/ // send an "amount" of the contract token to recipient through IBC - function send_to_ibc(string memory recipient, uint amount, string memory channel_id, bytes memory extraData) public { + function send_to_ibc(string memory recipient, uint amount) public { + if (isSource) { + transfer(module_address, amount); + } else { + unsafe_burn(msg.sender, amount); + } + emit __CronosSendToIbc(msg.sender, recipient, amount); + } + + function send_to_ibc_v2(string memory recipient, uint amount, string memory channel_id, bytes memory extraData) public { if (isSource) { transfer(module_address, amount); } else { diff --git a/integration_tests/test_ibc.py b/integration_tests/test_ibc.py index 8b2fe0d3a1..be8bce4adc 100644 --- a/integration_tests/test_ibc.py +++ b/integration_tests/test_ibc.py @@ -270,7 +270,7 @@ def test_cronos_transfer_source_tokens(ibc): assert chainmain_receiver_balance == 0 # send to ibc - tx = contract.functions.send_to_ibc(chainmain_receiver, amount, '', b'').buildTransaction( + tx = contract.functions.send_to_ibc_v2(chainmain_receiver, amount, '', b'').buildTransaction( {"from": ADDRS["validator"]} ) txreceipt = send_transaction(w3, tx) @@ -291,6 +291,16 @@ def check_chainmain_balance_change(): wait_for_fn("check balance change", check_chainmain_balance_change) assert chainmain_receiver_new_balance == amount + # check legacy send to ibc + tx = contract.functions.send_to_ibc(chainmain_receiver, 1).buildTransaction( + {"from": ADDRS["validator"]} + ) + txreceipt = send_transaction(w3, tx) + assert txreceipt.status == 1, "should success" + chainmain_receiver_balance = amount + wait_for_fn("check balance change", check_chainmain_balance_change) + assert chainmain_receiver_new_balance == amount + 1 + # send back the token to cronos # check receiver balance cronos_balance_before_send = contract.caller.balanceOf(ADDRS["signer2"])