abstract-interchain-tests 0.22.2

Interchain testing library for the Abstract SDK. This is used primarily for tests but some elements are re-usable for testing apps and adapters
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
pub use abstract_std::app;
use abstract_std::{
    ibc::{CallbackInfo, CallbackResult, ModuleIbcMsg},
    ibc_client::{self},
    objects::module::ModuleInfo,
    IBC_CLIENT,
};
use cosmwasm_schema::{cw_serde, QueryResponses};
pub use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use cosmwasm_std::{
    from_json, to_json_binary, wasm_execute, AllBalanceResponse, Coin, Response, StdError,
};
use cw_controllers::AdminError;
use cw_storage_plus::Item;

pub type AppTestResult = Result<(), MockError>;

abstract_app::app_msg_types!(MockAppContract, MockExecMsg, MockQueryMsg);

#[cosmwasm_schema::cw_serde]
pub struct MockInitMsg {}

#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::ExecuteFns)]
#[impl_into(ExecuteMsg)]
pub enum MockExecMsg {
    DoSomething {},
    DoSomethingAdmin {},
    DoSomethingIbc {
        remote_chain: String,
        target_module: ModuleInfo,
    },
    QuerySomethingIbc {
        remote_chain: String,
        address: String,
    },
}

#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::QueryFns)]
#[impl_into(QueryMsg)]
#[derive(QueryResponses)]
pub enum MockQueryMsg {
    #[returns(ReceivedIbcCallbackStatus)]
    GetReceivedIbcCallbackStatus {},

    #[returns(ReceivedIbcQueryCallbackStatus)]
    GetReceivedIbcQueryCallbackStatus {},

    #[returns(ReceivedIbcModuleStatus)]
    GetReceivedIbcModuleStatus {},
}

#[cosmwasm_schema::cw_serde]
pub struct ReceivedIbcCallbackStatus {
    pub received: bool,
}

#[cosmwasm_schema::cw_serde]
pub struct ReceivedIbcQueryCallbackStatus {
    pub balance: Vec<Coin>,
}

#[cosmwasm_schema::cw_serde]
pub struct ReceivedIbcModuleStatus {
    pub received: ModuleInfo,
}

#[cosmwasm_schema::cw_serde]
pub struct MockMigrateMsg;

#[cosmwasm_schema::cw_serde]
pub struct MockReceiveMsg;

#[cosmwasm_schema::cw_serde]
pub struct MockSudoMsg;

use abstract_sdk::{AbstractSdkError, ModuleInterface};
use thiserror::Error;

use abstract_app::{AppContract, AppError};

