mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 03:05:44 +00:00
Reorganising the repository - external renames and moves (#4074)
* Adding first rough ouline of the repository structure * Remove old CI stuff * add title * formatting fixes * move node-exits job's script to scripts dir * Move docs into subdir * move to bin * move maintainence scripts, configs and helpers into its own dir * add .local to ignore * move core->client * start up 'test' area * move test client * move test runtime * make test move compile * Add dependencies rule enforcement. * Fix indexing. * Update docs to reflect latest changes * Moving /srml->/paint * update docs * move client/sr-* -> primitives/ * clean old readme * remove old broken code in rhd * update lock * Step 1. * starting to untangle client * Fix after merge. * start splitting out client interfaces * move children and blockchain interfaces * Move trie and state-machine to primitives. * Fix WASM builds. * fixing broken imports * more interface moves * move backend and light to interfaces * move CallExecutor * move cli off client * moving around more interfaces * re-add consensus crates into the mix * fix subkey path * relieve client from executor * starting to pull out client from grandpa * move is_decendent_of out of client * grandpa still depends on client directly * lemme tests pass * rename srml->paint * Make it compile. * rename interfaces->client-api * Move keyring to primitives. * fixup libp2p dep * fix broken use * allow dependency enforcement to fail * move fork-tree * Moving wasm-builder * make env * move build-script-utils * fixup broken crate depdencies and names * fix imports for authority discovery * fix typo * update cargo.lock * fixing imports * Fix paths and add missing crates * re-add missing crates
This commit is contained in:
committed by
Bastian Köcher
parent
becc3b0a4f
commit
60e5011c72
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,144 @@
|
||||
// Copyright 2019
|
||||
// by Centrality Investments Ltd.
|
||||
// and Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Mocks for the module.
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use sr_primitives::{
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use primitives::H256;
|
||||
use support::{parameter_types, impl_outer_event, impl_outer_origin};
|
||||
|
||||
use super::*;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
// first constructing a configuration type (`Test`) which `impl`s each of the
|
||||
// configuration traits of modules we want to use.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Test;
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const MaximumBlockWeight: u32 = 1024;
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
}
|
||||
impl system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = ();
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
type Header = Header;
|
||||
type Event = TestEvent;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
}
|
||||
|
||||
impl Trait for Test {
|
||||
type Balance = u64;
|
||||
type AssetId = u32;
|
||||
type Event = TestEvent;
|
||||
}
|
||||
|
||||
mod generic_asset {
|
||||
pub use crate::Event;
|
||||
}
|
||||
|
||||
impl_outer_event! {
|
||||
pub enum TestEvent for Test {
|
||||
generic_asset<T>,
|
||||
}
|
||||
}
|
||||
|
||||
pub type GenericAsset = Module<Test>;
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
|
||||
pub struct ExtBuilder {
|
||||
asset_id: u32,
|
||||
next_asset_id: u32,
|
||||
accounts: Vec<u64>,
|
||||
initial_balance: u64,
|
||||
}
|
||||
|
||||
// Returns default values for genesis config
|
||||
impl Default for ExtBuilder {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
asset_id: 0,
|
||||
next_asset_id: 1000,
|
||||
accounts: vec![0],
|
||||
initial_balance: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtBuilder {
|
||||
// Sets free balance to genesis config
|
||||
pub fn free_balance(mut self, free_balance: (u32, u64, u64)) -> Self {
|
||||
self.asset_id = free_balance.0;
|
||||
self.accounts = vec![free_balance.1];
|
||||
self.initial_balance = free_balance.2;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn next_asset_id(mut self, asset_id: u32) -> Self {
|
||||
self.next_asset_id = asset_id;
|
||||
self
|
||||
}
|
||||
|
||||
// builds genesis config
|
||||
pub fn build(self) -> runtime_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
|
||||
GenesisConfig::<Test> {
|
||||
assets: vec![self.asset_id],
|
||||
endowed_accounts: self.accounts,
|
||||
initial_balance: self.initial_balance,
|
||||
next_asset_id: self.next_asset_id,
|
||||
staking_asset_id: 16000,
|
||||
spending_asset_id: 16001,
|
||||
}
|
||||
.assimilate_storage(&mut t).unwrap();
|
||||
|
||||
t.into()
|
||||
}
|
||||
}
|
||||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
pub fn new_test_ext() -> runtime_io::TestExternalities {
|
||||
system::GenesisConfig::default()
|
||||
.build_storage::<Test>()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user