mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +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:
@@ -101,7 +101,7 @@ impl Trait for Test {
|
||||
type EpochChangeTrigger = crate::ExternalTrigger;
|
||||
}
|
||||
|
||||
pub fn new_test_ext(authorities: Vec<DummyValidatorId>) -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
pub fn new_test_ext(authorities: Vec<DummyValidatorId>) -> runtime_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig {
|
||||
authorities: authorities.into_iter().map(|a| (UintAuthorityId(a).to_public_key(), 1)).collect(),
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
//! Consensus extension module tests for BABE consensus.
|
||||
|
||||
use super::*;
|
||||
use runtime_io::with_externalities;
|
||||
use mock::{new_test_ext, Babe, Test};
|
||||
use sr_primitives::{traits::OnFinalize, testing::{Digest, DigestItem}};
|
||||
use sr_primitives::{
|
||||
set_and_run_with_externalities, traits::OnFinalize, testing::{Digest, DigestItem},
|
||||
};
|
||||
use session::ShouldEndSession;
|
||||
|
||||
const EMPTY_RANDOMNESS: [u8; 32] = [
|
||||
@@ -53,14 +54,14 @@ fn empty_randomness_is_correct() {
|
||||
|
||||
#[test]
|
||||
fn initial_values() {
|
||||
with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
assert_eq!(Babe::authorities().len(), 4)
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_module() {
|
||||
with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
assert!(!Babe::should_end_session(0), "Genesis does not change sessions");
|
||||
assert!(!Babe::should_end_session(200000),
|
||||
"BABE does not include the block number in epoch calculations");
|
||||
@@ -71,7 +72,7 @@ type System = system::Module<Test>;
|
||||
|
||||
#[test]
|
||||
fn first_block_epoch_zero_start() {
|
||||
with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
let genesis_slot = 100;
|
||||
let first_vrf = [1; 32];
|
||||
let pre_digest = make_pre_digest(
|
||||
@@ -119,7 +120,7 @@ fn first_block_epoch_zero_start() {
|
||||
|
||||
#[test]
|
||||
fn authority_index() {
|
||||
with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
set_and_run_with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || {
|
||||
assert_eq!(
|
||||
Babe::find_author((&[(BABE_ENGINE_ID, &[][..])]).into_iter().cloned()), None,
|
||||
"Trivially invalid authorities are ignored")
|
||||
|
||||
Reference in New Issue
Block a user