Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pallets/author-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
2 changes: 2 additions & 0 deletions pallets/foreign-asset-creator/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl pallet_assets::Config for Test {
type CallbackHandle = ();
type WeightInfo = ();
type RemoveItemsLimit = ConstU32<1000>;
type Holder = ();
pallet_assets::runtime_benchmarks_enabled! {
type BenchmarkHelper = ();
}
Expand Down Expand Up @@ -237,6 +238,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Test> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
1 change: 1 addition & 0 deletions pallets/migrations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
cumulus-primitives-core = { workspace = true }

# Benchmarks
frame-benchmarking = { workspace = true, optional = true }
Expand Down
18 changes: 16 additions & 2 deletions pallets/migrations/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,31 @@ parameter_types! {
pub const InstantAllowed: bool = false;
}

// Taken from frame scheduller mock
parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
Weight::from_parts(frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64),
);
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
}

impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type MaximumWeight = ();
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = ();
type WeightInfo = ();
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly; // TODO : Simplest type, maybe there is better ?
type Preimages = ();
type BlockNumberProvider = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions pallets/randomness/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Test> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
1 change: 1 addition & 0 deletions pallets/relay-storage-roots/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Test> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
4 changes: 4 additions & 0 deletions precompiles/assets-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ impl pallet_evm::Config for Runtime {
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type CreateOriginFilter = ();
type CreateInnerOriginFilter = ();
}

