mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +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:
@@ -250,7 +250,7 @@ mod tests {
|
||||
use runtime_io::TestExternalities;
|
||||
use primitives::H256;
|
||||
use sr_primitives::{
|
||||
set_and_run_with_externalities, testing::Header, Perbill,
|
||||
testing::Header, Perbill,
|
||||
traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT},
|
||||
};
|
||||
use support::{assert_ok, impl_outer_origin, parameter_types};
|
||||
@@ -322,7 +322,7 @@ mod tests {
|
||||
#[test]
|
||||
fn median_works() {
|
||||
let t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
set_and_run_with_externalities(&mut TestExternalities::new(t), || {
|
||||
TestExternalities::new(t).execute_with(|| {
|
||||
FinalityTracker::update_hint(Some(500));
|
||||
assert_eq!(FinalityTracker::median(), 250);
|
||||
assert!(NOTIFICATIONS.with(|n| n.borrow().is_empty()));
|
||||
@@ -332,7 +332,7 @@ mod tests {
|
||||
#[test]
|
||||
fn notifies_when_stalled() {
|
||||
let t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
set_and_run_with_externalities(&mut TestExternalities::new(t), || {
|
||||
TestExternalities::new(t).execute_with(|| {
|
||||
let mut parent_hash = System::parent_hash();
|
||||
for i in 2..106 {
|
||||
System::initialize(&i, &parent_hash, &Default::default(), &Default::default());
|
||||
@@ -351,7 +351,7 @@ mod tests {
|
||||
#[test]
|
||||
fn recent_notifications_prevent_stalling() {
|
||||
let t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
set_and_run_with_externalities(&mut TestExternalities::new(t), || {
|
||||
TestExternalities::new(t).execute_with(|| {
|
||||
let mut parent_hash = System::parent_hash();
|
||||
for i in 2..106 {
|
||||
System::initialize(&i, &parent_hash, &Default::default(), &Default::default());
|
||||
|
||||
Reference in New Issue
Block a user