# \`inspect\_message\` seems not work on the \`ic-test-state-machine\`

**URL:** <https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857>\
**Category:** Developers\
**Tags:** Discussing\
**Created:** [June 21, 2023, 5:30am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857 "2023-06-21T05:30:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![famouscat8](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/famouscat8/32/4732_2.png) [@famouscat8](https://forum.dfinity.org/u/famouscat8)\
**Post date:** [June 21, 2023, 5:30am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857/1 "2023-06-21T05:30:02Z")

</div>

I have this in my rust canister:

```rust
#[inspect_message]
fn inspect_message() {
    let inspected_maethod_name = ic_cdk::api::call::method_name();
    if inspected_maethod_name == "create_user" {
        ic_cdk::api::call::reject_message();
    }
    ic_cdk::api::call::accept_message();
}

```

but i still can call the `create_user` function in the test suit using `ic-test-state-machine`’s call\_candid method.

---

<div class="post-metadata">

**Author:** ![domwoe](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/domwoe/32/5165_2.png) [@domwoe](https://forum.dfinity.org/u/domwoe)\
**Post date:** [June 21, 2023, 6:23am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857/2 "2023-06-21T06:23:23Z")

</div>

Not an expert here, but `inspect_message` only handles ingress messages. `ic-test-state-machine` operates on another level.

To test the `inspect_message` handler you’d need to run e2e tests, i.e. running your canister on the (local) replica and calling `create_user` from a client.

---

<div class="post-metadata">

**Author:** ![famouscat8](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/famouscat8/32/4732_2.png) [@famouscat8](https://forum.dfinity.org/u/famouscat8)\
**Post date:** [June 21, 2023, 6:25am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857/3 "2023-06-21T06:25:39Z")

</div>

Any open source project used the `inspect message` feature? I want to get a example to learn how to use it.

---

<div class="post-metadata">

**Author:** ![domwoe](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/domwoe/32/5165_2.png) [@domwoe](https://forum.dfinity.org/u/domwoe)\
**Post date:** [June 21, 2023, 6:31am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857/4 "2023-06-21T06:31:05Z")

</div>

Here’s one: [examples/rust/nft-wallet/src/lib.rs at 71156ae52e4911a8ce7cf4ed957741a7131c9454 · dfinity/examples · GitHub](https://github.com/dfinity/examples/blob/71156ae52e4911a8ce7cf4ed957741a7131c9454/rust/nft-wallet/src/lib.rs#L91)

---

<div class="post-metadata">

**Author:** ![sea-snake](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sea-snake/32/7243_2.png) [@sea-snake](https://forum.dfinity.org/u/sea-snake)\
**Post date:** [June 21, 2023, 7:14am UTC](https://forum.dfinity.org/t/inspect-message-seems-not-work-on-the-ic-test-state-machine/20857/5 "2023-06-21T07:14:38Z")

</div>

As far as I remember this only runs for calls that come through the http gateway. Other canisters that call your canister directly (inter canister call) will not go through inspect\_message if I remember correctly.

So make sure that it’s not used as the sole security layer, still make sure that the methods themselves also verify access.
