mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Add execute_with to TestExternalities (#3793)
This function executes the given closure in a context where the test externalities are set. This makes the srml tests easier to write, as the test externalities need to be created anyway.
This commit is contained in:
@@ -155,7 +155,6 @@ mod tests {
|
||||
use primitives::H256;
|
||||
use sr_primitives::{
|
||||
Perbill, traits::{BlakeTwo256, OnInitialize, Header as _, IdentityLookup}, testing::Header,
|
||||
set_and_run_with_externalities,
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types, traits::Randomness};
|
||||
|
||||
@@ -222,7 +221,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_random_material_parital() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
let genesis_hash = System::parent_hash();
|
||||
|
||||
setup_blocks(38);
|
||||
@@ -236,7 +235,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_random_material_filled() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
let genesis_hash = System::parent_hash();
|
||||
|
||||
setup_blocks(81);
|
||||
@@ -251,7 +250,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_random_material_filled_twice() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
let genesis_hash = System::parent_hash();
|
||||
|
||||
setup_blocks(162);
|
||||
@@ -266,7 +265,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_random() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
setup_blocks(162);
|
||||
|
||||
assert_eq!(System::block_number(), 162);
|
||||
|
||||
Reference in New Issue
Block a user