mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-16 23:35:43 +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:
@@ -313,9 +313,7 @@ impl<T: Trait, D: AsRef<[u8]>> support::traits::KeyOwnerProofSystem<(KeyTypeId,
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::crypto::key_types::DUMMY;
|
||||
use sr_primitives::{
|
||||
traits::OnInitialize, testing::UintAuthorityId, set_and_run_with_externalities,
|
||||
};
|
||||
use sr_primitives::{traits::OnInitialize, testing::UintAuthorityId};
|
||||
use crate::mock::{
|
||||
NEXT_VALIDATORS, force_new_session,
|
||||
set_next_validators, Test, System, Session,
|
||||
@@ -336,7 +334,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn generated_proof_is_good() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
set_next_validators(vec![1, 2]);
|
||||
force_new_session();
|
||||
|
||||
@@ -377,7 +375,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn prune_up_to_works() {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
for i in 1..101u64 {
|
||||
set_next_validators(vec![i]);
|
||||
force_new_session();
|
||||
|
||||
Reference in New Issue
Block a user