1// 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)]19use crate as pallet_promotion;2021use frame_benchmarking::{add_benchmark, BenchmarkBatch};22use frame_support::{23 assert_ok, parameter_types,24 traits::{Currency, OnInitialize, Everything, ConstU32},25};26use frame_system::RawOrigin;27use sp_core::H256;28use sp_runtime::{29 traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup},30 testing::Header,31 Perbill,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// }difftreelog
source
pallets/app-promotion/src/tests.rs3.8 KiBsourcehistory