Runtime Errors and Testing

Runtime tests allow you to verify the logic in your runtime module by mocking a Substrate runtime environment. This requires an explicit implementation of all the traits declared in the module(s) for the mock runtime. So, if our module trait looked like,


# #![allow(unused_variables)]
#fn main() {
pub trait Trait: system::Trait {
  type Reward = SomeRewardType<AssociatedType>;

  type ConstThing = Get<u32>;
}
#}

Then, the implementation would require an explicit implementation of this trait in our mock runtime (similar in structure to the substrate and polkadot runtime configurations). For example,


# #![allow(unused_variables)]
#fn main() {
pub type SpecificType = u32; // could be some other type

parameter_types!{
  pub const ConstThing = 255;
}

impl module::Trait for Runtime {
  type Reward = SpecificType;
  type ConstThing = ConstThing;
}
#}

Within the context of testing, there are a few ways of building a mock runtime that offer varying levels of customizations...

This recipe is still in progress -- see srml-balances as well as the other srml modules test scaffolding for more