Rename pallet trait Trait to Config (#7599)

* rename Trait to Config

* add test asserting using Trait is still valid.

* fix ui tests
This commit is contained in:
Guillaume Thiolliere
2020-11-30 15:34:54 +01:00
committed by GitHub
parent dd3c84c362
commit 1cbfc9257f
200 changed files with 1767 additions and 1607 deletions
+20 -20
View File
@@ -145,7 +145,7 @@ pub type OriginOf<E, C> = <CallOf<E, C> as Dispatchable>::Origin;
/// Main entry point for certain runtime actions as e.g. `execute_block`.
///
/// Generic parameters:
/// - `System`: Something that implements `frame_system::Trait`
/// - `System`: Something that implements `frame_system::Config`
/// - `Block`: The block type of the runtime
/// - `Context`: The context that is used when checking an extrinsic.
/// - `UnsignedValidator`: The unsigned transaction validator of the runtime.
@@ -158,7 +158,7 @@ pub struct Executive<System, Block, Context, UnsignedValidator, AllModules, OnRu
);
impl<
System: frame_system::Trait,
System: frame_system::Config,
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
Context: Default,
UnsignedValidator,
@@ -185,7 +185,7 @@ where
}
impl<
System: frame_system::Trait,
System: frame_system::Config,
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
Context: Default,
UnsignedValidator,
@@ -505,10 +505,10 @@ mod tests {
UnknownTransaction, TransactionSource, TransactionValidity
};
pub trait Trait: frame_system::Trait {}
pub trait Config: frame_system::Config {}
frame_support::decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
#[weight = 100]
fn some_function(origin) {
// NOTE: does not make any different.
@@ -555,7 +555,7 @@ mod tests {
}
}
impl<T: Trait> sp_runtime::traits::ValidateUnsigned for Module<T> {
impl<T: Config> sp_runtime::traits::ValidateUnsigned for Module<T> {
type Call = Call<T>;
fn validate_unsigned(
@@ -594,7 +594,7 @@ mod tests {
write: 100,
};
}
impl frame_system::Trait for Runtime {
impl frame_system::Config for Runtime {
type BaseCallFilter = ();
type Origin = Origin;
type Index = u64;
@@ -626,7 +626,7 @@ mod tests {
parameter_types! {
pub const ExistentialDeposit: Balance = 1;
}
impl pallet_balances::Trait for Runtime {
impl pallet_balances::Config for Runtime {
type Balance = Balance;
type Event = Event;
type DustRemoval = ();
@@ -639,13 +639,13 @@ mod tests {
parameter_types! {
pub const TransactionByteFee: Balance = 0;
}
impl pallet_transaction_payment::Trait for Runtime {
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
}
impl custom::Trait for Runtime {}
impl custom::Config for Runtime {}
pub struct RuntimeVersion;
impl frame_support::traits::Get<sp_version::RuntimeVersion> for RuntimeVersion {
@@ -668,8 +668,8 @@ mod tests {
type TestXt = sp_runtime::testing::TestXt<Call, SignedExtra>;
type TestBlock = Block<TestXt>;
type TestUncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<
<Runtime as frame_system::Trait>::AccountId,
<Runtime as frame_system::Trait>::Call,
<Runtime as frame_system::Config>::AccountId,
<Runtime as frame_system::Config>::Call,
(),
SignedExtra,
>;
@@ -715,9 +715,9 @@ mod tests {
balances: vec![(1, 211)],
}.assimilate_storage(&mut t).unwrap();
let xt = TestXt::new(Call::Balances(BalancesCall::transfer(2, 69)), sign_extra(1, 0, 0));
let weight = xt.get_dispatch_info().weight + <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
let weight = xt.get_dispatch_info().weight + <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
let fee: Balance
= <Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight);
= <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight);
let mut t = sp_io::TestExternalities::new(t);
t.execute_with(|| {
Executive::initialize_block(&Header::new(
@@ -818,7 +818,7 @@ mod tests {
let encoded = xt.encode();
let encoded_len = encoded.len() as Weight;
// on_initialize weight + block execution weight
let base_block_weight = 175 + <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
let base_block_weight = 175 + <Runtime as frame_system::Config>::BlockExecutionWeight::get();
let limit = AvailableBlockRatio::get() * MaximumBlockWeight::get() - base_block_weight;
let num_to_exhaust_block = limit / (encoded_len + 5);
t.execute_with(|| {
@@ -861,7 +861,7 @@ mod tests {
let mut t = new_test_ext(1);
t.execute_with(|| {
// Block execution weight + on_initialize weight from custom module
let base_block_weight = 175 + <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
let base_block_weight = 175 + <Runtime as frame_system::Config>::BlockExecutionWeight::get();
Executive::initialize_block(&Header::new(
1,
@@ -879,7 +879,7 @@ mod tests {
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());
// default weight for `TestXt` == encoded length.
let extrinsic_weight = len as Weight + <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
let extrinsic_weight = len as Weight + <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
assert_eq!(
<frame_system::Module<Runtime>>::block_weight().total(),
base_block_weight + 3 * extrinsic_weight,
@@ -946,9 +946,9 @@ mod tests {
sign_extra(1, 0, 0),
);
let weight = xt.get_dispatch_info().weight
+ <Runtime as frame_system::Trait>::ExtrinsicBaseWeight::get();
+ <Runtime as frame_system::Config>::ExtrinsicBaseWeight::get();
let fee: Balance =
<Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight);
<Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight);
Executive::initialize_block(&Header::new(
1,
H256::default(),
@@ -1106,7 +1106,7 @@ mod tests {
let runtime_upgrade_weight = <AllModules as OnRuntimeUpgrade>::on_runtime_upgrade();
let frame_system_on_initialize_weight = frame_system::Module::<Runtime>::on_initialize(block_number);
let on_initialize_weight = <AllModules as OnInitialize<u64>>::on_initialize(block_number);
let base_block_weight = <Runtime as frame_system::Trait>::BlockExecutionWeight::get();
let base_block_weight = <Runtime as frame_system::Config>::BlockExecutionWeight::get();
// Weights are recorded correctly
assert_eq!(