mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 02:17:58 +00:00
Use construct_runtime in tests (#8059)
* impl some more * add serde * remove unused * fix staking fuzz * fix system bench Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4b1460f61f
commit
0ed683ca13
@@ -15,24 +15,27 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::*;
|
||||
use crate::{self as frame_system, *};
|
||||
use sp_std::cell::RefCell;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
testing::Header,
|
||||
};
|
||||
use frame_support::{
|
||||
impl_outer_origin, parameter_types,
|
||||
weights::PostDispatchInfo,
|
||||
testing::Header, BuildStorage,
|
||||
};
|
||||
use frame_support::parameter_types;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test where system = super {}
|
||||
}
|
||||
type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = mocking::MockBlock<Test>;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Default)]
|
||||
pub struct Test;
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
const MAX_BLOCK_WEIGHT: Weight = 1024;
|
||||
@@ -81,20 +84,6 @@ impl OnKilledAccount<u64> for RecordKilled {
|
||||
fn on_killed_account(who: &u64) { KILLED.with(|r| r.borrow_mut().push(*who)) }
|
||||
}
|
||||
|
||||
#[derive(Debug, codec::Encode, codec::Decode)]
|
||||
pub struct Call;
|
||||
|
||||
impl Dispatchable for Call {
|
||||
type Origin = Origin;
|
||||
type Config = ();
|
||||
type Info = DispatchInfo;
|
||||
type PostInfo = PostDispatchInfo;
|
||||
fn dispatch(self, _origin: Self::Origin)
|
||||
-> sp_runtime::DispatchResultWithInfo<Self::PostInfo> {
|
||||
panic!("Do not use dummy implementation for dispatch.");
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type BaseCallFilter = ();
|
||||
type BlockWeights = RuntimeBlockWeights;
|
||||
@@ -108,11 +97,11 @@ impl Config for Test {
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event<Self>;
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type DbWeight = DbWeight;
|
||||
type Version = Version;
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = u32;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = RecordKilled;
|
||||
@@ -120,14 +109,15 @@ impl Config for Test {
|
||||
type SS58Prefix = ();
|
||||
}
|
||||
|
||||
pub type System = Module<Test>;
|
||||
pub type SysEvent = <Test as Config>::Event;
|
||||
pub type SysEvent = frame_system::Event<Test>;
|
||||
|
||||
pub const CALL: &<Test as Config>::Call = &Call;
|
||||
/// A simple call, which one doesn't matter.
|
||||
pub const CALL: &<Test as Config>::Call = &Call::System(frame_system::Call::set_heap_pages(0u64));
|
||||
|
||||
/// Create new externalities for `System` module tests.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut ext: sp_io::TestExternalities = GenesisConfig::default().build_storage::<Test>().unwrap().into();
|
||||
let mut ext: sp_io::TestExternalities = GenesisConfig::default()
|
||||
.build_storage().unwrap().into();
|
||||
// Add to each test the initial weight of a block
|
||||
ext.execute_with(|| System::register_extra_weight_unchecked(
|
||||
<Test as crate::Config>::BlockWeights::get().base_block,
|
||||
|
||||
Reference in New Issue
Block a user