Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing IBC with mock module fails: Cannot execute Stargate #37

Closed
ori-wagmi opened this issue Apr 27, 2023 · 1 comment · Fixed by #106
Closed

Unit testing IBC with mock module fails: Cannot execute Stargate #37

ori-wagmi opened this issue Apr 27, 2023 · 1 comment · Fixed by #106
Assignees
Milestone

Comments

@ori-wagmi
Copy link

Context
I'm unit testing a method that makes an IBC call using a mocked module per:
#7
#10
https://github.com/CosmWasm/cw-multi-test/blob/8b58aa75573d65e9f2fdfffd2c8929848e8ad03b/src/ibc.rs

Issue:
The test fails with:

thread 'unit_tests::receive_remote_gmp' panicked at 'called `Result::unwrap()` on an `Err` value: error executing WasmMsg: --snip--

Caused by:
    Cannot execute Stargate { type_url: "/ibc.applications.transfer.v1.MsgTransfer", value: --snip-

Expected that the IBC message gets sent to the mock IBC module and doesn't error.

Details:
In unit_test.rs, I've setup my test exactly like the cw-multi-test/.../ibc.rs example:

// struct FakeIbcModule impl Module impl Ibc
let mut app = AppBuilder::new().with_ibc(FakeIbcModule).build(|_, _, _| ());
...
app.execute_contract(
        sender, 
        contract,
        ExecuteMsg,
        &[])
    .unwrap();

the ExecuteMsg handler does the following:

// MsgTransfer: #[proto_message(type_url = "/ibc.applications.transfer.v1.MsgTransfer")]
let ibc_transfer = crate::ibc::MsgTransfer {...};
...
return Ok(response.add_message(ibc_transfer));

Question:
Does anyone know why this is failing? Can anyone point me to a working test example that matches my scenario?

@DariuszDepta DariuszDepta added this to the 0.19.0 milestone Oct 20, 2023
@DariuszDepta DariuszDepta self-assigned this Oct 20, 2023
@DariuszDepta DariuszDepta modified the milestones: 0.19.0, 0.20.0 Nov 23, 2023
@DariuszDepta
Copy link
Member

DariuszDepta commented Nov 29, 2023

Hi @ori-wagmi,
I guess the problem was, that IBC message that you wanted to process had type_url field serialized, which is specific to CosmosMsg::Stargate variant. MultiTest did not have support for it, so you got this weird behavior.

Curently, there is a PR #106 that adds support for stargate messages and queries if you would need them in tests.

To fix your IBC test case please consult the current CosmosMsg::Ibc and IbcMsg defined in cosmwasm-std.

Please do not hesitate to reach us if you need any more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants