# Testing Complex FRAME Pallets: Discussion + Tools

**URL:** https://forum.polkadot.network/t/testing-complex-frame-pallets-discussion-tools/356
**Category:** Miscellaneous
**Tags:** frame
**Created:** [September 13, 2022, 10:36am UTC](https://forum.polkadot.network/t/testing-complex-frame-pallets-discussion-tools/356 "2022-09-13T10:36:46Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![OliverTY](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.polkadot.network/oliverty/32/2986_2.png) [@OliverTY](https://forum.polkadot.network/u/OliverTY)
#### Post date: [September 13, 2022, 4:24pm UTC](https://forum.polkadot.network/t/testing-complex-frame-pallets-discussion-tools/356/3 "2022-09-13T16:24:08Z")

</div>

It is indeed a bit too much to react to all of it. Maybe we just collect ideas in here and then create dedicated discussions for each part.

> [@kianenigma](#):
>
> Lastly, if and once we have storage types that can have `on_insert`, `on_update`, `on_remove` hooks etc., we can integrate all of these checks at a much lower level.

I like this idea. Imagine writing the invariants actually as code and not as comment:

```rust
#[pallet::storage] 
pub type Map = StorageMap<u32, u32>;

#[pallet::storage]
#[pallet::invariant(
    event: changed(_previous, current) {
        assert!(current == Map::iter().count());
    },
    check_on: StorageLayerCommit,
    // Could think of when to check these conditions; per Extrinsic, per Block, Always…
)]
pub type Counter = StorageValue<u32>;

```

---

_[View the full topic](https://forum.polkadot.network/t/testing-complex-frame-pallets-discussion-tools/356)._
