mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 15:07:59 +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:
@@ -72,8 +72,7 @@ mod tests {
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, assert_ok, parameter_types};
|
||||
use sr_primitives::{
|
||||
set_and_run_with_externalities, traits::{BlakeTwo256, IdentityLookup}, testing::Header,
|
||||
weights::Weight, Perbill,
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header, weights::Weight, Perbill,
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
@@ -122,7 +121,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn it_works_for_default_value() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Just a dummy test for the dummy funtion `do_something`
|
||||
// calling the `do_something` function with a value 42
|
||||
assert_ok!(TemplateModule::do_something(Origin::signed(1), 42));
|
||||
|
||||
Reference in New Issue
Block a user