Skip to content

Commit 22bcaf6

Browse files
committed
Fix VM tests
1 parent eb79917 commit 22bcaf6

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

packages/vm/src/ibc_calls.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ where
235235
#[cfg(test)]
236236
mod tests {
237237
use super::*;
238-
use crate::calls::{call_execute, call_instantiate};
238+
use crate::calls::{call_instantiate, call_reply};
239239
use crate::testing::{mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage};
240240
use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_ack};
241-
use cosmwasm_std::{Empty, IbcOrder};
241+
use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, SubcallResponse};
242242

243243
static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm");
244244
const IBC_VERSION: &str = "ibc-reflect-v1";
@@ -264,18 +264,26 @@ mod tests {
264264

265265
// then we connect (with counter-party version set)
266266
let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION);
267-
call_ibc_channel_connect::<_, _, _, Empty>(instance, &mock_env(), &handshake_connect)
268-
.unwrap()
269-
.unwrap();
270-
267+
let res: IbcBasicResponse =
268+
call_ibc_channel_connect::<_, _, _, Empty>(instance, &mock_env(), &handshake_connect)
269+
.unwrap()
270+
.unwrap();
271+
assert_eq!(1, res.submessages.len());
272+
let id = res.submessages[0].id;
273+
274+
let event = Event {
275+
kind: "message".into(),
276+
attributes: vec![attr("contract_address", &account)],
277+
};
271278
// which creates a reflect account. here we get the callback
272-
let execute_msg = format!(
273-
r#"{{"init_callback":{{"id":"{}","contract_addr":"{}"}}}}"#,
274-
channel_id, account
275-
);
276-
let info = mock_info(account, &[]);
277-
call_execute::<_, _, _, Empty>(instance, &mock_env(), &info, execute_msg.as_bytes())
278-
.unwrap();
279+
let response = Reply {
280+
id,
281+
result: ContractResult::Ok(SubcallResponse {
282+
events: vec![event],
283+
data: None,
284+
}),
285+
};
286+
call_reply::<_, _, _, Empty>(instance, &mock_env(), &response).unwrap();
279287
}
280288

281289
const CHANNEL_ID: &str = "channel-123";

0 commit comments

Comments
 (0)