Skip to content

Commit

Permalink
Fix schedule_xcmp_task_full test
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Jun 30, 2023
1 parent fe76e7b commit 6f99af0
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
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.

4 changes: 2 additions & 2 deletions node/src/chain_spec/neumann.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ fn testnet_genesis(
vesting_schedule: Vec<(u64, Vec<(AccountId, Balance)>)>,
general_councils: Vec<AccountId>,
technical_memberships: Vec<AccountId>,
xcmp_handler_asset_data: Vec<(Vec<u8>, XcmFlow)>,
xcmp_handler_transact_info: Vec<(Vec<u8>, XcmFlow)>,
) -> neumann_runtime::GenesisConfig {
neumann_runtime::GenesisConfig {
system: neumann_runtime::SystemConfig {
Expand Down Expand Up @@ -362,7 +362,7 @@ fn testnet_genesis(
treasury: Default::default(),
valve: ValveConfig { start_with_valve_closed: false, closed_gates: pallet_gates_closed },
vesting: VestingConfig { vesting_schedule },
xcmp_handler: XcmpHandlerConfig { asset_data: xcmp_handler_asset_data },
xcmp_handler: XcmpHandlerConfig { transact_info: xcmp_handler_transact_info },
asset_registry: Default::default(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions node/src/chain_spec/oak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn testnet_genesis(
vesting_schedule: Vec<(u64, Vec<(AccountId, Balance)>)>,
general_councils: Vec<AccountId>,
technical_memberships: Vec<AccountId>,
xcmp_handler_asset_data: Vec<(Vec<u8>, XcmFlow)>,
xcmp_handler_transact_info: Vec<(Vec<u8>, XcmFlow)>,
) -> oak_runtime::GenesisConfig {
let candidate_stake =
std::cmp::max(oak_runtime::MinCollatorStk::get(), oak_runtime::MinCandidateStk::get());
Expand Down Expand Up @@ -402,7 +402,7 @@ fn testnet_genesis(
treasury: Default::default(),
valve: ValveConfig { start_with_valve_closed: false, closed_gates: pallet_gates_closed },
vesting: VestingConfig { vesting_schedule },
xcmp_handler: XcmpHandlerConfig { asset_data: xcmp_handler_asset_data },
xcmp_handler: XcmpHandlerConfig { transact_info: xcmp_handler_transact_info },
asset_registry: Default::default(),
}
}
3 changes: 3 additions & 0 deletions pallets/automation-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "p
pallet-xcm = { git = 'https://github.com/paritytech/polkadot', default-features = false, branch = "release-v0.9.38" }
xcm-executor = { git = 'https://github.com/paritytech/polkadot', default-features = false, branch = "release-v0.9.38" }

# Cumulus dependencies
parachain-info = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.38' }

orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.38" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.38" }

Expand Down
7 changes: 6 additions & 1 deletion pallets/automation-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub use types::*;

use codec::Decode;
use core::convert::TryInto;
use cumulus_primitives_core::ParaId;
use frame_support::{
dispatch::{DispatchErrorWithPostInfo, GetDispatchInfo, PostDispatchInfo},
pallet_prelude::*,
Expand Down Expand Up @@ -186,6 +187,9 @@ pub mod pallet {

/// This chain's Universal Location.
type UniversalLocation: Get<InteriorMultiLocation>;

//The paraId of this chain.
type SelfParaId: Get<ParaId>;
}

#[pallet::pallet]
Expand Down Expand Up @@ -1399,7 +1403,8 @@ pub mod pallet {
.map_err(|()| Error::<T>::BadVersion)?;
let asset_location = asset_location
.reanchored(
&MultiLocation::new(1, X1(Parachain(2114))).into(),
&MultiLocation::new(1, X1(Parachain(T::SelfParaId::get().into())))
.into(),
T::UniversalLocation::get(),
)
.map_err(|_| Error::<T>::CannotReanchor)?;
Expand Down
14 changes: 13 additions & 1 deletion pallets/automation-time/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ construct_runtime!(
System: system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
ParachainInfo: parachain_info::{Pallet, Storage, Config},
Tokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>},
Currencies: orml_currencies::{Pallet, Call},
AutomationTime: pallet_automation_time::{Pallet, Call, Storage, Event<T>},
Expand Down Expand Up @@ -110,6 +111,8 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
}

impl parachain_info::Config for Test {}

parameter_type_with_key! {
pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance {
Default::default()
Expand Down Expand Up @@ -307,7 +310,7 @@ where
fn is_local_fee_deduction(
destination: MultiLocation,
) -> Result<bool, sp_runtime::DispatchError> {
!destination == MultiLocation::new(1, X1(Parachain(PARA_ID)))
Ok(destination != MultiLocation::new(1, X1(Parachain(PARA_ID))))
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -355,6 +358,13 @@ impl EnsureProxy<AccountId> for MockEnsureProxy {
}
}

parameter_types! {
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
// The universal location within the global consensus system
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
}

impl pallet_automation_time::Config for Test {
type RuntimeEvent = RuntimeEvent;
type MaxTasksPerSlot = MaxTasksPerSlot;
Expand All @@ -378,6 +388,8 @@ impl pallet_automation_time::Config for Test {
type CurrencyIdConvert = MockTokenIdConvert;
type FeeConversionRateProvider = MockConversionRateProvider;
type EnsureProxy = MockEnsureProxy;
type UniversalLocation = UniversalLocation;
type SelfParaId = parachain_info::Pallet<Test>;
}

// Build genesis storage according to the mock runtime.
Expand Down
4 changes: 2 additions & 2 deletions pallets/xcmp-handler/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ pub fn new_test_ext(genesis_config: Option<Vec<(Vec<u8>, XcmFlow)>>) -> sp_io::T
)
.expect("Pallet Parachain info can be assimilated");

if let Some(asset_data) = genesis_config {
if let Some(transact_info) = genesis_config {
GenesisBuild::<Test>::assimilate_storage(
&pallet_xcmp_handler::GenesisConfig { asset_data },
&pallet_xcmp_handler::GenesisConfig { transact_info },
&mut t,
)
.expect("Pallet Parachain info can be assimilated");
Expand Down
1 change: 1 addition & 0 deletions runtime/neumann/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ impl pallet_automation_time::Config for Runtime {
type ScheduleAllowList = ScheduleAllowList;
type EnsureProxy = AutomationEnsureProxy;
type UniversalLocation = UniversalLocation;
type SelfParaId = parachain_info::Pallet<Runtime>;
}

impl pallet_automation_price::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions runtime/oak/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ impl pallet_automation_time::Config for Runtime {
type ScheduleAllowList = ScheduleAllowList;
type EnsureProxy = AutomationEnsureProxy;
type UniversalLocation = UniversalLocation;
type SelfParaId = parachain_info::Pallet<Runtime>;
}

pub struct ClosedCallFilter;
Expand Down
1 change: 1 addition & 0 deletions runtime/turing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ impl pallet_automation_time::Config for Runtime {
type ScheduleAllowList = ScheduleAllowList;
type EnsureProxy = AutomationEnsureProxy;
type UniversalLocation = UniversalLocation;
type SelfParaId = parachain_info::Pallet<Runtime>;
}

impl pallet_automation_price::Config for Runtime {
Expand Down

0 comments on commit 6f99af0

Please sign in to comment.