Update Balances Pallet for decl_error! (#4405)

* Update balances for `decl_error!`

* Update for new `decl_error`

* Fix staking tests

* Use `ok_or` over `match`
This commit is contained in:
Shawn Tabrizi
2019-12-20 00:23:20 +01:00
committed by GitHub
parent dfe87ec61e
commit 4fffe19c28
5 changed files with 120 additions and 76 deletions
+11 -11
View File
@@ -27,7 +27,7 @@ use crate::{GenesisConfig, Module, Trait};
use frame_system as system;
impl_outer_origin!{
pub enum Origin for Runtime {}
pub enum Origin for Test {}
}
thread_local! {
@@ -53,14 +53,14 @@ impl Get<u64> for CreationFee {
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Runtime;
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for Runtime {
impl frame_system::Trait for Test {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
@@ -82,15 +82,15 @@ parameter_types! {
pub const TransactionBaseFee: u64 = 0;
pub const TransactionByteFee: u64 = 1;
}
impl pallet_transaction_payment::Trait for Runtime {
type Currency = Module<Runtime>;
impl pallet_transaction_payment::Trait for Test {
type Currency = Module<Test>;
type OnTransactionPayment = ();
type TransactionBaseFee = TransactionBaseFee;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = ConvertInto;
type FeeMultiplierUpdate = ();
}
impl Trait for Runtime {
impl Trait for Test {
type Balance = u64;
type OnFreeBalanceZero = ();
type OnNewAccount = ();
@@ -152,8 +152,8 @@ impl ExtBuilder {
}
pub fn build(self) -> sp_io::TestExternalities {
self.set_associated_consts();
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
GenesisConfig::<Runtime> {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
GenesisConfig::<Test> {
balances: if self.monied {
vec![
(1, 10 * self.existential_deposit),
@@ -179,10 +179,10 @@ impl ExtBuilder {
}
}
pub type System = frame_system::Module<Runtime>;
pub type Balances = Module<Runtime>;
pub type System = frame_system::Module<Test>;
pub type Balances = Module<Test>;
pub const CALL: &<Runtime as frame_system::Trait>::Call = &();
pub const CALL: &<Test as frame_system::Trait>::Call = &();
/// create a transaction info struct from weight. Handy to avoid building the whole struct.
pub fn info_from_weight(w: Weight) -> DispatchInfo {