mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
Impl integrity test for runtime (#6356)
* 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>
This commit is contained in:
committed by
GitHub
parent
34f496eb3d
commit
622dff9ca7
+19
-1
@@ -15,16 +15,24 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! General tests for construct_runtime macro, test for:
|
||||
//! * error declareed with decl_error works
|
||||
//! * integrity test is generated
|
||||
|
||||
#![recursion_limit="128"]
|
||||
|
||||
use sp_runtime::{generic, traits::{BlakeTwo256, Block as _, Verify}, DispatchError};
|
||||
use sp_core::{H256, sr25519};
|
||||
|
||||
use sp_std::cell::RefCell;
|
||||
|
||||
mod system;
|
||||
|
||||
pub trait Currency {}
|
||||
|
||||
thread_local! {
|
||||
pub static INTEGRITY_TEST_EXEC: RefCell<u32> = RefCell::new(0);
|
||||
}
|
||||
|
||||
mod module1 {
|
||||
use super::*;
|
||||
|
||||
@@ -65,6 +73,10 @@ mod module2 {
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
Err(Error::<T>::Something.into())
|
||||
}
|
||||
|
||||
fn integrity_test() {
|
||||
INTEGRITY_TEST_EXEC.with(|i| *i.borrow_mut() += 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,3 +151,9 @@ fn check_module2_error_type() {
|
||||
Err(DispatchError::Module { index: 2, error: 0, message: Some("Something") }),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn integrity_test_works() {
|
||||
__construct_runtime_integrity_test::runtime_integrity_tests();
|
||||
assert_eq!(INTEGRITY_TEST_EXEC.with(|i| *i.borrow()), 1);
|
||||
}
|
||||
Reference in New Issue
Block a user