Skip to content

Commit

Permalink
Companion for Substrate 12740 (#1898)
Browse files Browse the repository at this point in the history
* add helper config trait

* benchmarkhelper

* update config

* update tests

* into

* update lockfile for {"substrate", "polkadot"}

* include benchmarks in tomls

Co-authored-by: parity-processbot <>
  • Loading branch information
joepetrowski committed Nov 28, 2022
1 parent 8cae878 commit f307761
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 277 deletions.
509 changes: 256 additions & 253 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type AssetIdParameter = codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
Expand All @@ -259,6 +260,8 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down
16 changes: 8 additions & 8 deletions parachains/runtimes/assets/statemine/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn test_asset_xcm_trader() {
let local_asset_id = 1;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
true,
minimum_asset_balance
Expand All @@ -41,7 +41,7 @@ fn test_asset_xcm_trader() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down Expand Up @@ -118,7 +118,7 @@ fn test_asset_xcm_trader_with_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand All @@ -127,7 +127,7 @@ fn test_asset_xcm_trader_with_refund() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
ExistentialDeposit::get()
));
Expand Down Expand Up @@ -205,7 +205,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -265,7 +265,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -338,7 +338,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
let minimum_asset_balance = 1_000_000_u128;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
false,
minimum_asset_balance
Expand All @@ -347,7 +347,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down
3 changes: 3 additions & 0 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type AssetIdParameter = codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
Expand All @@ -275,6 +276,8 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down
16 changes: 8 additions & 8 deletions parachains/runtimes/assets/statemint/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn test_asset_xcm_trader() {
let local_asset_id = 1;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
true,
minimum_asset_balance
Expand All @@ -41,7 +41,7 @@ fn test_asset_xcm_trader() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down Expand Up @@ -121,7 +121,7 @@ fn test_asset_xcm_trader_with_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand All @@ -130,7 +130,7 @@ fn test_asset_xcm_trader_with_refund() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
ExistentialDeposit::get()
));
Expand Down Expand Up @@ -211,7 +211,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -274,7 +274,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -347,7 +347,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
let minimum_asset_balance = 1_000_000_u128;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
false,
minimum_asset_balance
Expand All @@ -356,7 +356,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down
3 changes: 3 additions & 0 deletions parachains/runtimes/assets/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type AssetIdParameter = codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
Expand All @@ -240,6 +241,8 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down
16 changes: 8 additions & 8 deletions parachains/runtimes/assets/westmint/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn test_asset_xcm_trader() {
let local_asset_id = 1;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
true,
minimum_asset_balance
Expand All @@ -41,7 +41,7 @@ fn test_asset_xcm_trader() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
local_asset_id,
local_asset_id.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down Expand Up @@ -118,7 +118,7 @@ fn test_asset_xcm_trader_with_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand All @@ -127,7 +127,7 @@ fn test_asset_xcm_trader_with_refund() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
ExistentialDeposit::get()
));
Expand Down Expand Up @@ -204,7 +204,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -264,7 +264,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We set existential deposit to be identical to the one for Balances first
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
true,
ExistentialDeposit::get()
Expand Down Expand Up @@ -336,7 +336,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
let minimum_asset_balance = 1_000_000_u128;
assert_ok!(Assets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
1,
1.into(),
AccountId::from(ALICE).into(),
false,
minimum_asset_balance
Expand All @@ -345,7 +345,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// We first mint enough asset for the account to exist for assets
assert_ok!(Assets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(ALICE)),
1,
1.into(),
AccountId::from(ALICE).into(),
minimum_asset_balance
));
Expand Down
1 change: 1 addition & 0 deletions parachains/runtimes/testing/penpal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
Expand Down
3 changes: 3 additions & 0 deletions parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type AssetIdParameter = codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = EnsureRoot<AccountId>;
Expand All @@ -410,6 +411,8 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions parachains/runtimes/testing/rococo-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -99,3 +100,7 @@ std = [
"parachain-info/std",
"parachains-common/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
]
3 changes: 3 additions & 0 deletions parachains/runtimes/testing/rococo-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = u64;
type AssetId = AssetId;
type AssetIdParameter = codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AdminOrigin;
Expand All @@ -509,6 +510,8 @@ impl pallet_assets::Config for Runtime {
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

impl pallet_aura::Config for Runtime {
Expand Down

0 comments on commit f307761

Please sign in to comment.