mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 02:15:43 +00:00
Move Externalities into its own crate (#3775)
* Move `Externalities` into `substrate-externalities` - `Externalities` now support generic extensions - Split of `primtives-storage` for storage primitive types * Move the externalities scoping into `substrate-externalities` * Fix compilation * Review feedback * Adds macro for declaring extensions * Fix benchmarks * Introduce `ExtensionStore` trait * Last review comments * Implement it for `ExtensionStore`
This commit is contained in:
@@ -25,7 +25,7 @@ use sr_primitives::Perbill;
|
||||
use sr_staking_primitives::{SessionIndex, offence::ReportOffence};
|
||||
use sr_primitives::testing::{Header, UintAuthorityId, TestXt};
|
||||
use sr_primitives::traits::{IdentityLookup, BlakeTwo256, ConvertInto};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, impl_outer_dispatch, parameter_types};
|
||||
use {runtime_io, system};
|
||||
|
||||
@@ -85,7 +85,7 @@ impl ReportOffence<u64, IdentificationTuple, Offence> for OffenceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
pub fn new_test_ext() -> runtime_io::TestExternalities {
|
||||
let t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
use super::*;
|
||||
use crate::mock::*;
|
||||
use offchain::testing::TestOffchainExt;
|
||||
use primitives::offchain::OpaquePeerId;
|
||||
use runtime_io::with_externalities;
|
||||
use primitives::offchain::{OpaquePeerId, OffchainExt};
|
||||
use support::{dispatch, assert_noop};
|
||||
use sr_primitives::testing::UintAuthorityId;
|
||||
use sr_primitives::{set_and_run_with_externalities, testing::UintAuthorityId};
|
||||
|
||||
|
||||
#[test]
|
||||
@@ -49,7 +48,7 @@ fn test_unresponsiveness_slash_fraction() {
|
||||
|
||||
#[test]
|
||||
fn should_report_offline_validators() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
// given
|
||||
let block = 1;
|
||||
System::set_block_number(block);
|
||||
@@ -125,7 +124,7 @@ fn heartbeat(
|
||||
|
||||
#[test]
|
||||
fn should_mark_online_validator_when_heartbeat_is_received() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
advance_session();
|
||||
// given
|
||||
VALIDATORS.with(|l| *l.borrow_mut() = Some(vec![1, 2, 3, 4, 5, 6]));
|
||||
@@ -160,7 +159,7 @@ fn should_mark_online_validator_when_heartbeat_is_received() {
|
||||
|
||||
#[test]
|
||||
fn late_heartbeat_should_fail() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
advance_session();
|
||||
// given
|
||||
VALIDATORS.with(|l| *l.borrow_mut() = Some(vec![1, 2, 4, 4, 5, 6]));
|
||||
@@ -181,9 +180,9 @@ fn late_heartbeat_should_fail() {
|
||||
fn should_generate_heartbeats() {
|
||||
let mut ext = new_test_ext();
|
||||
let (offchain, state) = TestOffchainExt::new();
|
||||
ext.set_offchain_externalities(offchain);
|
||||
ext.register_extension(OffchainExt::new(offchain));
|
||||
|
||||
with_externalities(&mut ext, || {
|
||||
set_and_run_with_externalities(&mut ext, || {
|
||||
// given
|
||||
let block = 1;
|
||||
System::set_block_number(block);
|
||||
@@ -219,7 +218,7 @@ fn should_generate_heartbeats() {
|
||||
|
||||
#[test]
|
||||
fn should_cleanup_received_heartbeats_on_session_end() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(), || {
|
||||
advance_session();
|
||||
|
||||
VALIDATORS.with(|l| *l.borrow_mut() = Some(vec![1, 2, 3]));
|
||||
|
||||
Reference in New Issue
Block a user