#[derive(Error, Debug, PartialEq)]
pub enum MockError {
    #[error("{0}")]
    Std(#[from] StdError),

    #[error("{0}")]
    DappError(#[from] AppError),

    #[error("{0}")]
    Abstract(#[from] abstract_std::AbstractError),

    #[error("{0}")]
    AbstractSdk(#[from] AbstractSdkError),

    #[error("{0}")]
    Admin(#[from] AdminError),
}

pub type MockAppContract = AppContract<
    // MockModule,
    MockError,
    MockInitMsg,
    MockExecMsg,
    MockQueryMsg,
    MockMigrateMsg,
    MockReceiveMsg,
    MockSudoMsg,
>;

#[cw_serde]
pub struct IbcModuleToModuleMsg {
    ibc_msg: String,
}

// Easy way to see if an ibc-callback was actually received.
pub const IBC_CALLBACK_RECEIVED: Item<bool> = Item::new("ibc_callback_received");
// Easy way to see if an module ibc called was actually received.
pub const MODULE_IBC_RECEIVED: Item<ModuleInfo> = Item::new("module_ibc_received");

// Easy way to see if an ibc-callback was actually received.
pub const IBC_CALLBACK_QUERY_RECEIVED: Item<Vec<Coin>> = Item::new("ibc_callback_query_received");

pub const fn mock_app(id: &'static str, version: &'static str) -> MockAppContract {
    MockAppContract::new(id, version, None)
        .with_instantiate(|deps, _, _, _, _| {
            IBC_CALLBACK_RECEIVED.save(deps.storage, &false)?;
            Ok(Response::new().set_data("mock_init".as_bytes()))
        })
        .with_execute(|deps, _env, _, app, msg| match msg {
            MockExecMsg::DoSomethingIbc {
                remote_chain,
                target_module,
            } => {
                let ibc_client_addr = app.modules(deps.as_ref()).module_address(IBC_CLIENT)?;
                // We send an IBC Client module message
                let msg = wasm_execute(
                    ibc_client_addr,
                    &ibc_client::ExecuteMsg::ModuleIbcAction {
                        host_chain: remote_chain,
                        target_module,
                        msg: to_json_binary(&IbcModuleToModuleMsg {
                            ibc_msg: "module_to_module:msg".to_string(),
                        })
                        .unwrap(),
                        callback_info: Some(CallbackInfo {
                            id: "c_id".to_string(),
                            msg: None,
                        }),
                    },
                    vec![],
                )?;

                Ok(Response::new().add_message(msg))
            }
            MockExecMsg::QuerySomethingIbc {
                address,
                remote_chain,
            } => {
                let ibc_client_addr = app.modules(deps.as_ref()).module_address(IBC_CLIENT)?;
                // We send an IBC Client module message
                let msg = wasm_execute(
                    ibc_client_addr,
                    &ibc_client::ExecuteMsg::IbcQuery {
                        host_chain: remote_chain,
                        callback_info: CallbackInfo {
                            id: "query_id".to_string(),
                            msg: None,
                        },
                        query: cosmwasm_std::QueryRequest::Bank(
                            cosmwasm_std::BankQuery::AllBalances { address },
                        ),
                    },
                    vec![],
                )?;

                Ok(Response::new().add_message(msg))
            }
            _ => Ok(Response::new().set_data("mock_exec".as_bytes())),
        })
        .with_query(|deps, _, _, msg| match msg {
            MockQueryMsg::GetReceivedIbcCallbackStatus {} => {
                to_json_binary(&ReceivedIbcCallbackStatus {
                    received: IBC_CALLBACK_RECEIVED.load(deps.storage)?,
                })
                .map_err(Into::into)
            }
            MockQueryMsg::GetReceivedIbcModuleStatus {} => {
                to_json_binary(&ReceivedIbcModuleStatus {
                    received: MODULE_IBC_RECEIVED.load(deps.storage)?,
                })
                .map_err(Into::into)
            }
            MockQueryMsg::GetReceivedIbcQueryCallbackStatus {} => {
                to_json_binary(&ReceivedIbcQueryCallbackStatus {
                    balance: IBC_CALLBACK_QUERY_RECEIVED.load(deps.storage)?,
                })
                .map_err(Into::into)
            }
        })
        .with_sudo(|_, _, _, _| Ok(Response::new().set_data("mock_sudo".as_bytes())))
        .with_receive(|_, _, _, _, _| Ok(Response::new().set_data("mock_receive".as_bytes())))
        .with_ibc_callbacks(&[
            ("c_id", |deps, _, _, _, _| {
                IBC_CALLBACK_RECEIVED.save(deps.storage, &true).unwrap();
                Ok(Response::new().add_attribute("mock_callback", "executed"))
            }),
            ("query_id", |deps, _, _, _, msg| match msg.result {
                CallbackResult::Query { query: _, result } => {
                    let result = result.unwrap()[0].clone();
                    let deser: AllBalanceResponse = from_json(result)?;
                    IBC_CALLBACK_QUERY_RECEIVED
                        .save(deps.storage, &deser.amount)
                        .unwrap();
                    Ok(Response::new().add_attribute("mock_callback_query", "executed"))
                }
                _ => panic!("Expected query result"),
            }),
        ])
        .with_replies(&[(1u64, |_, _, _, msg| {
            Ok(Response::new().set_data(msg.result.unwrap().data.unwrap()))
        })])
        .with_migrate(|_, _, _, _| Ok(Response::new().set_data("mock_migrate".as_bytes())))
        .with_module_ibc(|deps, _, _, msg| {
            let ModuleIbcMsg { source_module, .. } = msg;
            // We save the module info status
            MODULE_IBC_RECEIVED.save(deps.storage, &source_module)?;
            Ok(Response::new().add_attribute("mock_module_ibc", "executed"))
        })
}

pub mod origin_app {
    use abstract_testing::addresses::{TEST_MODULE_ID, TEST_VERSION};

    use super::{mock_app, MockAppContract};
    pub const MOCK_APP_ORIGIN: MockAppContract = mock_app(TEST_MODULE_ID, TEST_VERSION);
    abstract_app::cw_orch_interface!(MOCK_APP_ORIGIN, MockAppContract, MockAppOriginI);
}

pub mod remote_app {
    use super::{mock_app, MockAppContract};

    pub const TEST_MODULE_ID_REMOTE: &str = "tester:test-module-id-remote";
    pub const TEST_VERSION_REMOTE: &str = "0.45.7";
    pub const MOCK_APP_REMOTE: MockAppContract =
        mock_app(TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE);
    abstract_app::cw_orch_interface!(MOCK_APP_REMOTE, MockAppContract, MockAppRemoteI);
}

#[cfg(test)]
pub mod test {

    fn assert_remote_module_call_status(
        app: &MockAppRemoteI<MockBech32>,
        source_module_expected: Option<ModuleInfo>,
    ) -> AnyResult<()> {
        let source_module = app
            .get_received_ibc_module_status()
            .map(|s| s.received)
            .ok();

        assert_eq!(source_module, source_module_expected);
        Ok(())
    }

    fn assert_callback_status(app: &MockAppOriginI<MockBech32>, status: bool) -> AnyResult<()> {
        let get_received_ibc_callback_status_res: ReceivedIbcCallbackStatus =
            app.get_received_ibc_callback_status()?;

        assert_eq!(
            ReceivedIbcCallbackStatus { received: status },
            get_received_ibc_callback_status_res
        );
        Ok(())
    }

    fn assert_query_callback_status(
        app: &MockAppOriginI<MockBech32>,
        balance: Vec<Coin>,
    ) -> AnyResult<()> {
        let get_received_ibc_query_callback_status_res: ReceivedIbcQueryCallbackStatus =
            app.get_received_ibc_query_callback_status()?;

        assert_eq!(
            ReceivedIbcQueryCallbackStatus { balance },
            get_received_ibc_query_callback_status_res
        );
        Ok(())
    }
    use crate::{
        interchain_accounts::create_test_remote_account,
        module_to_module_interactions::{
            origin_app::interface::MockAppOriginI,
            remote_app::{interface::MockAppRemoteI, TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE},
            MockExecMsgFns, MockInitMsg, MockQueryMsgFns, ReceivedIbcCallbackStatus,
            ReceivedIbcQueryCallbackStatus,
        },
        setup::{
            ibc_abstract_setup, ibc_connect_polytone_and_abstract, mock_test::logger_test_init,
        },
        JUNO, STARGAZE,
    };
    use abstract_app::objects::{chain_name::ChainName, module::ModuleInfo};
    use abstract_interface::{
        AppDeployer, DeployStrategy, Manager, ManagerQueryFns, VCExecFns, VCQueryFns,
    };
    use abstract_std::manager::{self, ModuleInstallConfig};
    use abstract_testing::addresses::{TEST_MODULE_ID, TEST_NAMESPACE, TEST_VERSION};
    use anyhow::Result as AnyResult;
    use cosmwasm_std::{coins, to_json_binary};
    use cw_orch::prelude::*;
    use cw_orch_interchain::{prelude::*, types::IbcPacketOutcome};

    #[test]
    fn target_module_must_exist() -> AnyResult<()> {
        logger_test_init();
        let mock_interchain =
            MockBech32InterchainEnv::new(vec![(JUNO, "juno"), (STARGAZE, "stargaze")]);

        // We just verified all steps pass
        let (abstr_origin, _abstr_remote) = ibc_abstract_setup(&mock_interchain, JUNO, STARGAZE)?;
        ibc_connect_polytone_and_abstract(&mock_interchain, STARGAZE, JUNO)?;

        let remote_name = ChainName::from_chain_id(STARGAZE).to_string();

        let (origin_account, _remote_account_id) =
            create_test_remote_account(&abstr_origin, JUNO, STARGAZE, &mock_interchain, None)?;

        let app = MockAppOriginI::new(
            TEST_MODULE_ID,
            abstr_origin.version_control.get_chain().clone(),
        );

        abstr_origin.version_control.claim_namespace(
            origin_account.manager.config()?.account_id,
            TEST_NAMESPACE.to_owned(),
        )?;

        app.deploy(TEST_VERSION.parse()?, DeployStrategy::Try)?;

        origin_account.install_app(&app, &MockInitMsg {}, None)?;

        // The user on origin chain wants to change the account description
        let target_module_info =
            ModuleInfo::from_id(TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE.into())?;
        let ibc_action_result = app.do_something_ibc(remote_name, target_module_info.clone())?;

        let ibc_result = mock_interchain.wait_ibc(JUNO, ibc_action_result)?;

        let expected_error_outcome = format!(
            "Module {} does not have a stored module reference",
            target_module_info
        );
        match &ibc_result.packets[0].outcome {
            IbcPacketOutcome::Timeout { .. } => {
                panic!("Expected a failed ack not a timeout !")
            }
            IbcPacketOutcome::Success { ack, .. } => assert!(String::from_utf8_lossy(ack)
                .to_string()
                .contains(&expected_error_outcome)),
        }

        Ok(())
    }

    #[test]
    fn target_account_must_have_module_installed() -> AnyResult<()> {
        logger_test_init();
        let mock_interchain =
            MockBech32InterchainEnv::new(vec![(JUNO, "juno"), (STARGAZE, "stargaze")]);

        // We just verified all steps pass
        let (abstr_origin, abstr_remote) = ibc_abstract_setup(&mock_interchain, JUNO, STARGAZE)?;
        ibc_connect_polytone_and_abstract(&mock_interchain, STARGAZE, JUNO)?;

        let remote_name = ChainName::from_chain_id(STARGAZE).to_string();

        let (origin_account, _remote_account_id) =
            create_test_remote_account(&abstr_origin, JUNO, STARGAZE, &mock_interchain, None)?;

        let (remote_account, _remote_account_id) =
            create_test_remote_account(&abstr_remote, STARGAZE, JUNO, &mock_interchain, None)?;

        // Install local app
        let app = MockAppOriginI::new(
            TEST_MODULE_ID,
            abstr_origin.version_control.get_chain().clone(),
        );

        abstr_origin
            .version_control
            .claim_namespace(origin_account.id()?, TEST_NAMESPACE.to_owned())?;

        app.deploy(TEST_VERSION.parse()?, DeployStrategy::Try)?;

        origin_account.install_app(&app, &MockInitMsg {}, None)?;

        // Install remote app
        let app_remote = MockAppRemoteI::new(
            TEST_MODULE_ID_REMOTE,
            abstr_remote.version_control.get_chain().clone(),
        );

        abstr_remote
            .version_control
            .claim_namespace(remote_account.id()?, TEST_NAMESPACE.to_owned())?;

        app_remote.deploy(TEST_VERSION_REMOTE.parse()?, DeployStrategy::Try)?;

        // The user on origin chain wants to change the account description
        let target_module_info =
            ModuleInfo::from_id(TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE.into())?;
        let ibc_action_result = app.do_something_ibc(remote_name, target_module_info.clone())?;

        let ibc_result = mock_interchain.wait_ibc(JUNO, ibc_action_result)?;

        let expected_error_outcome =
            format!("App {} not installed on Account", target_module_info,);
        match &ibc_result.packets[0].outcome {
            IbcPacketOutcome::Timeout { .. } => {
                panic!("Expected a failed ack not a timeout !")
            }
            IbcPacketOutcome::Success { ack, .. } => assert!(String::from_utf8_lossy(ack)
                .to_string()
                .contains(&expected_error_outcome)),
        }

        Ok(())
    }

    #[test]
    fn works() -> AnyResult<()> {
        logger_test_init();
        let mock_interchain =
            MockBech32InterchainEnv::new(vec![(JUNO, "juno"), (STARGAZE, "stargaze")]);

        // We just verified all steps pass
        let (abstr_origin, abstr_remote) = ibc_abstract_setup(&mock_interchain, JUNO, STARGAZE)?;
        ibc_connect_polytone_and_abstract(&mock_interchain, STARGAZE, JUNO)?;

        let remote_name = ChainName::from_chain_id(STARGAZE).to_string();

        let (origin_account, remote_account_id) =
            create_test_remote_account(&abstr_origin, JUNO, STARGAZE, &mock_interchain, None)?;

        let (remote_account, _) =
            create_test_remote_account(&abstr_remote, STARGAZE, JUNO, &mock_interchain, None)?;

        // Install local app
        let app = MockAppOriginI::new(
            TEST_MODULE_ID,
            abstr_origin.version_control.get_chain().clone(),
        );

        abstr_origin
            .version_control
            .claim_namespace(origin_account.id()?, TEST_NAMESPACE.to_owned())?;

        app.deploy(TEST_VERSION.parse()?, DeployStrategy::Try)?;

        origin_account.install_app(&app, &MockInitMsg {}, None)?;

        // Install remote app
        let app_remote = MockAppRemoteI::new(
            TEST_MODULE_ID_REMOTE,
            abstr_remote.version_control.get_chain().clone(),
        );

        abstr_remote
            .version_control
            .claim_namespace(remote_account.id()?, TEST_NAMESPACE.to_owned())?;

        app_remote.deploy(TEST_VERSION_REMOTE.parse()?, DeployStrategy::Try)?;

        let remote_install_response = origin_account.manager.execute_on_remote(
            &remote_name,
            manager::ExecuteMsg::InstallModules {
                modules: vec![ModuleInstallConfig::new(
                    ModuleInfo::from_id_latest(TEST_MODULE_ID_REMOTE)?,
                    Some(to_json_binary(&MockInitMsg {})?),
                )],
            },
        )?;

        mock_interchain.check_ibc(JUNO, remote_install_response)?;

        // We get the object for handling the actual module on the remote account
        let remote_manager = abstr_remote
            .version_control
            .account_base(remote_account_id)?
            .account_base
            .manager;
        let manager = Manager::new(
            "remote-account-manager",
            abstr_remote.version_control.get_chain().clone(),
        );
        manager.set_address(&remote_manager);
        let module_address = manager.module_info(TEST_MODULE_ID_REMOTE)?.unwrap().address;
        let remote_account_app = MockAppRemoteI::new(
            "remote-account-app",
            abstr_remote.version_control.get_chain().clone(),
        );
        remote_account_app.set_address(&module_address);

        // The user on origin chain triggers a module-to-module interaction
        let target_module_info =
            ModuleInfo::from_id(TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE.into())?;
        let ibc_action_result = app.do_something_ibc(remote_name, target_module_info.clone())?;

        assert_remote_module_call_status(&remote_account_app, None)?;
        assert_callback_status(&app, false)?;

        mock_interchain.check_ibc(JUNO, ibc_action_result)?;

        assert_remote_module_call_status(
            &remote_account_app,
            Some(ModuleInfo::from_id(TEST_MODULE_ID, TEST_VERSION.into())?),
        )?;
        assert_callback_status(&app, true)?;

        Ok(())
    }

    pub const REMOTE_AMOUNT: u128 = 5674309;
    pub const REMOTE_DENOM: &str = "remote_denom";
    #[test]
    fn queries() -> AnyResult<()> {
        logger_test_init();
        let mock_interchain =
            MockBech32InterchainEnv::new(vec![(JUNO, "juno"), (STARGAZE, "stargaze")]);

        // We just verified all steps pass
        let (abstr_origin, _abstr_remote) = ibc_abstract_setup(&mock_interchain, JUNO, STARGAZE)?;
        ibc_connect_polytone_and_abstract(&mock_interchain, STARGAZE, JUNO)?;

        let remote_name = ChainName::from_chain_id(STARGAZE).to_string();
        let remote = mock_interchain.chain(STARGAZE)?;
        let remote_address =
            remote.addr_make_with_balance("remote-test", coins(REMOTE_AMOUNT, REMOTE_DENOM))?;

        let (origin_account, _remote_account_id) =
            create_test_remote_account(&abstr_origin, JUNO, STARGAZE, &mock_interchain, None)?;

        // Install local app
        let app = MockAppOriginI::new(
            TEST_MODULE_ID,
            abstr_origin.version_control.get_chain().clone(),
        );

        abstr_origin
            .version_control
            .claim_namespace(origin_account.id()?, TEST_NAMESPACE.to_owned())?;

        app.deploy(TEST_VERSION.parse()?, DeployStrategy::Try)?;

        origin_account.install_app(&app, &MockInitMsg {}, None)?;

        let query_response = app.query_something_ibc(remote_address.to_string(), remote_name)?;

        assert_query_callback_status(&app, coins(REMOTE_AMOUNT, REMOTE_DENOM)).unwrap_err();
        mock_interchain.check_ibc(JUNO, query_response)?;
        assert_query_callback_status(&app, coins(REMOTE_AMOUNT, REMOTE_DENOM))?;

        Ok(())
    }

    pub mod security {
        use abstract_std::ibc_client::ExecuteMsgFns;

        use crate::module_to_module_interactions::IbcModuleToModuleMsg;

        use super::*;

        #[test]
        fn calling_module_should_match() -> AnyResult<()> {
            logger_test_init();
            let mock_interchain =
                MockBech32InterchainEnv::new(vec![(JUNO, "juno"), (STARGAZE, "stargaze")]);

            // We just verified all steps pass
            let (abstr_origin, abstr_remote) =
                ibc_abstract_setup(&mock_interchain, JUNO, STARGAZE)?;
            ibc_connect_polytone_and_abstract(&mock_interchain, STARGAZE, JUNO)?;

            let remote_name = ChainName::from_chain_id(STARGAZE).to_string();

            let (origin_account, remote_account_id) =
                create_test_remote_account(&abstr_origin, JUNO, STARGAZE, &mock_interchain, None)?;

            let (remote_account, _) =
                create_test_remote_account(&abstr_remote, STARGAZE, JUNO, &mock_interchain, None)?;

            // Install local app
            let app = MockAppOriginI::new(
                TEST_MODULE_ID,
                abstr_origin.version_control.get_chain().clone(),
            );

            abstr_origin
                .version_control
                .claim_namespace(origin_account.id()?, TEST_NAMESPACE.to_owned())?;

            app.deploy(TEST_VERSION.parse()?, DeployStrategy::Try)?;

            origin_account.install_app(&app, &MockInitMsg {}, None)?;

            // Install remote app
            let app_remote = MockAppRemoteI::new(
                TEST_MODULE_ID_REMOTE,
                abstr_remote.version_control.get_chain().clone(),
            );

            abstr_remote
                .version_control
                .claim_namespace(remote_account.id()?, TEST_NAMESPACE.to_owned())?;

            app_remote.deploy(TEST_VERSION_REMOTE.parse()?, DeployStrategy::Try)?;

            let remote_install_response = origin_account.manager.execute_on_remote(
                &remote_name,
                manager::ExecuteMsg::InstallModules {
                    modules: vec![ModuleInstallConfig::new(
                        ModuleInfo::from_id_latest(TEST_MODULE_ID_REMOTE)?,
                        Some(to_json_binary(&MockInitMsg {})?),
                    )],
                },
            )?;

            mock_interchain.check_ibc(JUNO, remote_install_response)?;

            // We get the object for handling the actual module on the remote account
            let remote_manager = abstr_remote
                .version_control
                .account_base(remote_account_id)?
                .account_base
                .manager;
            let manager = Manager::new(
                "remote-account-manager",
                abstr_remote.version_control.get_chain().clone(),
            );
            manager.set_address(&remote_manager);
            let module_address = manager.module_info(TEST_MODULE_ID_REMOTE)?.unwrap().address;
            let remote_account_app = MockAppRemoteI::new(
                "remote-account-app",
                abstr_remote.version_control.get_chain().clone(),
            );
            remote_account_app.set_address(&module_address);

            // The user on origin chain triggers a module-to-module interaction
            let target_module_info =
                ModuleInfo::from_id(TEST_MODULE_ID_REMOTE, TEST_VERSION_REMOTE.into())?;

            // The user triggers manually a module-to-module interaction
            abstr_origin
                .ibc
                .client
                .module_ibc_action(
                    remote_name,
                    to_json_binary(&IbcModuleToModuleMsg {
                        ibc_msg: "module_to_module:msg".to_string(),
                    })
                    .unwrap(),
                    target_module_info,
                    None,
                )
                .unwrap_err();

            Ok(())
        }
    }
}