Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Impl integrity test for runtime (#6356)
Browse files Browse the repository at this point in the history
* impl integrity test for runtime

* Update frame/support/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/support/procedural/src/construct_runtime/mod.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* use thread local

* update doc

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Gavin Wood <gavin@parity.io>
  • Loading branch information
3 people authored Jun 16, 2020
1 parent 9e999b2 commit b29e467
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions frame/support/procedural/src/construct_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
let outer_config = decl_outer_config(&name, modules.iter(), &scrate);
let inherent = decl_outer_inherent(&block, &unchecked_extrinsic, modules.iter(), &scrate);
let validate_unsigned = decl_validate_unsigned(&name, modules.iter(), &scrate);
let integrity_test = decl_integrity_test(&scrate);

let res = quote!(
#scrate_decl
Expand Down Expand Up @@ -120,6 +121,8 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
#inherent

#validate_unsigned

#integrity_test
);

Ok(res.into())
Expand Down Expand Up @@ -406,3 +409,17 @@ fn find_system_module<'a>(
.find(|decl| decl.name == SYSTEM_MODULE_NAME)
.map(|decl| &decl.module)
}

fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
quote!(
#[cfg(test)]
mod __construct_runtime_integrity_test {
use super::*;

#[test]
pub fn runtime_integrity_tests() {
<AllModules as #scrate::traits::IntegrityTest>::integrity_test();
}
}
)
}
Loading

0 comments on commit b29e467

Please sign in to comment.