Update to Substrate master (#311)

* Best effort to bring up to date.

* Fix the executor stuff

* Update verisons.

* Finish fixing

* Final fixes and warnings.

* add some docs and bump Wasm versions

* Fix tests

* Fix final test
This commit is contained in:
Gavin Wood
2019-07-04 17:15:59 +02:00
committed by GitHub
parent 6377974ed7
commit 29ee4e8f3a
24 changed files with 808 additions and 625 deletions
+16 -2
View File
@@ -197,7 +197,7 @@ mod tests {
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use sr_primitives::{
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::Header
traits::{BlakeTwo256, IdentityLookup}, testing::Header
};
use balances;
use srml_support::{impl_outer_origin, assert_ok, assert_err, assert_noop, parameter_types};
@@ -222,6 +222,15 @@ mod tests {
type Header = Header;
type Event = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const TransferFee: u64 = 0;
pub const CreationFee: u64 = 0;
pub const TransactionBaseFee: u64 = 0;
pub const TransactionByteFee: u64 = 0;
}
impl balances::Trait for Test {
type Balance = u64;
type OnFreeBalanceZero = ();
@@ -230,6 +239,11 @@ mod tests {
type TransactionPayment = ();
type DustRemoval = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
type TransferFee = TransferFee;
type CreationFee = CreationFee;
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee;
}
parameter_types!{
@@ -274,7 +288,7 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
// We use default for brevity, but you can configure as desired if needed.
t.extend(balances::GenesisConfig::<Test>::default().build_storage().unwrap().0);
t.extend(GenesisConfig::<Test>{
+109 -12
View File
@@ -48,7 +48,9 @@ use council::seats as council_seats;
#[cfg(any(feature = "std", test))]
use version::NativeVersion;
use substrate_primitives::OpaqueMetadata;
use srml_support::{parameter_types, construct_runtime};
use srml_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency, OnUnbalanced}
};
#[cfg(feature = "std")]
pub use staking::StakerStatus;
@@ -80,6 +82,16 @@ pub fn native_version() -> NativeVersion {
}
}
const DOTS: Balance = 1_000_000_000_000;
const BUCKS: Balance = DOTS / 100;
const CENTS: Balance = BUCKS / 100;
const MILLICENTS: Balance = CENTS / 1_000;
const SECS_PER_BLOCK: BlockNumber = 10;
const MINUTES: BlockNumber = 60 / SECS_PER_BLOCK;
const HOURS: BlockNumber = MINUTES * 60;
const DAYS: BlockNumber = HOURS * 24;
impl system::Trait for Runtime {
type Origin = Origin;
type Index = Nonce;
@@ -104,14 +116,46 @@ impl indices::Trait for Runtime {
type Event = Event;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 1 * BUCKS;
pub const TransferFee: Balance = 1 * CENTS;
pub const CreationFee: Balance = 1 * CENTS;
pub const TransactionBaseFee: Balance = 1 * CENTS;
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
}
/// Logic for the author to get a portion of fees.
pub struct ToAuthor;
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
impl OnUnbalanced<NegativeImbalance> for ToAuthor {
fn on_unbalanced(amount: NegativeImbalance) {
Balances::resolve_creating(&Authorship::author(), amount);
}
}
/// Splits fees 80/20 between treasury and block author.
pub type DealWithFees = SplitTwoWays<
Balance,
NegativeImbalance,
_4, Treasury, // 4 parts (80%) goes to the treasury.
_1, ToAuthor, // 1 part (20%) goes to the block author.
>;
impl balances::Trait for Runtime {
type Balance = Balance;
type OnFreeBalanceZero = Staking;
type OnNewAccount = Indices;
type Event = Event;
type TransactionPayment = ();
type TransactionPayment = DealWithFees;
type DustRemoval = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
type TransferFee = TransferFee;
type CreationFee = CreationFee;
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee;
}
impl timestamp::Trait for Runtime {
@@ -119,6 +163,18 @@ impl timestamp::Trait for Runtime {
type OnTimestampSet = Aura;
}
parameter_types! {
pub const UncleGenerations: u64 = 0;
}
// TODO: substrate#2986 implement this properly
impl authorship::Trait for Runtime {
type FindAuthor = ();
type UncleGenerations = UncleGenerations;
type FilterUncle = ();
type EventHandler = ();
}
parameter_types! {
pub const Period: BlockNumber = 10 * MINUTES;
pub const Offset: BlockNumber = 0;
@@ -174,9 +230,6 @@ impl staking::Trait for Runtime {
type BondingDuration = BondingDuration;
}
const MINUTES: BlockNumber = 6;
const BUCKS: Balance = 1_000_000_000_000;
parameter_types! {
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
@@ -203,6 +256,18 @@ impl democracy::Trait for Runtime {
type CooloffPeriod = CooloffPeriod;
}
parameter_types! {
pub const CandidacyBond: Balance = 10 * BUCKS;
pub const VotingBond: Balance = 1 * BUCKS;
pub const VotingFee: Balance = 2 * BUCKS;
pub const PresentSlashPerVoter: Balance = 1 * CENTS;
pub const CarryCount: u32 = 6;
// one additional vote should go by before an inactive voter can be reaped.
pub const InactiveGracePeriod: council::VoteIndex = 1;
pub const CouncilVotingPeriod: BlockNumber = 2 * DAYS;
pub const DecayRatio: u32 = 0;
}
impl council::Trait for Runtime {
type Event = Event;
type BadPresentation = ();
@@ -210,6 +275,14 @@ impl council::Trait for Runtime {
type BadVoterIndex = ();
type LoserCandidate = ();
type OnMembersChanged = CouncilMotions;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type VotingFee = VotingFee;
type PresentSlashPerVoter = PresentSlashPerVoter;
type CarryCount = CarryCount;
type InactiveGracePeriod = InactiveGracePeriod;
type CouncilVotingPeriod = CouncilVotingPeriod;
type DecayRatio = DecayRatio;
}
impl council::motions::Trait for Runtime {
@@ -218,19 +291,41 @@ impl council::motions::Trait for Runtime {
type Event = Event;
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 1 * BUCKS;
pub const SpendPeriod: BlockNumber = 1 * DAYS;
pub const Burn: Permill = Permill::from_percent(50);
}
impl treasury::Trait for Runtime {
type Currency = balances::Module<Self>;
type Currency = Balances;
type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>;
type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>;
type Event = Event;
type MintedForSpending = ();
type ProposalRejection = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
}
impl grandpa::Trait for Runtime {
type Event = Event;
}
parameter_types! {
pub const WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub const ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
}
impl finality_tracker::Trait for Runtime {
type OnFinalizationStalled = Grandpa;
type WindowSize = WindowSize;
type ReportLatency = ReportLatency;
}
impl parachains::Trait for Runtime {
type Origin = Origin;
type Call = Call;
@@ -263,20 +358,22 @@ construct_runtime!(
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system,
System: system::{Module, Call, Storage, Config, Event},
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
Authorship: authorship::{Module, Call, Storage},
Indices: indices,
Balances: balances,
Session: session::{Module, Call, Storage, Event, Config<T>},
Staking: staking,
Democracy: democracy,
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Event},
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
Staking: staking::{default, OfflineWorker},
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
Council: council::{Module, Call, Storage, Event<T>},
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin<T>},
CouncilSeats: council_seats::{Config<T>},
Treasury: treasury,
FinalityTracker: finality_tracker::{Module, Call, Inherent},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
Treasury: treasury::{Module, Call, Storage, Event<T>},
Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent, Origin},
Slots: slots::{Module, Call, Storage, Event<T>},
Sudo: sudo,
+56 -43
View File
@@ -93,7 +93,7 @@ pub trait ParachainRegistrar<AccountId> {
impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
type ParaId = ParaId;
fn new_id() -> ParaId {
<NextFreeId<T>>::mutate(|n| { let r = *n; *n = ParaId::from(u32::from(*n) + 1); r })
<NextFreeId>::mutate(|n| { let r = *n; *n = ParaId::from(u32::from(*n) + 1); r })
}
fn register_parachain(id: ParaId, code: Vec<u8>, initial_head_data: Vec<u8>) -> Result {
let mut parachains = Self::active_parachains();
@@ -102,9 +102,9 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
Err(idx) => parachains.insert(idx, id),
}
<Code<T>>::insert(id, code);
<Parachains<T>>::put(parachains);
<Heads<T>>::insert(id, initial_head_data);
<Code>::insert(id, code);
<Parachains>::put(parachains);
<Heads>::insert(id, initial_head_data);
// Because there are no ordering guarantees that inherents
// are applied before regular transactions, a parachain candidate could
@@ -121,8 +121,8 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
Err(_) => return Ok(()),
}
<Code<T>>::remove(id);
<Heads<T>>::remove(id);
<Code>::remove(id);
<Heads>::remove(id);
let watermark = <Watermarks<T>>::take(id);
@@ -137,7 +137,7 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
}
}
<Parachains<T>>::put(parachains);
<Parachains>::put(parachains);
Ok(())
}
@@ -249,12 +249,12 @@ decl_storage! {
let only_ids: Vec<_> = p.iter().map(|&(ref id, _, _)| id).cloned().collect();
<Parachains<T> as generator::StorageValue<_>>::put(&only_ids, storage);
<Parachains as generator::StorageValue<_>>::put(&only_ids, storage);
for (id, code, genesis) in p {
// no ingress -- a chain cannot be routed to until it is live.
<Code<T> as generator::StorageMap<_, _>>::insert(&id, &code, storage);
<Heads<T> as generator::StorageMap<_, _>>::insert(&id, &genesis, storage);
<Code as generator::StorageMap<_, _>>::insert(&id, &code, storage);
<Heads as generator::StorageMap<_, _>>::insert(&id, &genesis, storage);
<Watermarks<T> as generator::StorageMap<_, _>>::insert(&id, &Zero::zero(), storage);
}
});
@@ -267,7 +267,7 @@ decl_module! {
/// Provide candidate receipts for parachains, in ascending order by id.
fn set_heads(origin, heads: Vec<AttestedCandidate>) -> Result {
ensure_none(origin)?;
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
ensure!(!<DidUpdate>::exists(), "Parachain heads must be updated only once in the block");
let active_parachains = Self::active_parachains();
let parachain_count = active_parachains.len();
@@ -322,7 +322,7 @@ decl_module! {
);
}
<DidUpdate<T>>::put(true);
<DidUpdate>::put(true);
Ok(())
}
@@ -385,7 +385,7 @@ impl<T: Trait> Module<T> {
) -> Result {
// Either there are no more messages to add...
if !upward_messages.is_empty() {
let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
let (count, size) = <RelayDispatchQueueSize>::get(id);
ensure!(
// ...or we are appending one message onto an empty queue...
upward_messages.len() + count as usize == 1
@@ -421,7 +421,7 @@ impl<T: Trait> Module<T> {
for head in heads.iter() {
let id = head.parachain_index();
<Heads<T>>::insert(id, &head.candidate.head_data.0);
<Heads>::insert(id, &head.candidate.head_data.0);
let last_watermark = <Watermarks<T>>::mutate(id, |mark| {
rstd::mem::replace(mark, Some(watermark))
@@ -452,14 +452,14 @@ impl<T: Trait> Module<T> {
/// Place any new upward messages into our queue for later dispatch.
fn queue_upward_messages(id: ParaId, upward_messages: &[UpwardMessage]) {
if !upward_messages.is_empty() {
<RelayDispatchQueueSize<T>>::mutate(id, |&mut(ref mut count, ref mut len)| {
<RelayDispatchQueueSize>::mutate(id, |&mut(ref mut count, ref mut len)| {
*count += upward_messages.len() as u32;
*len += upward_messages.iter()
.fold(0, |a, x| a + x.data.len()) as u32;
});
// Should never be able to fail assuming our state is uncorrupted, but best not
// to panic, even if it does.
let _ = <RelayDispatchQueue<T>>::append(id, upward_messages);
let _ = <RelayDispatchQueue>::append(id, upward_messages);
}
}
@@ -480,7 +480,7 @@ impl<T: Trait> Module<T> {
let mut dispatched_count = 0usize;
let mut dispatched_size = 0usize;
for id in active_parachains.iter().cycle().skip(offset).take(para_count) {
let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
let (count, size) = <RelayDispatchQueueSize>::get(id);
let count = count as usize;
let size = size as usize;
if dispatched_count == 0 || (
@@ -489,8 +489,8 @@ impl<T: Trait> Module<T> {
) {
if count > 0 {
// still dispatching messages...
<RelayDispatchQueueSize<T>>::remove(id);
let messages = <RelayDispatchQueue<T>>::take(id);
<RelayDispatchQueueSize>::remove(id);
let messages = <RelayDispatchQueue>::take(id);
for UpwardMessage { origin, data } in messages.into_iter() {
dispatch_message(*id, origin, &data);
}
@@ -816,7 +816,7 @@ mod tests {
use substrate_primitives::{H256, Blake2Hasher};
use substrate_trie::NodeCodec;
use sr_primitives::{
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::UintAuthorityId,
traits::{BlakeTwo256, IdentityLookup}, testing::UintAuthorityId,
};
use primitives::{
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey,
@@ -877,6 +877,14 @@ mod tests {
type AuthorityId = AuraId;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 0;
pub const TransferFee: Balance = 0;
pub const CreationFee: Balance = 0;
pub const TransactionBaseFee: Balance = 0;
pub const TransactionByteFee: Balance = 0;
}
impl balances::Trait for Test {
type Balance = Balance;
type OnFreeBalanceZero = ();
@@ -885,6 +893,11 @@ mod tests {
type TransactionPayment = ();
type DustRemoval = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
type TransferFee = TransferFee;
type CreationFee = CreationFee;
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee;
}
parameter_types! {
@@ -913,7 +926,7 @@ mod tests {
type System = system::Module<Test>;
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities<Blake2Hasher> {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
let authority_keys = [
AuthorityKeyring::Alice,
AuthorityKeyring::Bob,
@@ -1049,8 +1062,8 @@ mod tests {
assert_eq!(dispatched, vec![
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 4])
]);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
});
with_externalities(&mut new_test_ext(parachains.clone()), || {
let parachains = vec![0.into(), 1.into(), 2.into()];
@@ -1070,9 +1083,9 @@ mod tests {
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2]),
(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
]);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
});
with_externalities(&mut new_test_ext(parachains.clone()), || {
let parachains = vec![0.into(), 1.into(), 2.into()];
@@ -1092,9 +1105,9 @@ mod tests {
(1.into(), ParachainDispatchOrigin::Parachain, vec![1; 2]),
(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
]);
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).len(), 1);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(0)).len(), 1);
assert!(<RelayDispatchQueue>::get(ParaId::from(1)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
});
with_externalities(&mut new_test_ext(parachains.clone()), || {
let parachains = vec![0.into(), 1.into(), 2.into()];
@@ -1114,9 +1127,9 @@ mod tests {
(2.into(), ParachainDispatchOrigin::Parachain, vec![2]),
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2])
]);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
});
}
@@ -1140,7 +1153,7 @@ mod tests {
];
assert_ok!(Parachains::check_upward_messages(0.into(), &messages, 2, 3));
Parachains::queue_upward_messages(0.into(), &messages);
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)), vec![
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(0)), vec![
UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1, 2] },
]);
@@ -1288,8 +1301,8 @@ mod tests {
Origin::NONE,
));
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
assert!(<RelayDispatchQueue>::get(ParaId::from(1)).is_empty());
});
}
@@ -1436,10 +1449,10 @@ mod tests {
Origin::NONE,
).is_err());
assert!(Parachains::dispatch(
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
Origin::NONE,
).is_ok());
));
});
}
@@ -1527,19 +1540,19 @@ mod tests {
make_attestations(&mut candidate_a);
make_attestations(&mut candidate_b);
assert!(Parachains::dispatch(
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_a, candidate_b]),
Origin::NONE,
).is_ok());
));
Parachains::on_finalize(i);
}
System::set_block_number(10);
assert!(Parachains::dispatch(
assert_ok!(Parachains::dispatch(
set_heads(vec![]),
Origin::NONE,
).is_ok());
));
// parachain 1 has had a bunch of parachain candidates included,
// which raises the watermark.
@@ -1588,10 +1601,10 @@ mod tests {
};
make_attestations(&mut candidate_c);
assert!(Parachains::dispatch(
assert_ok!(Parachains::dispatch(
set_heads(vec![candidate_c]),
Origin::NONE,
).is_ok());
));
Parachains::on_finalize(11);
System::set_block_number(12);
+20 -13
View File
@@ -250,7 +250,7 @@ decl_module! {
ensure!(lease_period_index >= Self::lease_period_index(), "lease period in past");
// Bump the counter.
let n = <AuctionCounter<T>>::mutate(|n| { *n += 1; *n });
let n = <AuctionCounter>::mutate(|n| { *n += 1; *n });
// Set the information.
let ending = <system::Module<T>>::block_number() + duration;
@@ -639,7 +639,7 @@ impl<T: Trait> Module<T> {
amount: BalanceOf<T>
) -> Result<(), &'static str> {
// Bidding on latest auction.
ensure!(auction_index == <AuctionCounter<T>>::get(), "not current auction");
ensure!(auction_index == <AuctionCounter>::get(), "not current auction");
// Assume it's actually an auction (this should never fail because of above).
let (first_lease_period, _) = <AuctionInfo<T>>::get().ok_or("not an auction")?;
@@ -781,8 +781,7 @@ mod tests {
use substrate_primitives::{Blake2Hasher, H256};
use sr_io::with_externalities;
use sr_primitives::{
BuildStorage, testing::Header,
traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
};
use srml_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
use balances;
@@ -809,14 +808,27 @@ mod tests {
type Event = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 0;
pub const TransferFee: u64 = 0;
pub const CreationFee: u64 = 0;
pub const TransactionBaseFee: u64 = 0;
pub const TransactionByteFee: u64 = 0;
}
impl balances::Trait for Test {
type Balance = u64;
type OnFreeBalanceZero = ();
type OnNewAccount = ();
type TransactionPayment = ();
type TransferPayment = ();
type DustRemoval = ();
type Event = ();
type TransactionPayment = ();
type DustRemoval = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
type TransferFee = TransferFee;
type CreationFee = CreationFee;
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee;
}
thread_local! {
@@ -886,14 +898,9 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
t.extend(balances::GenesisConfig::<Test>{
transaction_base_fee: 0,
transaction_byte_fee: 0,
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
existential_deposit: 0,
transfer_fee: 0,
creation_fee: 0,
vesting: vec![],
}.build_storage().unwrap().0);
t.into()