mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 17:21:08 +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:
@@ -23,11 +23,9 @@ use support::{
|
||||
StorageValue, StorageMap, parameter_types, assert_ok,
|
||||
traits::{Get, ChangeMembers, Currency}
|
||||
};
|
||||
use runtime_io::with_externalities;
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use primitives::H256;
|
||||
use sr_primitives::{
|
||||
Perbill, BuildStorage,
|
||||
testing::Header,
|
||||
Perbill, BuildStorage, set_and_run_with_externalities, testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
|
||||
};
|
||||
use crate as elections;
|
||||
@@ -213,7 +211,7 @@ impl ExtBuilder {
|
||||
self.desired_seats = seats;
|
||||
self
|
||||
}
|
||||
pub fn build(self) -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
pub fn build(self) -> runtime_io::TestExternalities {
|
||||
VOTER_BOND.with(|v| *v.borrow_mut() = self.voter_bond);
|
||||
VOTING_FEE.with(|v| *v.borrow_mut() = self.voting_fee);
|
||||
PRESENT_SLASH_PER_VOTER.with(|v| *v.borrow_mut() = self.bad_presentation_punishment);
|
||||
@@ -283,9 +281,9 @@ pub(crate) fn locks(who: &u64) -> Vec<u64> {
|
||||
Balances::locks(who).iter().map(|l| l.amount).collect::<Vec<u64>>()
|
||||
}
|
||||
|
||||
pub(crate) fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
pub(crate) fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities {
|
||||
let mut t = ExtBuilder::default().build();
|
||||
with_externalities(&mut t, || {
|
||||
set_and_run_with_externalities(&mut t, || {
|
||||
<elections::Candidates<Test>>::put(vec![0, 0, 1]);
|
||||
elections::CandidateCount::put(1);
|
||||
<elections::RegisterInfoOf<Test>>::insert(1, (0, 2));
|
||||
|
||||
Reference in New Issue
Block a user