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:
Bastian Köcher
2019-10-10 15:01:30 +02:00
committed by GitHub
parent 34c7338211
commit 4dbc9265ee
44 changed files with 2369 additions and 2645 deletions
@@ -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);