|
| 1 | +// This file is part of https://github.com/galacticcouncil/* |
| 2 | +// |
| 3 | +// $$$$$$$ Licensed under the Apache License, Version 2.0 (the "License") |
| 4 | +// $$$$$$$$$$$$$ you may only use this file in compliance with the License |
| 5 | +// $$$$$$$$$$$$$$$$$$$ |
| 6 | +// $$$$$$$$$ Copyright (C) 2021-2025 Intergalactic, Limited (GIB) |
| 7 | +// $$$$$$$$$$$ $$$$$$$$$$ SPDX-License-Identifier: Apache-2.0 |
| 8 | +// $$$$$$$$$$$$$$$$$$$$$$$$$$ |
| 9 | +// $$$$$$$$$$$$$$$$$$$$$$$ $ Built with <3 for decentralisation |
| 10 | +// $$$$$$$$$$$$$$$$$$$ $$$$$$$ |
| 11 | +// $$$$$$$ $$$$$$$$$$$$$$$$$$ Unless required by applicable law or agreed to in |
| 12 | +// $ $$$$$$$$$$$$$$$$$$$$$$$ writing, software distributed under the License is |
| 13 | +// $$$$$$$$$$$$$$$$$$$$$$$$$$ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 14 | +// $$$$$$$$$ $$$$$$$$$$$ OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// $$$$$$$$ |
| 16 | +// $$$$$$$$$$$$$$$$$$ See the License for the specific language governing |
| 17 | +// $$$$$$$$$$$$$ permissions and limitations under the License. |
| 18 | +// $$$$$$$ |
| 19 | +// $$ |
| 20 | +// $$$$$ $$$$$ $$ $ |
| 21 | +// $$$ $$$ $$$ $$ $$$$$ $$ $$$ $$$$ $$$$$$$ $$$$ $$$ $$$$$$ $$ $$$$$$ |
| 22 | +// $$$ $$$ $$$ $$ $$$ $$$ $$$ $ $$ $$ $$ $$ $$ $$ $$$ $$$ |
| 23 | +// $$$$$$$$$$$ $$ $$ $$$ $$ $$ $$$$$$$ $$ $$ $$ $$$ $$ $$ |
| 24 | +// $$$ $$$ $$$$ $$$ $$ $$ $$$ $$ $$ $$ $$ $$ $$ $$ |
| 25 | +// $$$$$ $$$$$ $$ $$$$$$$$ $ $$$ $$$$$$$$ $$$ $$$$ $$$$$$$ $$$$ $$$$ |
| 26 | +// $$$ |
| 27 | + |
| 28 | +use crate as parameters; |
| 29 | +use frame_support::{parameter_types, traits::Everything, PalletId}; |
| 30 | +use frame_system as system; |
| 31 | +use sp_core::H256; |
| 32 | +use sp_runtime::{ |
| 33 | + traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, |
| 34 | + BuildStorage, Permill, |
| 35 | +}; |
| 36 | +use std::{cell::RefCell, collections::HashMap}; |
| 37 | + |
| 38 | +type Block = frame_system::mocking::MockBlock<Test>; |
| 39 | + |
| 40 | +pub type AccountId = u64; |
| 41 | +pub type Amount = i128; |
| 42 | +pub type AssetId = u32; |
| 43 | +pub type Balance = u128; |
| 44 | +pub type NamedReserveIdentifier = [u8; 8]; |
| 45 | + |
| 46 | +pub const HDX: AssetId = 0; |
| 47 | +pub const DAI: AssetId = 2; |
| 48 | +pub const DOGE: AssetId = 333; |
| 49 | +pub const REGISTERED_ASSET: AssetId = 1000; |
| 50 | + |
| 51 | +pub const ONE: Balance = 1_000_000_000_000; |
| 52 | + |
| 53 | +pub const ALICE: AccountId = 1; |
| 54 | +pub const BOB: AccountId = 2; |
| 55 | + |
| 56 | +pub const TREASURY_INITIAL_BALANCE: Balance = 1_000_000 * ONE; |
| 57 | + |
| 58 | +frame_support::construct_runtime!( |
| 59 | + pub enum Test |
| 60 | + { |
| 61 | + System: frame_system, |
| 62 | + Parameters: parameters, |
| 63 | + } |
| 64 | +); |
| 65 | + |
| 66 | +thread_local! { |
| 67 | + pub static REGISTERED_ASSETS: RefCell<HashMap<AssetId, u32>> = RefCell::new(HashMap::default()); |
| 68 | + pub static EXISTENTIAL_DEPOSIT: RefCell<HashMap<AssetId, u128>>= RefCell::new(HashMap::default()); |
| 69 | + pub static PRECISIONS: RefCell<HashMap<AssetId, u32>>= RefCell::new(HashMap::default()); |
| 70 | +} |
| 71 | + |
| 72 | +parameter_types! { |
| 73 | + pub NativeCurrencyId: AssetId = HDX; |
| 74 | + pub ExistentialDepositMultiplier: u8 = 5; |
| 75 | + pub OtcFee: Permill = Permill::from_percent(1u32); |
| 76 | + pub const TreasuryPalletId: PalletId = PalletId(*b"aca/trsy"); |
| 77 | + pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); |
| 78 | +} |
| 79 | + |
| 80 | +impl parameters::Config for Test {} |
| 81 | + |
| 82 | +parameter_types! { |
| 83 | + pub const BlockHashCount: u64 = 250; |
| 84 | + pub const SS58Prefix: u8 = 63; |
| 85 | + pub const MaxReserves: u32 = 50; |
| 86 | +} |
| 87 | + |
| 88 | +impl system::Config for Test { |
| 89 | + type BaseCallFilter = Everything; |
| 90 | + type BlockWeights = (); |
| 91 | + type BlockLength = (); |
| 92 | + type RuntimeOrigin = RuntimeOrigin; |
| 93 | + type RuntimeCall = RuntimeCall; |
| 94 | + type RuntimeTask = RuntimeTask; |
| 95 | + type Nonce = u64; |
| 96 | + type Block = Block; |
| 97 | + type Hash = H256; |
| 98 | + type Hashing = BlakeTwo256; |
| 99 | + type AccountId = AccountId; |
| 100 | + type Lookup = IdentityLookup<Self::AccountId>; |
| 101 | + type RuntimeEvent = RuntimeEvent; |
| 102 | + type BlockHashCount = BlockHashCount; |
| 103 | + type DbWeight = (); |
| 104 | + type Version = (); |
| 105 | + type PalletInfo = PalletInfo; |
| 106 | + type AccountData = (); |
| 107 | + type OnNewAccount = (); |
| 108 | + type OnKilledAccount = (); |
| 109 | + type SystemWeightInfo = (); |
| 110 | + type SS58Prefix = SS58Prefix; |
| 111 | + type OnSetCode = (); |
| 112 | + type MaxConsumers = frame_support::traits::ConstU32<16>; |
| 113 | + type SingleBlockMigrations = (); |
| 114 | + type MultiBlockMigrator = (); |
| 115 | + type PreInherents = (); |
| 116 | + type PostInherents = (); |
| 117 | + type PostTransactions = (); |
| 118 | +} |
| 119 | + |
| 120 | +pub struct ExtBuilder; |
| 121 | + |
| 122 | +impl Default for ExtBuilder { |
| 123 | + fn default() -> Self { |
| 124 | + Self {} |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +impl ExtBuilder { |
| 129 | + pub fn build(self) -> sp_io::TestExternalities { |
| 130 | + let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap(); |
| 131 | + let mut r: sp_io::TestExternalities = t.into(); |
| 132 | + |
| 133 | + r.execute_with(|| { |
| 134 | + System::set_block_number(1); |
| 135 | + }); |
| 136 | + r |
| 137 | + } |
| 138 | +} |
0 commit comments