-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8494797
commit 58d171f
Showing
10 changed files
with
237 additions
and
41 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
104 changes: 104 additions & 0 deletions
104
pallets/dactr/src/extensions/check_batch_transactions_mock.rs
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,104 @@ | ||
#![cfg(test)] | ||
|
||
use frame_support::{derive_impl, weights::IdentityFee}; | ||
use frame_system::{ | ||
header_builder::da::HeaderExtensionBuilder, mocking::MockUncheckedExtrinsic, | ||
test_utils::TestRandomness, | ||
}; | ||
use pallet_transaction_payment::CurrencyAdapter; | ||
use sp_runtime::{AccountId32, BuildStorage}; | ||
|
||
use crate::{self as da_control, *}; | ||
|
||
/// An unchecked extrinsic type to be used in tests. | ||
type Extrinsic = MockUncheckedExtrinsic<Test>; | ||
/// An implementation of `sp_runtime::traits::Block` to be used in tests. | ||
type Block = frame_system::mocking::MockDaBlock<Test>; | ||
type Balance = u64; | ||
|
||
frame_support::construct_runtime!( | ||
pub struct Test { | ||
Timestamp: pallet_timestamp, | ||
System: frame_system, | ||
Utility: pallet_utility, | ||
Balances: pallet_balances, | ||
TransactionPayment: pallet_transaction_payment, | ||
DataAvailability: da_control, | ||
Vector: pallet_vector, | ||
} | ||
); | ||
|
||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] | ||
impl frame_system::Config for Test { | ||
type AccountData = pallet_balances::AccountData<Balance>; | ||
type Block = Block; | ||
type HeaderExtensionBuilder = HeaderExtensionBuilder<Test>; | ||
type PalletInfo = PalletInfo; | ||
type Randomness = TestRandomness<Test>; | ||
type Extrinsic = Extrinsic; | ||
type AccountId = AccountId32; | ||
type Lookup = sp_runtime::traits::IdentityLookup<AccountId32>; | ||
} | ||
|
||
#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig as pallet_transaction_payment::DefaultConfig)] | ||
impl pallet_transaction_payment::Config for Test { | ||
type LengthToFee = pallet_transaction_payment::TestLengthToFeeU64; | ||
type OnChargeTransaction = CurrencyAdapter<Balances, ()>; | ||
type WeightToFee = IdentityFee<Balance>; | ||
} | ||
|
||
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] | ||
impl pallet_balances::Config for Test { | ||
type AccountStore = System; | ||
} | ||
|
||
impl pallet_utility::Config for Test { | ||
type PalletsOrigin = OriginCaller; | ||
type RuntimeCall = RuntimeCall; | ||
type RuntimeEvent = RuntimeEvent; | ||
type WeightInfo = (); | ||
} | ||
|
||
#[derive_impl(da_control::config_preludes::TestDefaultConfig)] | ||
impl da_control::Config for Test {} | ||
|
||
#[derive_impl(pallet_vector::config_preludes::TestDefaultConfig as pallet_vector::DefaultConfig)] | ||
impl pallet_vector::Config for Test { | ||
type TimeProvider = Timestamp; | ||
type Currency = Balances; | ||
} | ||
|
||
#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig as pallet_timestamp::DefaultConfig)] | ||
impl pallet_timestamp::Config for Test {} | ||
|
||
fn u8_to_account_id(value: u8) -> AccountId32 { | ||
let mut account = [0u8; 32]; | ||
account[0] = value; | ||
|
||
AccountId32::new(account) | ||
} | ||
|
||
/// Create new externalities for `System` module tests. | ||
pub fn new_test_ext() -> sp_io::TestExternalities { | ||
let mut storage = frame_system::GenesisConfig::<Test>::default() | ||
.build_storage() | ||
.unwrap(); | ||
|
||
let alice = u8_to_account_id(1); | ||
|
||
pallet_balances::GenesisConfig::<Test> { | ||
balances: vec![(alice.clone(), 1_000_000u64)], | ||
} | ||
.assimilate_storage(&mut storage) | ||
.unwrap(); | ||
|
||
da_control::GenesisConfig::<Test> { | ||
app_keys: vec![(b"Avail".to_vec(), (alice, 0))], | ||
} | ||
.assimilate_storage(&mut storage) | ||
.unwrap(); | ||
|
||
let mut ext = sp_io::TestExternalities::new(storage); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod check_app_id; | ||
pub mod check_batch_transactions; | ||
pub mod check_batch_transactions_mock; | ||
|
||
const MAX_ITERATIONS: usize = 2; |
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
Oops, something went wrong.