substrate
substrate copied to clipboard
`TryState`: automatically execute after each migration
Not automatically yet, I think it is okay to leave it up to the pallet to do so, which is what you are seeing here.
We can make a follow-up and once try_state is a bit more standard, make it execute upon all migrations.
Originally posted by @kianenigma in https://github.com/paritytech/substrate/pull/10174#discussion_r956728563
Ofc, IFF feature = try-runtime
wild dream: have a standard testing framework, call it automatically after each TEST.
To achieve executing this after each test:
have a new macro construct_runtime_with_ext_builder.
This generates, per pallet (e.g. staking)
- For each filed of
GenesisBuild, a structStakingBuilder { genesis_field_1, genesis_filed_2, .. } - For each
typeinConfigthat'sGet<u32>, aparameter_types! { static Config1: _ = .., Config2: _ = .. } - And
setterfunctions for all of the above.
lastly, it implements functions such as build and execute_with on Runtime, so at the end we would do:
Runtime::build().exeucte_with(|| {
})
in each test.
and this Runtime::execute_with would execute try_state() of the pallet after each test.
I really like this idea. It solves legacy issues like https://github.com/paritytech/polkadot-sdk/issues/367. The shitty thing about this is more hidden code, more magic, flying in the face of https://github.com/paritytech/polkadot-sdk/issues/32.