If I have a pallet that depends on the staking pallet, and for example one of the functions needs access to the active era, how can I set up the test environment so that I can actually test this?
Let's say I am accessing the active era like this:
let active_era = Staking::<T>::active_era().ok_or(/*...*/)
I have checked the mock.rs
file in the staking
pallet directory, and it sets up all the configs and sets up the environment needed for testing the staking
pallet.
For my pallet, I need to set up the staking pallet because my pallet is dependent on it.
I was thinking of accessing the ExtBuilder
from the staking pallet, but it is a bit more complex than just importing it at the beginning of the file. It's because the staking/src/mock.rs
file is only compiled when testing the pallet. So when I am testing only my pallet it isn't possible to access the ExtBuilder
from the staking pallet.
This means that I can't access anything from the mock.rs
file inside the staking pallet.
How should I go about setting up the staking
pallet for testing my own pallet?