Open
Description
Currently we write a separate genesis
function for each Parachain when creating the emulated test environments cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs
.
Much of this logic is repeated, but some is chain / environment specific. We can make a generic function, reducing code repetition and making this code more expressive and configurable.
There will likely be more situations in the future where we want to configure genesis state for XCM testing.
We could do something like
trait RuntimeGenesisConfig {
fn configure_storage(storage: &mut Storage);
}
Then we could do a impl RuntimeGenesisConfig for BridgeHubRococoRuntime
, for example.
And finally:
impl Storage {
pub fn new_genesis<R: RuntimeGenesisConfig>() -> Self {
let mut storage = Storage::default();
R::configure_storage(&mut storage);
storage
}
}
Originally suggested here by @liamaharon