type ForeignAssetInstance = pallet_assets::Instance1;
Expand Down Expand Up @@ -241,6 +243,7 @@ impl pallet_assets::Config<ForeignAssetInstance> for Runtime {
type AssetIdParameter = AssetId;
type CreateOrigin = AsEnsureOriginWithArg<EnsureNever<AccountId>>;
type CallbackHandle = ();
type Holder = ();
pallet_assets::runtime_benchmarks_enabled! {
type BenchmarkHelper = BenchmarkHelper;
}
Expand Down Expand Up @@ -282,6 +285,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
20 changes: 10 additions & 10 deletions precompiles/assets-erc20/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn approve() {
value: 500.into(),
},
)
.expect_cost(37024756)
.expect_cost(30211756)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand Down Expand Up @@ -286,7 +286,7 @@ fn approve_saturating() {
value: U256::MAX,
},
)
.expect_cost(37024756)
.expect_cost(30211756)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand Down Expand Up @@ -415,7 +415,7 @@ fn transfer() {
value: 400.into(),
},
)
.expect_cost(50509756) // 1 weight => 1 gas in mock
.expect_cost(40921756) // 1 weight => 1 gas in mock
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_TRANSFER,
Expand Down Expand Up @@ -542,7 +542,7 @@ fn transfer_from() {
value: 400.into(),
},
)
.expect_cost(70172756) // 1 weight => 1 gas in mock
.expect_cost(60468756) // 1 weight => 1 gas in mock
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_TRANSFER,
Expand Down Expand Up @@ -620,7 +620,7 @@ fn transfer_from_non_incremental_approval() {
value: 500.into(),
},
)
.expect_cost(37024756)
.expect_cost(30211756)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand All @@ -643,7 +643,7 @@ fn transfer_from_non_incremental_approval() {
value: 300.into(),
},
)
.expect_cost(76042756)
.expect_cost(61543756)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand Down Expand Up @@ -751,7 +751,7 @@ fn transfer_from_self() {
value: 400.into(),
},
)
.expect_cost(50509756) // 1 weight => 1 gas in mock
.expect_cost(40921756) // 1 weight => 1 gas in mock
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_TRANSFER,
Expand Down Expand Up @@ -898,7 +898,7 @@ fn permit_valid() {
s: H256::from(rs.s.b32()),
},
)
.expect_cost(37023000)
.expect_cost(30210000)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand Down Expand Up @@ -1007,7 +1007,7 @@ fn permit_valid_named_asset() {
s: H256::from(rs.s.b32()),
},
)
.expect_cost(37023000)
.expect_cost(30210000)
.expect_log(log3(
ForeignAssetId(0u128),
SELECTOR_LOG_APPROVAL,
Expand Down Expand Up @@ -1485,7 +1485,7 @@ fn permit_valid_with_metamask_signed_data() {
s: H256::from(s_real),
},
)
.expect_cost(37023000)
.expect_cost(30210000)
.expect_log(log3(
ForeignAssetId(1u128),
SELECTOR_LOG_APPROVAL,
Expand Down
3 changes: 3 additions & 0 deletions precompiles/balances-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ impl pallet_evm::Config for Runtime {
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type CreateOriginFilter = ();
type CreateInnerOriginFilter = ();
}

// Configure a mock runtime to test the pallet.
Expand Down Expand Up @@ -205,6 +207,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
6 changes: 3 additions & 3 deletions precompiles/balances-erc20/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn transfer() {
value: 400.into(),
},
)
.expect_cost(176106756) // 1 weight => 1 gas in mock
.expect_cost(173835756) // 1 weight => 1 gas in mock
.expect_log(log3(
Precompile1,
SELECTOR_LOG_TRANSFER,
Expand Down Expand Up @@ -370,7 +370,7 @@ fn transfer_from() {
value: 400.into(),
},
)
.expect_cost(176106756) // 1 weight => 1 gas in mock
.expect_cost(173835756) // 1 weight => 1 gas in mock
.expect_log(log3(
Precompile1,
SELECTOR_LOG_TRANSFER,
Expand Down Expand Up @@ -466,7 +466,7 @@ fn transfer_from_self() {
value: 400.into(),
},
)
.expect_cost(176106756) // 1 weight => 1 gas in mock
.expect_cost(173835756) // 1 weight => 1 gas in mock
.expect_log(log3(
Precompile1,
SELECTOR_LOG_TRANSFER,
Expand Down
7 changes: 6 additions & 1 deletion precompiles/batch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ impl pallet_evm::Config for Runtime {
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type CreateOriginFilter = ();
type CreateInnerOriginFilter = ();
}

parameter_types! {
Expand Down Expand Up @@ -194,6 +196,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand All @@ -204,7 +207,9 @@ impl ExtBuilder {
pallet_evm::Pallet::<Runtime>::create_account(
Revert.into(),
hex_literal::hex!("1460006000fd").to_vec(),
);
None,
)
.expect("account creation should succeed");
});
ext
}
Expand Down
11 changes: 8 additions & 3 deletions precompiles/batch/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,11 @@ fn batch_not_callable_by_smart_contract() {
.execute_with(|| {
// "deploy" SC to alice address
let alice_h160: H160 = Alice.into();
pallet_evm::Pallet::<Runtime>::create_account(alice_h160, vec![10u8]);
assert_ok!(pallet_evm::Pallet::<Runtime>::create_account(
alice_h160,
vec![10u8],
None
));

// succeeds if not called by SC, see `evm_batch_recursion_under_limit`
let input = PCall::batch_all {
Expand Down Expand Up @@ -1049,10 +1053,11 @@ fn batch_is_not_callable_by_dummy_code() {
.execute_with(|| {
// "deploy" dummy code to alice address
let alice_h160: H160 = Alice.into();
pallet_evm::Pallet::<Runtime>::create_account(
assert_ok!(pallet_evm::Pallet::<Runtime>::create_account(
alice_h160,
[0x60, 0x00, 0x60, 0x00, 0xfd].to_vec(),
);
None,
));

// succeeds if called by dummy code, see `evm_batch_recursion_under_limit`
let input = PCall::batch_all {
Expand Down
7 changes: 6 additions & 1 deletion precompiles/call-permit/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ impl pallet_evm::Config for Runtime {
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type CreateOriginFilter = ();
type CreateInnerOriginFilter = ();
}

parameter_types! {
Expand Down Expand Up @@ -180,6 +182,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand All @@ -190,7 +193,9 @@ impl ExtBuilder {
pallet_evm::Pallet::<Runtime>::create_account(
Revert.into(),
hex_literal::hex!("1460006000fd").to_vec(),
);
None,
)
.expect("account creation should succeed");
});
ext
}
Expand Down
6 changes: 6 additions & 0 deletions precompiles/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl pallet_assets::Config for Runtime {
type CallbackHandle = ();
type WeightInfo = ();
type RemoveItemsLimit = ConstU32<1000>;
type Holder = ();
pallet_assets::runtime_benchmarks_enabled! {
type BenchmarkHelper = ();
}
Expand Down Expand Up @@ -276,6 +277,8 @@ impl pallet_evm::Config for Runtime {
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
type CreateOriginFilter = ();
type CreateInnerOriginFilter = ();
}

parameter_types! {
Expand Down Expand Up @@ -384,6 +387,7 @@ impl pallet_xcm::Config for Runtime {
type MaxRemoteLockConsumers = ConstU32<0>;
type RemoteLockConsumerIdentifier = ();
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
type AuthorizedAliasConsideration = ();
}

use sp_std::cell::RefCell;
Expand Down Expand Up @@ -524,6 +528,7 @@ impl xcm_executor::Config for XcmConfig {
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = PolkadotXcm;
type XcmEventEmitter = ();
}

pub fn root_origin() -> <Runtime as frame_system::Config>::RuntimeOrigin {
Expand Down Expand Up @@ -576,6 +581,7 @@ impl ExtBuilder {

pallet_balances::GenesisConfig::<Runtime> {
balances: self.balances,
..Default::default()
}
.assimilate_storage(&mut t)
.expect("Pallet balances storage can be assimilated");
Expand Down
Loading