Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pallets/erc20-xcm-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ use crate as erc20_xcm_bridge;

use frame_support::traits::Everything;
use frame_support::{construct_runtime, pallet_prelude::*, parameter_types};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_evm::{
AddressMapping, EnsureAddressTruncated, FrameSystemAccountProvider, SubstrateBlockHashMapping,
};
use sp_core::{H160, H256, U256};
use sp_core::{H160, H256, U256, Hasher};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_runtime::AccountId32;

Expand Down Expand Up @@ -134,6 +135,17 @@ impl AddressMapping<AccountId32> for HashedAddressMapping {
}
}

pub struct RandomnessProvider;
impl frame_support::traits::Randomness<<Test as frame_system::Config>::Hash, BlockNumberFor<Test>>
for RandomnessProvider
{
fn random(subject: &[u8]) -> (<Test as frame_system::Config>::Hash, BlockNumberFor<Test>) {
let output = <Test as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Test>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Test {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -158,6 +170,7 @@ impl pallet_evm::Config for Test {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Test>;
type AccountProvider = FrameSystemAccountProvider<Test>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
14 changes: 13 additions & 1 deletion pallets/ethereum-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use pallet_evm::{
AddressMapping, EnsureAddressTruncated, FeeCalculator, FrameSystemAccountProvider,
};
use rlp::RlpStream;
use sp_core::{hashing::keccak_256, H160, H256, U256};
use sp_core::{hashing::keccak_256, H160, H256, U256, Hasher};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
AccountId32, BuildStorage,
Expand Down Expand Up @@ -177,6 +177,17 @@ impl AddressMapping<AccountId32> for HashedAddressMapping {
}
}

pub struct RandomnessProvider;
impl frame_support::traits::Randomness<<Test as frame_system::Config>::Hash, BlockNumberFor<Test>>
for RandomnessProvider
{
fn random(subject: &[u8]) -> (<Test as frame_system::Config>::Hash, BlockNumberFor<Test>) {
let output = <Test as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Test>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Test {
type FeeCalculator = FixedGasPrice;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -201,6 +212,7 @@ impl pallet_evm::Config for Test {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Test>;
type AccountProvider = FrameSystemAccountProvider<Test>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
14 changes: 13 additions & 1 deletion pallets/moonbeam-foreign-assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame_system::{EnsureRoot, Origin};
use pallet_ethereum::{IntermediateStateRoot, PostLogContent};
use pallet_evm::{FrameSystemAccountProvider, SubstrateBlockHashMapping};
use precompile_utils::testing::MockAccount;
use sp_core::{H256, U256};
use sp_core::{H256, U256, Hasher};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_runtime::BuildStorage;
use xcm::latest::{Junction, Location};
Expand Down Expand Up @@ -123,6 +123,17 @@ parameter_types! {
pub GasLimitStorageGrowthRatio: u64 = 366;
}

pub struct RandomnessProvider;
impl frame_support::traits::Randomness<<Test as frame_system::Config>::Hash, BlockNumberFor<Test>>
for RandomnessProvider
{
fn random(subject: &[u8]) -> (<Test as frame_system::Config>::Hash, BlockNumberFor<Test>) {
let output = <Test as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Test>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Test {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -147,6 +158,7 @@ impl pallet_evm::Config for Test {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Test>;
type AccountProvider = FrameSystemAccountProvider<Test>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
12 changes: 12 additions & 0 deletions pallets/moonbeam-lazy-migrations/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ parameter_types! {
pub SuicideQuickClearLimit: u32 = 0;
}

pub struct RandomnessProvider;
impl frame_support::traits::Randomness<<Test as frame_system::Config>::Hash, BlockNumberFor<Test>>
for RandomnessProvider
{
fn random(subject: &[u8]) -> (<Test as frame_system::Config>::Hash, BlockNumberFor<Test>) {
let output = <Test as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Test>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Test {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -155,6 +166,7 @@ impl pallet_evm::Config for Test {
type WeightInfo = ();
type SuicideQuickClearLimit = SuicideQuickClearLimit;
type AccountProvider = FrameSystemAccountProvider<Test>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
24 changes: 22 additions & 2 deletions precompiles/assets-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ use frame_support::{
weights::Weight,
};

use frame_system::{EnsureNever, EnsureRoot};
use frame_system::{pallet_prelude::BlockNumberFor, EnsureNever, EnsureRoot};
use pallet_evm::{EnsureAddressNever, EnsureAddressRoot, FrameSystemAccountProvider};
use precompile_utils::{
mock_account,
precompile_set::*,
testing::{AddressInPrefixedSet, MockAccount},
};
use sp_core::H256;
use sp_core::{Hasher, H256};
use sp_runtime::{
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage,
Expand Down Expand Up @@ -174,6 +174,25 @@ parameter_types! {
};
}

pub struct RandomnessProvider;
impl
frame_support::traits::Randomness<
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
> for RandomnessProvider
{
fn random(
subject: &[u8],
) -> (
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
) {
let output = <Runtime as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Runtime>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -198,6 +217,7 @@ impl pallet_evm::Config for Runtime {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type AccountProvider = FrameSystemAccountProvider<Runtime>;
type RandomnessProvider = RandomnessProvider;
}

type ForeignAssetInstance = pallet_assets::Instance1;
Expand Down
24 changes: 22 additions & 2 deletions precompiles/author-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ use frame_support::{
traits::{EqualPrivilegeOnly, Everything},
weights::Weight,
};
use frame_system::EnsureRoot;
use frame_system::{pallet_prelude::BlockNumberFor, EnsureRoot};
use pallet_evm::{
EnsureAddressNever, EnsureAddressRoot, FrameSystemAccountProvider, SubstrateBlockHashMapping,
};
use precompile_utils::{mock_account, precompile_set::*, testing::MockAccount};
use sp_core::{H256, U256};
use sp_core::{Hasher, H256, U256};
use sp_io;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
Expand Down Expand Up @@ -130,6 +130,25 @@ parameter_types! {
pub SuicideQuickClearLimit: u32 = 0;
}

pub struct RandomnessProvider;
impl
frame_support::traits::Randomness<
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
> for RandomnessProvider
{
fn random(
subject: &[u8],
) -> (
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
) {
let output = <Runtime as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Runtime>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -154,6 +173,7 @@ impl pallet_evm::Config for Runtime {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type AccountProvider = FrameSystemAccountProvider<Runtime>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
23 changes: 22 additions & 1 deletion precompiles/balances-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
use super::*;

use frame_support::{construct_runtime, parameter_types, traits::Everything, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_evm::{EnsureAddressNever, EnsureAddressRoot, FrameSystemAccountProvider};
use precompile_utils::{precompile_set::*, testing::MockAccount};
use sp_core::{ConstU32, H256, U256};
use sp_core::{ConstU32, Hasher, H256, U256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
Expand Down Expand Up @@ -124,6 +125,25 @@ parameter_types! {
};
}

pub struct RandomnessProvider;
impl
frame_support::traits::Randomness<
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
> for RandomnessProvider
{
fn random(
subject: &[u8],
) -> (
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
) {
let output = <Runtime as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Runtime>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -148,6 +168,7 @@ impl pallet_evm::Config for Runtime {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type AccountProvider = FrameSystemAccountProvider<Runtime>;
type RandomnessProvider = RandomnessProvider;
}

// Configure a mock runtime to test the pallet.
Expand Down
23 changes: 22 additions & 1 deletion precompiles/batch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use super::*;

use frame_support::traits::Everything;
use frame_support::{construct_runtime, parameter_types, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_evm::{EnsureAddressNever, EnsureAddressRoot, FrameSystemAccountProvider};
use precompile_utils::{mock_account, precompile_set::*, testing::MockAccount};
use sp_core::H256;
use sp_core::{Hasher, H256};
use sp_runtime::BuildStorage;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
Expand Down Expand Up @@ -139,6 +140,25 @@ parameter_types! {
};
}

pub struct RandomnessProvider;
impl
frame_support::traits::Randomness<
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
> for RandomnessProvider
{
fn random(
subject: &[u8],
) -> (
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
) {
let output = <Runtime as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Runtime>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -163,6 +183,7 @@ impl pallet_evm::Config for Runtime {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type AccountProvider = FrameSystemAccountProvider<Runtime>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
23 changes: 22 additions & 1 deletion precompiles/call-permit/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use super::*;

use frame_support::traits::Everything;
use frame_support::{construct_runtime, pallet_prelude::*, parameter_types};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_evm::{EnsureAddressNever, EnsureAddressRoot, FrameSystemAccountProvider};
use precompile_utils::{mock_account, precompile_set::*, testing::MockAccount};
use sp_core::H256;
use sp_core::{Hasher, H256};
use sp_runtime::BuildStorage;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
Expand Down Expand Up @@ -119,6 +120,25 @@ parameter_types! {
pub const SuicideQuickClearLimit: u32 = 0;
}

pub struct RandomnessProvider;
impl
frame_support::traits::Randomness<
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
> for RandomnessProvider
{
fn random(
subject: &[u8],
) -> (
<Runtime as frame_system::Config>::Hash,
BlockNumberFor<Runtime>,
) {
let output = <Runtime as frame_system::Config>::Hashing::hash(subject);
let block_number = frame_system::Pallet::<Runtime>::block_number();
(output, block_number)
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
Expand All @@ -143,6 +163,7 @@ impl pallet_evm::Config for Runtime {
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type AccountProvider = FrameSystemAccountProvider<Runtime>;
type RandomnessProvider = RandomnessProvider;
}

parameter_types! {
Expand Down
Loading
Loading