-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fungible extension test (#169)
- Loading branch information
1 parent
53c5983
commit f8c142d
Showing
7 changed files
with
253 additions
and
137 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use frame_support::{ | ||
derive_impl, parameter_types, | ||
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, Everything}, | ||
}; | ||
use frame_system::{EnsureRoot, EnsureSigned}; | ||
use sp_core::H256; | ||
use sp_runtime::{ | ||
traits::{BlakeTwo256, IdentityLookup}, | ||
BuildStorage, | ||
}; | ||
|
||
type Block = frame_system::mocking::MockBlock<Test>; | ||
pub(crate) type AccountId = u64; | ||
pub(crate) type AssetId = u32; | ||
pub(crate) type Balance = u128; | ||
|
||
// Configure a mock runtime to test the pallet. | ||
frame_support::construct_runtime!( | ||
pub enum Test | ||
{ | ||
System: frame_system = 0, | ||
Balances: pallet_balances = 1, | ||
Assets: pallet_assets::<Instance1> = 2, | ||
Fungibles: pallet_api::fungibles = 150, | ||
} | ||
); | ||
|
||
parameter_types! { | ||
pub const BlockHashCount: u64 = 250; | ||
pub const SS58Prefix: u8 = 42; | ||
} | ||
|
||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] | ||
impl frame_system::Config for Test { | ||
type BaseCallFilter = Everything; | ||
type BlockWeights = (); | ||
type BlockLength = (); | ||
type RuntimeOrigin = RuntimeOrigin; | ||
type RuntimeCall = RuntimeCall; | ||
type Nonce = u64; | ||
type Hash = H256; | ||
type Hashing = BlakeTwo256; | ||
type AccountId = AccountId; | ||
type Lookup = IdentityLookup<Self::AccountId>; | ||
type Block = Block; | ||
type RuntimeEvent = RuntimeEvent; | ||
type BlockHashCount = BlockHashCount; | ||
type DbWeight = (); | ||
type Version = (); | ||
type PalletInfo = PalletInfo; | ||
type AccountData = pallet_balances::AccountData<u128>; | ||
type OnNewAccount = (); | ||
type OnKilledAccount = (); | ||
type SystemWeightInfo = (); | ||
type SS58Prefix = SS58Prefix; | ||
type OnSetCode = (); | ||
type MaxConsumers = ConstU32<16>; | ||
} | ||
|
||
impl pallet_balances::Config for Test { | ||
type Balance = Balance; | ||
type DustRemoval = (); | ||
type RuntimeEvent = RuntimeEvent; | ||
type ExistentialDeposit = ConstU128<1>; | ||
type AccountStore = System; | ||
type FreezeIdentifier = (); | ||
type MaxFreezes = ConstU32<0>; | ||
type WeightInfo = (); | ||
type MaxLocks = (); | ||
type MaxReserves = (); | ||
type ReserveIdentifier = [u8; 8]; | ||
type RuntimeHoldReason = RuntimeHoldReason; | ||
type RuntimeFreezeReason = RuntimeFreezeReason; | ||
} | ||
|
||
pub(crate) type AssetsInstance = pallet_assets::Instance1; | ||
impl pallet_assets::Config<AssetsInstance> for Test { | ||
type RuntimeEvent = RuntimeEvent; | ||
type Balance = Balance; | ||
type RemoveItemsLimit = ConstU32<5>; | ||
type AssetId = AssetId; | ||
type AssetIdParameter = u32; | ||
type Currency = Balances; | ||
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<u64>>; | ||
type ForceOrigin = EnsureRoot<u64>; | ||
type AssetDeposit = ConstU128<1>; | ||
type AssetAccountDeposit = ConstU128<10>; | ||
type MetadataDepositBase = ConstU128<1>; | ||
type MetadataDepositPerByte = ConstU128<1>; | ||
type ApprovalDeposit = ConstU128<1>; | ||
type StringLimit = ConstU32<50>; | ||
type Freezer = (); | ||
type Extra = (); | ||
type CallbackHandle = (); | ||
type WeightInfo = (); | ||
#[cfg(feature = "runtime-benchmarks")] | ||
type BenchmarkHelper = (); | ||
} | ||
impl pallet_api::fungibles::Config for Test { | ||
type AssetsInstance = AssetsInstance; | ||
type WeightInfo = (); | ||
} | ||
|
||
pub(crate) fn new_test_ext() -> sp_io::TestExternalities { | ||
let t = frame_system::GenesisConfig::<Test>::default() | ||
.build_storage() | ||
.expect("Frame system builds valid default genesis config"); | ||
|
||
let mut ext = sp_io::TestExternalities::new(t); | ||
ext.execute_with(|| System::set_block_number(1)); | ||
ext | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.