difftreelog
fix test
in: master
2 files changed
pallets/app-promotion/src/lib.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -28,8 +28,7 @@
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
-#[cfg(test)]
-mod tests;
+
pub mod types;
pub mod weights;
pallets/app-promotion/src/tests.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg(test)]18#![allow(clippy::from_over_into)]19// use crate as pallet_promotion;2021// use frame_benchmarking::{add_benchmark, BenchmarkBatch};22// use frame_support::{23// assert_ok, parameter_types,24// traits::{Currency, OnInitialize, Everything, ConstU32},25// };26// use frame_system::RawOrigin;27// use sp_core::H256;28// use sp_runtime::{29// traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup},30// testing::Header,31// Perbill, Perquintill,32// };3334// type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;35// type Block = frame_system::mocking::MockBlock<Test>;3637// parameter_types! {38// pub const BlockHashCount: u64 = 250;39// pub BlockWeights: frame_system::limits::BlockWeights =40// frame_system::limits::BlockWeights::simple_max(1024);41// pub const SS58Prefix: u8 = 42;42// pub TreasuryAccountId: u64 = 1234;43// pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied44// pub static MockBlockNumberProvider: u64 = 0;45// pub const ExistentialDeposit: u64 = 1;46// pub const MaxLocks: u32 = 50;47// }4849// impl BlockNumberProvider for MockBlockNumberProvider {50// type BlockNumber = u64;5152// fn current_block_number() -> Self::BlockNumber {53// Self::get()54// }55// }5657// frame_support::construct_runtime!(58// pub enum Test where59// Block = Block,60// NodeBlock = Block,61// UncheckedExtrinsic = UncheckedExtrinsic,62// {63// Balances: pallet_balances::{Pallet, Call, Storage},64// System: frame_system::{Pallet, Call, Config, Storage, Event<T>},65// Promotion: pallet_promotion::{Pallet, Call, Storage}66// }67// );6869// impl frame_system::Config for Test {70// type BaseCallFilter = Everything;71// type BlockWeights = ();72// type BlockLength = ();73// type DbWeight = ();74// type Origin = Origin;75// type Call = Call;76// type Index = u64;77// type BlockNumber = u64;78// type Hash = H256;79// type Hashing = BlakeTwo256;80// type AccountId = u64;81// type Lookup = IdentityLookup<Self::AccountId>;82// type Header = Header;83// type Event = ();84// type BlockHashCount = BlockHashCount;85// type Version = ();86// type PalletInfo = PalletInfo;87// type AccountData = pallet_balances::AccountData<u64>;88// type OnNewAccount = ();89// type OnKilledAccount = ();90// type SystemWeightInfo = ();91// type SS58Prefix = SS58Prefix;92// type OnSetCode = ();93// type MaxConsumers = ConstU32<16>;94// }9596// impl pallet_balances::Config for Test {97// type AccountStore = System;98// type Balance = u64;99// type DustRemoval = ();100// type Event = ();101// type ExistentialDeposit = ExistentialDeposit;102// type WeightInfo = ();103// type MaxLocks = MaxLocks;104// type MaxReserves = ();105// type ReserveIdentifier = [u8; 8];106// }107108// impl pallet_promotion::Config for Test {109// type Currency = Balances;110111// type TreasuryAccountId = TreasuryAccountId;112113// type BlockNumberProvider = MockBlockNumberProvider;114// }115116// pub fn new_test_ext() -> sp_io::TestExternalities {117// frame_system::GenesisConfig::default()118// .build_storage::<Test>()119// .unwrap()120// .into()121// }122123// #[test]124// fn test_benchmark() {125// new_test_ext().execute_with(|| {126// test_benchmark_stake::<Test>();127// } )128// }129130// #[test]131// fn test_perbill() {132// const ONE_UNIQE: u128 = 1_000_000_000_000_000_000;133// const SECONDS_TO_BLOCK: u32 = 12;134// const DAY: u32 = 60 * 60 * 24 / SECONDS_TO_BLOCK;135// const RECALCULATION_INTERVAL: u32 = 10;136// let day_rate = Perbill::from_rational(5u64, 10_000);137// let interval_rate =138// Perbill::from_rational::<u64>(RECALCULATION_INTERVAL.into(), DAY.into()) * day_rate;139// println!("{:?}", interval_rate * ONE_UNIQE + ONE_UNIQE);140// println!("{:?}", day_rate * ONE_UNIQE);141// println!("{:?}", Perbill::one() * ONE_UNIQE);142// println!("{:?}", ONE_UNIQE);143// let mut next_iters = ONE_UNIQE + interval_rate * ONE_UNIQE;144// next_iters += interval_rate * next_iters;145// println!("{:?}", next_iters);146// let day_income = day_rate * ONE_UNIQE;147// let interval_income = interval_rate * ONE_UNIQE;148// let ratio = day_income / interval_income;149// println!("{:?} || {:?}", ratio, DAY / RECALCULATION_INTERVAL);150// }