Skip to content

Commit

Permalink
fix call ica
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Sep 22, 2023
1 parent d4bee9b commit 32d9db6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
9 changes: 9 additions & 0 deletions integration_tests/contracts/contracts/ICA.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IICAModule {
event SubmitMsgsResult(string seq);
function registerAccount(string calldata connectionID, string calldata version) external payable returns (bool);
function queryAccount(string calldata connectionID, address addr) external view returns (string memory);
function submitMsgs(string calldata connectionID, string calldata data, uint256 timeout) external payable returns (uint64);
}
17 changes: 7 additions & 10 deletions integration_tests/contracts/contracts/TestICA.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity >0.6.6;
pragma solidity ^0.8.4;

import {IICAModule} from "./ICA.sol";

contract TestICA {
address constant icaContract = 0x0000000000000000000000000000000000000066;
IICAModule ica = IICAModule(icaContract);

function encodeRegister(string memory connectionID) internal view returns (bytes memory) {
return abi.encodeWithSignature(
Expand All @@ -12,9 +15,7 @@ contract TestICA {
}

function callRegister(string memory connectionID) public returns (bool) {
(bool result, ) = icaContract.call(encodeRegister(connectionID));
require(result, "call failed");
return true;
return ica.registerAccount(connectionID, "");
}

function delegateRegister(string memory connectionID) public returns (bool) {
Expand All @@ -37,9 +38,7 @@ contract TestICA {
}

function callQueryAccount(string memory connectionID, address addr) public returns (string memory) {
(bool result, bytes memory data) = icaContract.call(encodeQueryAccount(connectionID, addr));
require(result, "call failed");
return abi.decode(data, (string));
return ica.queryAccount(connectionID, addr);
}

function delegateQueryAccount(string memory connectionID, address addr) public returns (string memory) {
Expand All @@ -62,9 +61,7 @@ contract TestICA {
}

function callSubmitMsgs(string memory connectionID, string memory data) public returns (uint64) {
(bool result, bytes memory data) = icaContract.call(encodeSubmitMsgs(connectionID, data));
require(result, "call failed");
return abi.decode(data, (uint64));
return ica.submitMsgs(connectionID, data, 300000000000);
}

function delegateSubmitMsgs(string memory connectionID, string memory data) public returns (uint64) {
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_ica_precompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def submit_msgs(msgs, seq):
assert tcontract.functions.staticQueryAccount(connid, addr).call() == ica_address

tx = tcontract.functions.callRegister(connid).build_transaction(data)
assert send_transaction(w3, tx, keys).status == 0
assert send_transaction(w3, tx, keys).status == 1
tx = tcontract.functions.delegateRegister(connid).build_transaction(data)
assert send_transaction(w3, tx, keys).status == 0
tx = tcontract.functions.staticRegister(connid).build_transaction(data)
assert send_transaction(w3, tx, keys).status == 0

tx = tcontract.functions.callSubmitMsgs(connid, "").build_transaction(data)
assert send_transaction(w3, tx, keys).status == 0
assert send_transaction(w3, tx, keys).status == 1

Check failure on line 139 in integration_tests/test_ica_precompile.py

View workflow job for this annotation

GitHub Actions / integration_tests

test_call AssertionError: assert 0 == 1 + where 0 = AttributeDict({'blockHash': HexBytes('0x1b026f8e9be95a1aed158c5cd239d605f6501e880b1c5a5f61446069d4c41ddd'), 'blockNumber': 57, 'contractAddress': None, 'cumulativeGasUsed': 197359, 'effectiveGasPrice': 0, 'from': '0x03EB2cbae6754c6e459F444783d1557dCa0f4e1A', 'gasUsed': 197359, 'logs': [], 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'status': 0, 'to': '0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503', 'transactionHash': HexBytes('0x86c811d7146224b7f81f077844afe0def96db26dae237e1e66ca2b928ca971ef'), 'transactionIndex': 0, 'type': 2}).status + where AttributeDict({'blockHash': HexBytes('0x1b026f8e9be95a1aed158c5cd239d605f6501e880b1c5a5f61446069d4c41ddd'), 'blockNumber': 57, 'contractAddress': None, 'cumulativeGasUsed': 197359, 'effectiveGasPrice': 0, 'from': '0x03EB2cbae6754c6e459F444783d1557dCa0f4e1A', 'gasUsed': 197359, 'logs': [], 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'status': 0, 'to': '0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503', 'transactionHash': HexBytes('0x86c811d7146224b7f81f077844afe0def96db26dae237e1e66ca2b928ca971ef'), 'transactionIndex': 0, 'type': 2}) = send_transaction(<web3.main.Web3 object at 0x7f155fbd5f30>, {'chainId': 777, 'data': '0x5134309c00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000c636f6e6e656374696f6e2d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'from': '0x03EB2cbae6754c6e459F444783d1557dCa0f4e1A', 'gas': 200000, ...}, HexBytes('0xe95790afde7a9eaf910419bbdfb7ef8ed93a6570562f19adc4bb73c29e80cc64'))
tx = tcontract.functions.delegateSubmitMsgs(connid, "").build_transaction(data)
assert send_transaction(w3, tx, keys).status == 0
tx = tcontract.functions.staticSubmitMsgs(connid, "").build_transaction(data)
Expand Down

0 comments on commit 32d9db6

Please sign in to comment.