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
+2 -5
View File
@@ -65,10 +65,7 @@ mod tests {
use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch};
use primitives::H256;
use sr_primitives::{
Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header,
set_and_run_with_externalities,
};
use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
impl_outer_origin! {
pub enum Origin for Test {}
@@ -150,7 +147,7 @@ mod tests {
#[test]
fn batch_works() {
set_and_run_with_externalities(&mut new_test_ext(), || {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(1), 10);
assert_eq!(Balances::free_balance(2), 0);
assert_noop!(Utility::batch(Origin::signed(1), vec![