Skip to content

Commit

Permalink
Add Pay Salary Collectives test (#260)
Browse files Browse the repository at this point in the history
Adding a missing test that was not migrated to this repo when production
runtimes were removed from `polkadot-sdk`:
https://github.com/paritytech/polkadot-sdk/blob/polkadot-v1.2.0/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs

---------

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
NachoPal and ggwpez authored May 2, 2024
1 parent 6d5a7a1 commit ef3c006
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Add `pallet-vesting` to Asset Hubs ([polkadot-fellows/runtimes#269](https://github.com/polkadot-fellows/runtimes/pull/269))
- Remove DMP queue and allow `system::authorize_upgrade` in XCM's call filter ([polkadot-fellows/runtimes#280](https://github.com/polkadot-fellows/runtimes/pull/280))
- Add Pay Salary Collectives test ([polkadot-fellows/runtimes#260](https://github.com/polkadot-fellows/runtimes/pull/260))

## [1.2.3] 29.04.2024

Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ codec = { package = "parity-scale-codec", version = "3.6.9" }
assert_matches = { workspace = true }

# Substrate
sp-core ={ workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }
pallet-balances = { workspace = true, default-features = true }
Expand All @@ -37,6 +38,7 @@ cumulus-pallet-parachain-system = { features = ["parameterized-consensus-hook"],
# Local
asset-hub-polkadot-runtime = { path = "../../../../../system-parachains/asset-hubs/asset-hub-polkadot" }
collectives-polkadot-runtime = { path = "../../../../../system-parachains/collectives/collectives-polkadot" }
collectives-polkadot-runtime-constants = { path = "../../../../../system-parachains/collectives/collectives-polkadot/constants" }
integration-tests-helpers = { path = "../../../helpers" }
polkadot-runtime = { path = "../../../../../relay/polkadot" }
polkadot-runtime-constants = { path = "../../../../../relay/polkadot/constants" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
pub use xcm::{prelude::*, v3};

// Cumulus
pub use emulated_integration_tests_common::xcm_emulator::{
assert_expected_events, bx, Chain, RelayChain as Relay, TestExt,
pub use emulated_integration_tests_common::{
accounts::ALICE,
xcm_emulator::{assert_expected_events, bx, Chain, Parachain, RelayChain as Relay, TestExt},
};
pub use polkadot_system_emulated_network::{
asset_hub_polkadot_emulated_chain::AssetHubPolkadotParaPallet as AssetHubPolkadotPallet,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::*;
use asset_hub_polkadot_runtime::xcm_config::LocationToAccountId;
use collectives_polkadot_runtime::fellowship::FellowshipSalaryPaymaster;
use frame_support::{
assert_ok,
traits::{
fungibles::{Create, Mutate},
tokens::Pay,
},
};
use xcm_executor::traits::ConvertLocation;

const FELLOWSHIP_SALARY_PALLET_ID: u8 =
collectives_polkadot_runtime_constants::FELLOWSHIP_SALARY_PALLET_INDEX;

#[test]
fn pay_salary() {
let asset_id: u32 = 1984;
let fellowship_salary = (
Parent,
Parachain(CollectivesPolkadot::para_id().into()),
PalletInstance(FELLOWSHIP_SALARY_PALLET_ID),
);
let pay_from = LocationToAccountId::convert_location(&fellowship_salary.into()).unwrap();
let pay_to = Polkadot::account_id_of(ALICE);
let pay_amount = 9000;

AssetHubPolkadot::execute_with(|| {
type AssetHubAssets = <AssetHubPolkadot as AssetHubPolkadotPallet>::Assets;

assert_ok!(<AssetHubAssets as Create<_>>::create(
asset_id,
pay_to.clone(),
true,
pay_amount / 2
));
assert_ok!(<AssetHubAssets as Mutate<_>>::mint_into(asset_id, &pay_from, pay_amount * 2));
});

CollectivesPolkadot::execute_with(|| {
type RuntimeEvent = <CollectivesPolkadot as Chain>::RuntimeEvent;

assert_ok!(FellowshipSalaryPaymaster::pay(&pay_to, (), pay_amount));
assert_expected_events!(
CollectivesPolkadot,
vec![
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
]
);
});

AssetHubPolkadot::execute_with(|| {
type RuntimeEvent = <AssetHubPolkadot as Chain>::RuntimeEvent;
assert_expected_events!(
AssetHubPolkadot,
vec![
RuntimeEvent::Assets(pallet_assets::Event::Transferred { .. }) => {},
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod fellowship_salary;
mod fellowship_treasury;

0 comments on commit ef3c006

Please sign in to comment.