|
| 1 | +use crate as pallet_sugondat_length_fee_adjustment; |
| 2 | +use frame_support::{ |
| 3 | + parameter_types, |
| 4 | + traits::ConstU64, |
| 5 | + weights::{Weight, WeightToFee as WeightToFeeT}, |
| 6 | +}; |
| 7 | +use pallet_transaction_payment::Multiplier; |
| 8 | +use sp_core::H256; |
| 9 | +use sp_runtime::{ |
| 10 | + traits::{BlakeTwo256, IdentityLookup}, |
| 11 | + FixedPointNumber, Perquintill, SaturatedConversion, |
| 12 | +}; |
| 13 | + |
| 14 | +type Block = frame_system::mocking::MockBlock<Test>; |
| 15 | +type Balance = u64; |
| 16 | + |
| 17 | +frame_support::construct_runtime!( |
| 18 | + pub enum Test { |
| 19 | + System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, |
| 20 | + Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, |
| 21 | + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>}, |
| 22 | + LengthFeeAdjustment: pallet_sugondat_length_fee_adjustment::{Pallet, Storage}, |
| 23 | + } |
| 24 | +); |
| 25 | + |
| 26 | +parameter_types! { |
| 27 | + pub const BlockHashCount: u64 = 250; |
| 28 | + pub const SS58Prefix: u8 = 42; |
| 29 | +} |
| 30 | + |
| 31 | +impl frame_system::Config for Test { |
| 32 | + type BaseCallFilter = frame_support::traits::Everything; |
| 33 | + type BlockWeights = (); |
| 34 | + type BlockLength = (); |
| 35 | + type DbWeight = (); |
| 36 | + type RuntimeOrigin = RuntimeOrigin; |
| 37 | + type RuntimeCall = RuntimeCall; |
| 38 | + type Nonce = u64; |
| 39 | + type Hash = H256; |
| 40 | + type Hashing = BlakeTwo256; |
| 41 | + type AccountId = u64; |
| 42 | + type Lookup = IdentityLookup<Self::AccountId>; |
| 43 | + type Block = Block; |
| 44 | + type RuntimeEvent = RuntimeEvent; |
| 45 | + type BlockHashCount = BlockHashCount; |
| 46 | + type Version = (); |
| 47 | + type PalletInfo = PalletInfo; |
| 48 | + type AccountData = pallet_balances::AccountData<u64>; |
| 49 | + type OnNewAccount = (); |
| 50 | + type OnKilledAccount = (); |
| 51 | + type SystemWeightInfo = (); |
| 52 | + type SS58Prefix = SS58Prefix; |
| 53 | + type OnSetCode = (); |
| 54 | + type MaxConsumers = frame_support::traits::ConstU32<16>; |
| 55 | +} |
| 56 | + |
| 57 | +impl pallet_balances::Config for Test { |
| 58 | + type Balance = u64; |
| 59 | + type RuntimeEvent = RuntimeEvent; |
| 60 | + type DustRemoval = (); |
| 61 | + type ExistentialDeposit = ConstU64<1>; |
| 62 | + type AccountStore = System; |
| 63 | + type MaxLocks = (); |
| 64 | + type MaxReserves = (); |
| 65 | + type ReserveIdentifier = [u8; 8]; |
| 66 | + type WeightInfo = (); |
| 67 | + type FreezeIdentifier = (); |
| 68 | + type MaxFreezes = (); |
| 69 | + type RuntimeHoldReason = (); |
| 70 | + type RuntimeFreezeReason = (); |
| 71 | + type MaxHolds = (); |
| 72 | +} |
| 73 | + |
| 74 | +parameter_types! { |
| 75 | + pub TransactionByteFee: Balance = 333333u64; |
| 76 | + pub TargetBlockFullness: Perquintill = Perquintill::from_percent(25); |
| 77 | + pub AdjustmentVariableBlockFullness: Multiplier = Multiplier::saturating_from_rational(75, 1_000_000); |
| 78 | + pub MinimumMultiplierBlockFullness: Multiplier = Multiplier::saturating_from_rational(1, 10u128); |
| 79 | + pub MaximumMultiplierBlockFullness: Multiplier = Multiplier::saturating_from_integer(10); |
| 80 | + pub MaximumBlockLength: u32 = 5 * 1024 * 1024; |
| 81 | + pub AdjustmentVariableBlockSize: Multiplier = Multiplier::saturating_from_rational(1, 840); |
| 82 | + pub MinimumMultiplierBlockSize: Multiplier = Multiplier::saturating_from_rational(1, 10u128); |
| 83 | + pub MaximumMultiplierBlockSize: Multiplier = Multiplier::saturating_from_integer(10); |
| 84 | + |
| 85 | + pub static WeightToFee: u64 = 1; |
| 86 | + pub static OperationalFeeMultiplier: u8 = 5; |
| 87 | +} |
| 88 | + |
| 89 | +impl WeightToFeeT for WeightToFee { |
| 90 | + type Balance = u64; |
| 91 | + |
| 92 | + fn weight_to_fee(weight: &Weight) -> Self::Balance { |
| 93 | + Self::Balance::saturated_from(weight.ref_time()) |
| 94 | + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | +impl pallet_transaction_payment::Config for Test { |
| 99 | + type RuntimeEvent = RuntimeEvent; |
| 100 | + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>; |
| 101 | + type OperationalFeeMultiplier = OperationalFeeMultiplier; |
| 102 | + type WeightToFee = WeightToFee; |
| 103 | + type LengthToFee = LengthFeeAdjustment; |
| 104 | + type FeeMultiplierUpdate = (); |
| 105 | +} |
| 106 | + |
| 107 | +impl pallet_sugondat_length_fee_adjustment::Config for Test { |
| 108 | + type TransactionByteFee = TransactionByteFee; |
| 109 | + type MaximumBlockLength = MaximumBlockLength; |
| 110 | + type AdjustmentVariableBlockSize = AdjustmentVariableBlockSize; |
| 111 | + type MinimumMultiplierBlockSize = MinimumMultiplierBlockSize; |
| 112 | + type MaximumMultiplierBlockSize = MaximumMultiplierBlockSize; |
| 113 | + type TargetBlockFullness = TargetBlockFullness; |
| 114 | + type AdjustmentVariableBlockFullness = AdjustmentVariableBlockFullness; |
| 115 | + type MaximumMultiplierBlockFullness = MaximumMultiplierBlockFullness; |
| 116 | + type MinimumMultiplierBlockFullness = MinimumMultiplierBlockFullness; |
| 117 | +} |
0 commit comments