referrerpolicy=no-referrer-when-downgrade

Module testing_prelude

Source
Expand description

The main testing prelude of FRAME.

A test setup typically starts with:

use polkadot_sdk_frame::testing_prelude::*;
// rest of your test setup.

This automatically brings in polkadot_sdk_frame::prelude::* and polkadot_sdk_frame::runtime::prelude::*.

Re-exports§

pub use frame_system;
pub use crate::prelude::*;
pub use crate::runtime::prelude::*;
pub use super::runtime::testing_prelude::*;

Macros§

assert_err
Other helper macros from frame_support that help with asserting in tests. Assert an expression returns an error specified.
assert_err_ignore_postinfo
Other helper macros from frame_support that help with asserting in tests. Assert an expression returns an error specified.
assert_error_encoded_size
Other helper macros from frame_support that help with asserting in tests. Assert that the maximum encoding size does not exceed the value defined in [MAX_MODULE_ERROR_ENCODED_SIZE] during compilation.
assert_noop
Other helper macros from frame_support that help with asserting in tests. Evaluate an expression, assert it returns an expected Err value and that runtime storage has not been mutated (i.e. expression is a no-operation).
assert_ok
Other helper macros from frame_support that help with asserting in tests. Panic if an expression doesn’t evaluate to Ok.
assert_storage_noop
Other helper macros from frame_support that help with asserting in tests. Evaluate any expression and assert that runtime storage has not been mutated (i.e. expression is a storage no-operation).
defensive
Other helper macros from frame_support that help with asserting in tests. Generic function to mark an execution path as ONLY defensive.
ensure
Other helper macros from frame_support that help with asserting in tests. Evaluate $x:expr and if not true return Err($y:expr).
hypothetically
Other helper macros from frame_support that help with asserting in tests. Do something hypothetically by rolling back any changes afterwards.
hypothetically_ok
Other helper macros from frame_support that help with asserting in tests. Assert something to be hypothetically Ok, without actually committing it.

Structs§

BadOrigin
Commonly used runtime traits for testing. An error type that indicates that the origin is invalid.
RunToBlockHooks
Hooks for the Pallet::run_to_block_with function.
StorageNoopGuard
Other helper macros from frame_support that help with asserting in tests. Asserts that no storage changes took place between con- and destruction of Self.

Enums§

Everything
A Contains implementation that contains every value.
StateVersion
Commonly used runtime traits for testing. Different possible state version.

Type Aliases§

MockBlock
An implementation of sp_runtime::traits::Block to be used in tests.
MockBlockU32
An implementation of sp_runtime::traits::Block to be used in tests with u32 BlockNumber type.
MockBlockU128
An implementation of sp_runtime::traits::Block to be used in tests with u128 BlockNumber type.
MockUncheckedExtrinsic
An unchecked extrinsic type to be used in tests.
TestExternalities
Type alias for Externalities implementation used in tests.
TestState
Type alias for Externalities implementation used in tests.

Attribute Macros§

storage_alias
Other helper macros from frame_support that help with asserting in tests.