1

I've been working on a pallet in isolation for a few months. I did testing by mocking a runtime and mocking the related pallets that are expected by it. Basically, so far I have created fake pallets in a mock directory and used those in place of the ones that my pallet expects to be loosely coupled with. Here's my directory structure (roughly)

frame/my-pallet/
├── Cargo.toml
└── src
    ├── benchmarking.rs
    ├── lib.rs
    ├── mock
    │   ├── accounts.rs
    │   ├── assets.rs
    │   ├── mod.rs
    │   ├── pallet1.rs
    │   ├── pallet2.rs
    │   └── runtime.rs
    ├── tests
    │   ├── mod.rs
    │   ├── extrinsic1.rs
    │   ├── extrinsic2.rs
    │   └── extrinsic3.rs
    ├── helpers.rs
    └── weights.rs

I now wanna do tests with a real implementation of pallet1, but I wanna keep the test cases with the mocked version. Is there a 'canonical' way of doing that? I'm considering just adding a integrations subdirectory under src and having new mock.rs and tests.rs files there.

2
  • Have you considered Zombienet?
    – Bruno
    Aug 15, 2022 at 19:48
  • Not yet, does that facilitate automated tests of scenarios where two or more pallets are involved?
    – Angelo
    Aug 16, 2022 at 11:12

1 Answer 1

1

Any pallet is just a Rust crate. Adding the "real" pallet1 as a dependency to Cargo.toml will make it available to be imported anywhere in your project.

1
  • Yes, but I guess what I'm asking is how to have multiple mocked runtimes in my test directory, so that I can have tests with mocked dependencies (which have some auxiliary calls not present in real pallets) and tests with 'real' dependencies
    – Angelo
    Aug 18, 2022 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.