Mock-builder: proposal tracking #1315
Labels
crcl-protocol
Circle protocol related.
epic
Bigger issue, needs to be broken down.
I8-enhancement
An additional feature.
P2-nice-to-have
Issue is worth doing.
Description
Utility for building mocks from traits that works fine with Substrate pallets.
Motivation
Loose coupling is great for avoiding the knowledge load of how other pallets work when you develop your own pallet. Nevertheless, this benefit and all the effort put into making this abstraction is lost once you need to choose an implementation for tests/benchmarks. Testing and benchmarking force you to have the dependencies and trait implementations you wanted to avoid by the usage of traits, getting the annoying extra load of knowledge again.
To fix this problem, we can need an automatic way of creating generic mocks that allows you to get rid of using real implementations in tests/benchmarks, and force you to improve the quality of your tests.
Note: by "generic mocks" I mean a mock that can be configured independently for each test case, by using closures.
Proposal
In your trait
mocks
folderA place where you create all trait mocks you need.
In your pallet
mock.rs
fileIn your tests
Roadmap
mock-builder
implementation for using it in tests for any trait. Doesn't matter at this stage the creation ergonomics.mock-builder
to the repo with pools & permissions instances #1220'static
when they do not really need this. This is quite annoying because we can not implement traits without that'static
. Mock-builder: support trait methods with no static lifetimes #1322The text was updated successfully, but these errors were encountered: