From 1f1efd556e8917524704975a1950cc9534563ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Tue, 5 Nov 2024 18:23:43 +0000 Subject: [PATCH 01/14] Replicate people chain integration tests in Rococo --- Cargo.lock | 2 + .../tests/people/people-rococo/Cargo.toml | 2 + .../people-rococo/src/tests/governance.rs | 318 ++++++++++++++++++ .../people/people-rococo/src/tests/mod.rs | 1 + 4 files changed, 323 insertions(+) create mode 100644 cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs diff --git a/Cargo.lock b/Cargo.lock index 59b6d92bde5d5..d780ddbaafeeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13684,9 +13684,11 @@ dependencies = [ "pallet-balances", "pallet-identity", "pallet-message-queue", + "pallet-xcm", "parachains-common", "parity-scale-codec", "polkadot-runtime-common", + "rococo-runtime", "rococo-runtime-constants", "rococo-system-emulated-network", "sp-runtime 31.0.1", diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml index 011be93ecac73..3e1d339eef8c4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml @@ -15,11 +15,13 @@ frame-support = { workspace = true } pallet-balances = { workspace = true } pallet-message-queue = { workspace = true } pallet-identity = { workspace = true } +pallet-xcm = { workspace = true } sp-runtime = { workspace = true } # Polkadot polkadot-runtime-common = { workspace = true, default-features = true } rococo-runtime-constants = { workspace = true, default-features = true } +rococo-runtime = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs new file mode 100644 index 0000000000000..e1898d3a6613b --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -0,0 +1,318 @@ +// 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::imports::*; + +use codec::Encode; +use frame_support::sp_runtime::traits::Dispatchable; +use parachains_common::AccountId; +use people_rococo_runtime::people::IdentityInfo; +use rococo_runtime; +use rococo_system_emulated_network::people_rococo_emulated_chain::people_rococo_runtime; + +use pallet_identity::Data; + +use emulated_integration_tests_common::accounts::{ALICE, BOB}; + +#[test] +fn relay_commands_add_registrar() { + let origins = vec![ + //(OriginKind::Xcm, GeneralAdminOrigin.into()), + (OriginKind::Superuser, ::RuntimeOrigin::root()), + ]; + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } +} + +#[test] +fn relay_commands_kill_identity() { + // To kill an identity, first one must be set + PeopleRococo::execute_with(|| { + type PeopleRuntime = ::Runtime; + type PeopleRuntimeEvent = ::RuntimeEvent; + + let people_rococo_alice = + ::RuntimeOrigin::signed(PeopleRococo::account_id_of(ALICE)); + + let identity_info = IdentityInfo { + email: Data::Raw(b"test@test.io".to_vec().try_into().unwrap()), + ..Default::default() + }; + let identity: Box<::IdentityInformation> = + Box::new(identity_info); + + assert_ok!(::Identity::set_identity( + people_rococo_alice, + identity + )); + + assert_expected_events!( + PeopleRococo, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::IdentitySet { .. }) => {}, + ] + ); + }); + + let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); + + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type PeopleCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleRuntime = ::Runtime; + + let kill_identity_call = + PeopleCall::Identity(pallet_identity::Call::::kill_identity { + target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of(ALICE)), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + // Making the weight's ref time any lower will prevent the XCM from triggering + // execution of the intended extrinsic on the People chain - beware of spurious + // test failure due to this. + require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), + call: kill_identity_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::IdentityKilled { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} + +#[test] +fn relay_commands_add_remove_username_authority() { + let people_rococo_alice = PeopleRococo::account_id_of(ALICE); + let people_rococo_bob = PeopleRococo::account_id_of(BOB); + + let origins = vec![ + //(OriginKind::Xcm, GeneralAdminOrigin.into(), "generaladmin"), + (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"), + ]; + for (origin_kind, origin, usr) in origins { + // First, add a username authority. + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::add_username_authority { + authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), + suffix: b"suffix1".into(), + allocation: 10, + }); + + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: add_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Check events system-parachain-side + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + + // Now, use the previously added username authority to concede a username to an account. + PeopleRococo::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::set_username_for( + ::RuntimeOrigin::signed(people_rococo_alice.clone()), + people_rococo_runtime::MultiAddress::Id(people_rococo_bob.clone()), + full_username, + None, + true + )); + + assert_expected_events!( + PeopleRococo, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, + ] + ); + }); + + // Accept the given username + PeopleRococo::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::accept_username( + ::RuntimeOrigin::signed(people_rococo_bob.clone()), + full_username.try_into().unwrap(), + )); + + assert_expected_events!( + PeopleRococo, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, + ] + ); + }); + + // Now, remove the username authority with another priviledged XCM call. + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), + suffix: b"suffix1".into() + }); + + let remove_authority_xcm_msg = + RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: remove_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Final event check. + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs index 08749b295dc21..b9ad9e3db467f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs @@ -14,4 +14,5 @@ // limitations under the License. mod claim_assets; +mod governance; mod teleport; From 7a284fd9e94c2f303b86534754b16c8d89cf025c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Wed, 6 Nov 2024 02:30:38 +0000 Subject: [PATCH 02/14] Replicate people chain integration tests in Westend --- .../people-westend/src/tests/governance.rs | 317 ++++++++++++++++++ .../people/people-westend/src/tests/mod.rs | 1 + 2 files changed, 318 insertions(+) create mode 100644 cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs new file mode 100644 index 0000000000000..d10270991e973 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -0,0 +1,317 @@ +// 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::imports::*; + +use codec::Encode; +use frame_support::sp_runtime::traits::Dispatchable; +use parachains_common::AccountId; +use people_westend_runtime::people::IdentityInfo; +use westend_system_emulated_network::people_westend_emulated_chain::people_westend_runtime; + +use pallet_identity::Data; + +use emulated_integration_tests_common::accounts::{ALICE, BOB}; + +#[test] +fn relay_commands_add_registrar() { + let origins = vec![ + //(OriginKind::Xcm, GeneralAdminOrigin.into()), + (OriginKind::Superuser, ::RuntimeOrigin::root()), + ]; + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } +} + +#[test] +fn relay_commands_kill_identity() { + // To kill an identity, first one must be set + PeopleWestend::execute_with(|| { + type PeopleRuntime = ::Runtime; + type PeopleRuntimeEvent = ::RuntimeEvent; + + let people_westend_alice = + ::RuntimeOrigin::signed(PeopleWestend::account_id_of(ALICE)); + + let identity_info = IdentityInfo { + email: Data::Raw(b"test@test.io".to_vec().try_into().unwrap()), + ..Default::default() + }; + let identity: Box<::IdentityInformation> = + Box::new(identity_info); + + assert_ok!(::Identity::set_identity( + people_westend_alice, + identity + )); + + assert_expected_events!( + PeopleWestend, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::IdentitySet { .. }) => {}, + ] + ); + }); + + let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); + + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type PeopleCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleRuntime = ::Runtime; + + let kill_identity_call = + PeopleCall::Identity(pallet_identity::Call::::kill_identity { + target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of(ALICE)), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + // Making the weight's ref time any lower will prevent the XCM from triggering + // execution of the intended extrinsic on the People chain - beware of spurious + // test failure due to this. + require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), + call: kill_identity_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::IdentityKilled { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); +} + +#[test] +fn relay_commands_add_remove_username_authority() { + let people_westend_alice = PeopleWestend::account_id_of(ALICE); + let people_westend_bob = PeopleWestend::account_id_of(BOB); + + let origins = vec![ + //(OriginKind::Xcm, GeneralAdminOrigin.into(), "generaladmin"), + (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"), + ]; + for (origin_kind, origin, usr) in origins { + // First, add a username authority. + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::add_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into(), + allocation: 10, + }); + + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: add_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Check events system-parachain-side + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + + // Now, use the previously added username authority to concede a username to an account. + PeopleWestend::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::set_username_for( + ::RuntimeOrigin::signed(people_westend_alice.clone()), + people_westend_runtime::MultiAddress::Id(people_westend_bob.clone()), + full_username, + None, + true + )); + + assert_expected_events!( + PeopleWestend, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, + ] + ); + }); + + // Accept the given username + PeopleWestend::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::accept_username( + ::RuntimeOrigin::signed(people_westend_bob.clone()), + full_username.try_into().unwrap(), + )); + + assert_expected_events!( + PeopleWestend, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, + ] + ); + }); + + // Now, remove the username authority with another priviledged XCM call. + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into() + }); + + let remove_authority_xcm_msg = + RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: remove_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Final event check. + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); + } +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/mod.rs index 08749b295dc21..b9ad9e3db467f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/mod.rs @@ -14,4 +14,5 @@ // limitations under the License. mod claim_assets; +mod governance; mod teleport; From 96cb9a874647a47777088afad4f23542bd367c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Wed, 6 Nov 2024 13:31:57 +0000 Subject: [PATCH 03/14] Remove unused import --- .../emulated/tests/people/people-rococo/src/tests/governance.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index e1898d3a6613b..430fafc4f5548 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -19,7 +19,6 @@ use codec::Encode; use frame_support::sp_runtime::traits::Dispatchable; use parachains_common::AccountId; use people_rococo_runtime::people::IdentityInfo; -use rococo_runtime; use rococo_system_emulated_network::people_rococo_emulated_chain::people_rococo_runtime; use pallet_identity::Data; From 2b2955da1edf55ba2b19c693bea2ebb436642b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Wed, 6 Nov 2024 13:34:28 +0000 Subject: [PATCH 04/14] Apply `fmt` --- .../tests/people/people-rococo/src/tests/governance.rs | 2 +- .../tests/people/people-westend/src/tests/governance.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index 430fafc4f5548..e552b4fcec432 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -275,7 +275,7 @@ fn relay_commands_add_remove_username_authority() { PeopleRuntime, >::remove_username_authority { authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into() + suffix: b"suffix1".into(), }); let remove_authority_xcm_msg = diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index d10270991e973..cbde01e52cd52 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -122,7 +122,9 @@ fn relay_commands_kill_identity() { let kill_identity_call = PeopleCall::Identity(pallet_identity::Call::::kill_identity { - target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of(ALICE)), + target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( + ALICE, + )), }); let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { @@ -275,7 +277,7 @@ fn relay_commands_add_remove_username_authority() { PeopleRuntime, >::remove_username_authority { authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into() + suffix: b"suffix1".into(), }); let remove_authority_xcm_msg = From 1f2a9588a36772fa3194707c9497651053d96d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Thu, 7 Nov 2024 20:20:26 +0000 Subject: [PATCH 05/14] Add origin check tests to Westend --- Cargo.lock | 1 + .../people-rococo/src/tests/governance.rs | 61 ++++- .../tests/people/people-westend/Cargo.toml | 1 + .../people-westend/src/tests/governance.rs | 220 +++++++++++++++++- 4 files changed, 279 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b9cfcf8a675b..6bd9211d169f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13794,6 +13794,7 @@ dependencies = [ "sp-runtime 31.0.1", "staging-xcm", "staging-xcm-executor", + "westend-runtime", "westend-runtime-constants", "westend-system-emulated-network", ] diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index e552b4fcec432..855c62e6b4795 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -16,9 +16,10 @@ use crate::imports::*; use codec::Encode; -use frame_support::sp_runtime::traits::Dispatchable; +use frame_support::{sp_runtime::traits::Dispatchable, traits::ProcessMessageError}; use parachains_common::AccountId; use people_rococo_runtime::people::IdentityInfo; +use rococo_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; use rococo_system_emulated_network::people_rococo_emulated_chain::people_rococo_runtime; use pallet_identity::Data; @@ -81,6 +82,64 @@ fn relay_commands_add_registrar() { } } +#[test] +fn relay_commands_add_registrar_wrong_origin() { + let people_rococo_alice = PeopleRococo::account_id_of(ALICE); + + let origins = vec![ + (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_rococo_alice)), + (OriginKind::Xcm, GeneralAdminOrigin.into()), + ]; + + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); + } +} + #[test] fn relay_commands_kill_identity() { // To kill an identity, first one must be set diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml index aa6eebc5458f4..53acd038cdf51 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml @@ -21,6 +21,7 @@ sp-runtime = { workspace = true } # Polkadot polkadot-runtime-common = { workspace = true, default-features = true } westend-runtime-constants = { workspace = true, default-features = true } +westend-runtime = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index cbde01e52cd52..0039972b3df75 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -16,9 +16,10 @@ use crate::imports::*; use codec::Encode; -use frame_support::sp_runtime::traits::Dispatchable; +use frame_support::{sp_runtime::traits::Dispatchable, traits::ProcessMessageError}; use parachains_common::AccountId; use people_westend_runtime::people::IdentityInfo; +//use westend_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; use westend_system_emulated_network::people_westend_emulated_chain::people_westend_runtime; use pallet_identity::Data; @@ -28,7 +29,6 @@ use emulated_integration_tests_common::accounts::{ALICE, BOB}; #[test] fn relay_commands_add_registrar() { let origins = vec![ - //(OriginKind::Xcm, GeneralAdminOrigin.into()), (OriginKind::Superuser, ::RuntimeOrigin::root()), ]; for (origin_kind, origin) in origins { @@ -81,6 +81,60 @@ fn relay_commands_add_registrar() { } } +#[test] +fn relay_commands_add_registrar_wrong_origin() { + let people_westend_alice = PeopleWestend::account_id_of(ALICE); + + let (origin_kind, origin) = + (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice)); + + let registrar: AccountId = [1; 32].into(); + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); +} + #[test] fn relay_commands_kill_identity() { // To kill an identity, first one must be set @@ -165,13 +219,67 @@ fn relay_commands_kill_identity() { }); } +#[test] +fn relay_commands_kill_identity_wrong_origin() { + let people_westend_alice = PeopleWestend::account_id_of(BOB); + + let (origin_kind, origin) = ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice), + ); + + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type PeopleCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleRuntime = ::Runtime; + + let kill_identity_call = + PeopleCall::Identity(pallet_identity::Call::::kill_identity { + target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of(ALICE)), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), + call: kill_identity_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); +} + #[test] fn relay_commands_add_remove_username_authority() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let people_westend_bob = PeopleWestend::account_id_of(BOB); let origins = vec![ - //(OriginKind::Xcm, GeneralAdminOrigin.into(), "generaladmin"), (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"), ]; for (origin_kind, origin, usr) in origins { @@ -317,3 +425,109 @@ fn relay_commands_add_remove_username_authority() { }); } } + +#[test] +fn relay_commands_add_remove_username_authority_wrong_origin() { + let people_westend_alice = PeopleWestend::account_id_of(ALICE); + + let (origin_kind, origin) = ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice.clone()), + ); + + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = + PeopleCall::Identity(pallet_identity::Call::::add_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into(), + allocation: 10, + }); + + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: add_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(add_authority_xcm_msg.dispatch(origin)); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Check events system-parachain-side + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); + + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into(), + }); + + let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: remove_username_authority.encode().into(), + } + ]))), + }); + + assert_ok!(remove_authority_xcm_msg + .dispatch(::RuntimeOrigin::signed(people_westend_alice))); + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); +} From 0fc54ca1490f0de55d1eafb3a621ea71b6a879cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Fri, 8 Nov 2024 02:16:47 +0000 Subject: [PATCH 06/14] Check general admin origin with username authorities In Westend, `type UsernameAuthorityOrigin = EnsureRoot;`, so `add_username_authority/remove_username_authority` should fail with regular signed and general admin origins. --- .../people-westend/src/tests/governance.rs | 186 +++++++++--------- 1 file changed, 97 insertions(+), 89 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index 0039972b3df75..40d96eb11ab54 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -19,7 +19,7 @@ use codec::Encode; use frame_support::{sp_runtime::traits::Dispatchable, traits::ProcessMessageError}; use parachains_common::AccountId; use people_westend_runtime::people::IdentityInfo; -//use westend_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; +use westend_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; use westend_system_emulated_network::people_westend_emulated_chain::people_westend_runtime; use pallet_identity::Data; @@ -30,6 +30,7 @@ use emulated_integration_tests_common::accounts::{ALICE, BOB}; fn relay_commands_add_registrar() { let origins = vec![ (OriginKind::Superuser, ::RuntimeOrigin::root()), + (OriginKind::Xcm, GeneralAdminOrigin.into()), ]; for (origin_kind, origin) in origins { let registrar: AccountId = [1; 32].into(); @@ -85,8 +86,10 @@ fn relay_commands_add_registrar() { fn relay_commands_add_registrar_wrong_origin() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); - let (origin_kind, origin) = - (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice)); + let (origin_kind, origin) = ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice), + ); let registrar: AccountId = [1; 32].into(); Westend::execute_with(|| { @@ -237,7 +240,9 @@ fn relay_commands_kill_identity_wrong_origin() { let kill_identity_call = PeopleCall::Identity(pallet_identity::Call::::kill_identity { - target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of(ALICE)), + target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( + ALICE, + )), }); let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { @@ -279,9 +284,8 @@ fn relay_commands_add_remove_username_authority() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let people_westend_bob = PeopleWestend::account_id_of(BOB); - let origins = vec![ - (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"), - ]; + let origins = + vec![(OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername")]; for (origin_kind, origin, usr) in origins { // First, add a username authority. Westend::execute_with(|| { @@ -430,104 +434,108 @@ fn relay_commands_add_remove_username_authority() { fn relay_commands_add_remove_username_authority_wrong_origin() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); - let (origin_kind, origin) = ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_westend_alice.clone()), - ); + let origins = vec![ + (OriginKind::Xcm, GeneralAdminOrigin.into()), + //(OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice.clone())), + ]; - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + for (origin_kind, origin) in origins { + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; - let add_username_authority = - PeopleCall::Identity(pallet_identity::Call::::add_username_authority { + let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::add_username_authority { authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), suffix: b"suffix1".into(), allocation: 10, }); - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), - call: add_username_authority.encode().into(), - } - ]))), - }); + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: add_username_authority.encode().into(), + } + ]))), + }); - assert_ok!(add_authority_xcm_msg.dispatch(origin)); + assert_ok!(add_authority_xcm_msg.dispatch(origin)); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); - // Check events system-parachain-side - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + // Check events system-parachain-side + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - }); + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into(), + }); - let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), - call: remove_username_authority.encode().into(), - } - ]))), - }); + let remove_authority_xcm_msg = + RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: remove_username_authority.encode().into(), + } + ]))), + }); - assert_ok!(remove_authority_xcm_msg - .dispatch(::RuntimeOrigin::signed(people_westend_alice))); + assert_ok!(remove_authority_xcm_msg + .dispatch(::RuntimeOrigin::signed(people_westend_alice.clone()))); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + }); + } } From 2af0b7d34227c41ff7313a8456f2842014c135e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Fri, 8 Nov 2024 18:40:29 +0000 Subject: [PATCH 07/14] Fix tests checking wrong origin in extrinsics (Rococo) --- .../people-rococo/src/tests/governance.rs | 356 ++++++++++++++---- 1 file changed, 290 insertions(+), 66 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index 855c62e6b4795..af3f0f5cf24cb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -16,7 +16,10 @@ use crate::imports::*; use codec::Encode; -use frame_support::{sp_runtime::traits::Dispatchable, traits::ProcessMessageError}; +use frame_support::{ + assert_err, dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, pallet_prelude::{DispatchError, Pays}, + sp_runtime::traits::Dispatchable, +}; use parachains_common::AccountId; use people_rococo_runtime::people::IdentityInfo; use rococo_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; @@ -28,58 +31,54 @@ use emulated_integration_tests_common::accounts::{ALICE, BOB}; #[test] fn relay_commands_add_registrar() { - let origins = vec![ - //(OriginKind::Xcm, GeneralAdminOrigin.into()), - (OriginKind::Superuser, ::RuntimeOrigin::root()), - ]; - for (origin_kind, origin) in origins { - let registrar: AccountId = [1; 32].into(); - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); + let registrar: AccountId = [1; 32].into(); + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), }); - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), }); - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - } + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); } #[test] @@ -87,10 +86,15 @@ fn relay_commands_add_registrar_wrong_origin() { let people_rococo_alice = PeopleRococo::account_id_of(ALICE); let origins = vec![ - (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_rococo_alice)), + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_rococo_alice), + ), (OriginKind::Xcm, GeneralAdminOrigin.into()), ]; + let mut signed_origin = true; + for (origin_kind, origin) in origins { let registrar: AccountId = [1; 32].into(); Rococo::execute_with(|| { @@ -99,7 +103,7 @@ fn relay_commands_add_registrar_wrong_origin() { type RuntimeEvent = ::RuntimeEvent; type PeopleCall = ::RuntimeCall; type PeopleRuntime = ::Runtime; - + let add_registrar_call = PeopleCall::Identity(pallet_identity::Call::::add_registrar { account: registrar.into(), @@ -116,27 +120,38 @@ fn relay_commands_add_registrar_wrong_origin() { } ]))), }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + + if signed_origin { + assert_ok!(xcm_message.dispatch(origin)); + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } else { + assert_err!( + xcm_message.dispatch(origin), + DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: None, + pays_fee: Pays::Yes, + }, + error: DispatchError::BadOrigin, + }, + ); + assert_expected_events!( + Rococo, + vec![] + ); + } }); - + PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); + assert_expected_events!(PeopleRococo, vec![]); }); + + signed_origin = false; } } @@ -222,6 +237,84 @@ fn relay_commands_kill_identity() { }); } +#[test] +fn relay_commands_kill_identity_wrong_origin() { + let people_rococo_alice = PeopleRococo::account_id_of(BOB); + + let origins = vec![ + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_rococo_alice), + ), + (OriginKind::Xcm, GeneralAdminOrigin.into()), + ]; + + let mut signed_origin: bool = true; + + for (origin_kind, origin) in origins { + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type PeopleCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleRuntime = ::Runtime; + + let kill_identity_call = + PeopleCall::Identity(pallet_identity::Call::::kill_identity { + target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of( + ALICE, + )), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), + call: kill_identity_call.encode().into(), + } + ]))), + }); + + if signed_origin { + assert_ok!(xcm_message.dispatch(origin)); + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } else { + assert_err!( + xcm_message.dispatch(origin), + DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: None, + pays_fee: Pays::Yes, + }, + error: DispatchError::BadOrigin, + }, + ); + assert_expected_events!( + Rococo, + vec![] + ); + } + }); + + PeopleRococo::execute_with(|| { + assert_expected_events!( + PeopleRococo, + vec![] + ); + }); + + signed_origin = false; + } +} + #[test] fn relay_commands_add_remove_username_authority() { let people_rococo_alice = PeopleRococo::account_id_of(ALICE); @@ -374,3 +467,134 @@ fn relay_commands_add_remove_username_authority() { }); } } + +#[test] +fn relay_commands_add_remove_username_authority_wrong_origin() { + let people_rococo_alice = PeopleRococo::account_id_of(ALICE); + + let origins = vec![ + (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_rococo_alice.clone())), + (OriginKind::Xcm, GeneralAdminOrigin.into()), + ]; + + let mut signed_origin = true; + + for (origin_kind, origin) in origins { + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::add_username_authority { + authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), + suffix: b"suffix1".into(), + allocation: 10, + }); + + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: add_username_authority.encode().into(), + } + ]))), + }); + + if signed_origin { + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } else { + assert_err!( + add_authority_xcm_msg.dispatch(origin.clone()), + DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: None, + pays_fee: Pays::Yes, + }, + error: DispatchError::BadOrigin, + }, + ); + assert_expected_events!( + Rococo, + vec![] + ); + } + }); + + // Check events system-parachain-side + PeopleRococo::execute_with(|| { + assert_expected_events!(PeopleRococo, vec![]); + }); + + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), + suffix: b"suffix1".into(), + }); + + let remove_authority_xcm_msg = + RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: Weight::from_parts(500_000_000, 500_000), + call: remove_username_authority.encode().into(), + } + ]))), + }); + + if signed_origin { + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } else { + assert_err!( + remove_authority_xcm_msg.dispatch(origin), + DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: None, + pays_fee: Pays::Yes, + }, + error: DispatchError::BadOrigin, + }, + ); + assert_expected_events!( + Rococo, + vec![] + ); + } + }); + + PeopleRococo::execute_with(|| { + assert_expected_events!(PeopleRococo, vec![]); + }); + + signed_origin = false; + } +} \ No newline at end of file From 15a231b66b9b640b788baa60f7c5d35a4cdd855b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Fri, 8 Nov 2024 19:27:50 +0000 Subject: [PATCH 08/14] Add origin check integration tests to Westend --- .../people-westend/src/tests/governance.rs | 311 ++++++++++-------- 1 file changed, 167 insertions(+), 144 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index 40d96eb11ab54..1f5818bcf70c7 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -14,9 +14,13 @@ // limitations under the License. use crate::imports::*; +use frame_support::traits::ProcessMessageError; use codec::Encode; -use frame_support::{sp_runtime::traits::Dispatchable, traits::ProcessMessageError}; +use frame_support::{ + assert_err, dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, pallet_prelude::{DispatchError, Pays}, + sp_runtime::traits::Dispatchable, +}; use parachains_common::AccountId; use people_westend_runtime::people::IdentityInfo; use westend_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; @@ -28,68 +32,8 @@ use emulated_integration_tests_common::accounts::{ALICE, BOB}; #[test] fn relay_commands_add_registrar() { - let origins = vec![ - (OriginKind::Superuser, ::RuntimeOrigin::root()), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - for (origin_kind, origin) in origins { - let registrar: AccountId = [1; 32].into(); - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), - call: add_registrar_call.encode().into(), - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - } -} - -#[test] -fn relay_commands_add_registrar_wrong_origin() { - let people_westend_alice = PeopleWestend::account_id_of(ALICE); - - let (origin_kind, origin) = ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_westend_alice), - ); + let (origin_kind, origin) = + (OriginKind::Superuser, ::RuntimeOrigin::root()); let registrar: AccountId = [1; 32].into(); Westend::execute_with(|| { @@ -132,12 +76,86 @@ fn relay_commands_add_registrar_wrong_origin() { assert_expected_events!( PeopleWestend, vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, ] ); }); } +#[test] +fn relay_commands_add_registrar_wrong_origin() { + let people_westend_alice = PeopleWestend::account_id_of(ALICE); + + let origins = vec![ + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice), + ), + (OriginKind::Xcm, GeneralAdminOrigin.into()), + ]; + + let mut signed_origin = true; + + for (origin_kind, origin) in origins { + let registrar: AccountId = [1; 32].into(); + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_registrar_call = + PeopleCall::Identity(pallet_identity::Call::::add_registrar { + account: registrar.into(), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), + call: add_registrar_call.encode().into(), + } + ]))), + }); + + assert_ok!(xcm_message.dispatch(origin)); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + if signed_origin { + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, + ] + ); + } else { + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + } + }); + + signed_origin = false; + } +} + #[test] fn relay_commands_kill_identity() { // To kill an identity, first one must be set @@ -226,57 +244,57 @@ fn relay_commands_kill_identity() { fn relay_commands_kill_identity_wrong_origin() { let people_westend_alice = PeopleWestend::account_id_of(BOB); - let (origin_kind, origin) = ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_westend_alice), - ); - - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type PeopleCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleRuntime = ::Runtime; + let origins = vec![ + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice), + ), + (OriginKind::Xcm, GeneralAdminOrigin.into()), + ]; - let kill_identity_call = - PeopleCall::Identity(pallet_identity::Call::::kill_identity { - target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( - ALICE, - )), + for (origin_kind, origin) in origins { + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type PeopleCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleRuntime = ::Runtime; + + let kill_identity_call = + PeopleCall::Identity(pallet_identity::Call::::kill_identity { + target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( + ALICE, + )), + }); + + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), + call: kill_identity_call.encode().into(), + } + ]))), }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), - call: kill_identity_call.encode().into(), - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); + + assert_ok!(xcm_message.dispatch(origin)); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); }); + + PeopleWestend::execute_with(|| { + assert_expected_events!( + PeopleWestend, + vec![] + ); + }); + } } #[test] @@ -284,8 +302,9 @@ fn relay_commands_add_remove_username_authority() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let people_westend_bob = PeopleWestend::account_id_of(BOB); - let origins = - vec![(OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername")]; + let origins = vec![ + (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername") + ]; for (origin_kind, origin, usr) in origins { // First, add a username authority. Westend::execute_with(|| { @@ -435,10 +454,12 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let origins = vec![ - (OriginKind::Xcm, GeneralAdminOrigin.into()), - //(OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice.clone())), + (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice.clone())), + //(OriginKind::Xcm, GeneralAdminOrigin.into()), ]; + let mut signed_origin = true; + for (origin_kind, origin) in origins { Westend::execute_with(|| { type Runtime = ::Runtime; @@ -467,26 +488,35 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { ]))), }); - assert_ok!(add_authority_xcm_msg.dispatch(origin)); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + if signed_origin { + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } else { + assert_err!( + add_authority_xcm_msg.dispatch(origin.clone()), + DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: None, + pays_fee: Pays::Yes, + }, + error: DispatchError::BadOrigin, + }, + ); + assert_expected_events!( + Westend, + vec![] + ); + } }); // Check events system-parachain-side PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); + assert_expected_events!(PeopleWestend, vec![]); }); Westend::execute_with(|| { @@ -516,9 +546,7 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { ]))), }); - assert_ok!(remove_authority_xcm_msg - .dispatch(::RuntimeOrigin::signed(people_westend_alice.clone()))); - + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); assert_expected_events!( Westend, vec![ @@ -528,14 +556,9 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { }); PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, - ] - ); + assert_expected_events!(PeopleWestend, vec![]); }); + + signed_origin = false; } -} +} \ No newline at end of file From 52d6f782e466572b726be84b4d462e63cd2bcd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Fri, 8 Nov 2024 19:28:53 +0000 Subject: [PATCH 09/14] Apply `cargo fmt` --- .../people-rococo/src/tests/governance.rs | 64 ++++++------------- .../people-westend/src/tests/governance.rs | 60 ++++++++--------- 2 files changed, 48 insertions(+), 76 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index af3f0f5cf24cb..6bc443903fdb4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -17,7 +17,9 @@ use crate::imports::*; use codec::Encode; use frame_support::{ - assert_err, dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, pallet_prelude::{DispatchError, Pays}, + assert_err, + dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, + pallet_prelude::{DispatchError, Pays}, sp_runtime::traits::Dispatchable, }; use parachains_common::AccountId; @@ -133,17 +135,11 @@ fn relay_commands_add_registrar_wrong_origin() { assert_err!( xcm_message.dispatch(origin), DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { - actual_weight: None, - pays_fee: Pays::Yes, - }, + post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, error: DispatchError::BadOrigin, }, ); - assert_expected_events!( - Rococo, - vec![] - ); + assert_expected_events!(Rococo, vec![]); } }); @@ -258,14 +254,14 @@ fn relay_commands_kill_identity_wrong_origin() { type PeopleCall = ::RuntimeCall; type RuntimeEvent = ::RuntimeEvent; type PeopleRuntime = ::Runtime; - + let kill_identity_call = PeopleCall::Identity(pallet_identity::Call::::kill_identity { target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of( ALICE, )), }); - + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ @@ -277,7 +273,7 @@ fn relay_commands_kill_identity_wrong_origin() { } ]))), }); - + if signed_origin { assert_ok!(xcm_message.dispatch(origin)); assert_expected_events!( @@ -290,25 +286,16 @@ fn relay_commands_kill_identity_wrong_origin() { assert_err!( xcm_message.dispatch(origin), DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { - actual_weight: None, - pays_fee: Pays::Yes, - }, + post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, error: DispatchError::BadOrigin, }, ); - assert_expected_events!( - Rococo, - vec![] - ); + assert_expected_events!(Rococo, vec![]); } }); - + PeopleRococo::execute_with(|| { - assert_expected_events!( - PeopleRococo, - vec![] - ); + assert_expected_events!(PeopleRococo, vec![]); }); signed_origin = false; @@ -473,7 +460,10 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { let people_rococo_alice = PeopleRococo::account_id_of(ALICE); let origins = vec![ - (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_rococo_alice.clone())), + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_rococo_alice.clone()), + ), (OriginKind::Xcm, GeneralAdminOrigin.into()), ]; @@ -519,17 +509,11 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { assert_err!( add_authority_xcm_msg.dispatch(origin.clone()), DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { - actual_weight: None, - pays_fee: Pays::Yes, - }, + post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, error: DispatchError::BadOrigin, }, ); - assert_expected_events!( - Rococo, - vec![] - ); + assert_expected_events!(Rococo, vec![]); } }); @@ -577,17 +561,11 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { assert_err!( remove_authority_xcm_msg.dispatch(origin), DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { - actual_weight: None, - pays_fee: Pays::Yes, - }, + post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, error: DispatchError::BadOrigin, }, ); - assert_expected_events!( - Rococo, - vec![] - ); + assert_expected_events!(Rococo, vec![]); } }); @@ -597,4 +575,4 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { signed_origin = false; } -} \ No newline at end of file +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index 1f5818bcf70c7..d21b7eeaba36f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -18,7 +18,9 @@ use frame_support::traits::ProcessMessageError; use codec::Encode; use frame_support::{ - assert_err, dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, pallet_prelude::{DispatchError, Pays}, + assert_err, + dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, + pallet_prelude::{DispatchError, Pays}, sp_runtime::traits::Dispatchable, }; use parachains_common::AccountId; @@ -32,8 +34,7 @@ use emulated_integration_tests_common::accounts::{ALICE, BOB}; #[test] fn relay_commands_add_registrar() { - let (origin_kind, origin) = - (OriginKind::Superuser, ::RuntimeOrigin::root()); + let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); let registrar: AccountId = [1; 32].into(); Westend::execute_with(|| { @@ -123,13 +124,13 @@ fn relay_commands_add_registrar_wrong_origin() { ]))), }); - assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + assert_ok!(xcm_message.dispatch(origin)); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); }); PeopleWestend::execute_with(|| { @@ -141,7 +142,7 @@ fn relay_commands_add_registrar_wrong_origin() { vec![ RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { error: ProcessMessageError::Unsupported, .. }) => {}, ] - ); + ); } else { assert_expected_events!( PeopleWestend, @@ -259,14 +260,14 @@ fn relay_commands_kill_identity_wrong_origin() { type PeopleCall = ::RuntimeCall; type RuntimeEvent = ::RuntimeEvent; type PeopleRuntime = ::Runtime; - + let kill_identity_call = PeopleCall::Identity(pallet_identity::Call::::kill_identity { target: people_westend_runtime::MultiAddress::Id(PeopleWestend::account_id_of( ALICE, )), }); - + let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ @@ -278,7 +279,7 @@ fn relay_commands_kill_identity_wrong_origin() { } ]))), }); - + assert_ok!(xcm_message.dispatch(origin)); assert_expected_events!( Westend, @@ -286,13 +287,10 @@ fn relay_commands_kill_identity_wrong_origin() { RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, ] ); - }); - + }); + PeopleWestend::execute_with(|| { - assert_expected_events!( - PeopleWestend, - vec![] - ); + assert_expected_events!(PeopleWestend, vec![]); }); } } @@ -302,9 +300,8 @@ fn relay_commands_add_remove_username_authority() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let people_westend_bob = PeopleWestend::account_id_of(BOB); - let origins = vec![ - (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername") - ]; + let origins = + vec![(OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername")]; for (origin_kind, origin, usr) in origins { // First, add a username authority. Westend::execute_with(|| { @@ -454,7 +451,10 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let origins = vec![ - (OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice.clone())), + ( + OriginKind::SovereignAccount, + ::RuntimeOrigin::signed(people_westend_alice.clone()), + ), //(OriginKind::Xcm, GeneralAdminOrigin.into()), ]; @@ -500,17 +500,11 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { assert_err!( add_authority_xcm_msg.dispatch(origin.clone()), DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { - actual_weight: None, - pays_fee: Pays::Yes, - }, + post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, error: DispatchError::BadOrigin, }, ); - assert_expected_events!( - Westend, - vec![] - ); + assert_expected_events!(Westend, vec![]); } }); @@ -561,4 +555,4 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { signed_origin = false; } -} \ No newline at end of file +} From 12d89793a2dd79a6853b906b95d06311c0a9dbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Mon, 11 Nov 2024 15:03:36 +0000 Subject: [PATCH 10/14] Remove `require_weight_at_most` from test `Transact`s --- .../people/people-rococo/src/tests/governance.rs | 8 -------- .../people/people-westend/src/tests/governance.rs | 11 ----------- 2 files changed, 19 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index 6bc443903fdb4..95e33618930d4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -54,7 +54,6 @@ fn relay_commands_add_registrar() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), call: add_registrar_call.encode().into(), } ]))), @@ -117,7 +116,6 @@ fn relay_commands_add_registrar_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), call: add_registrar_call.encode().into(), } ]))), @@ -204,7 +202,6 @@ fn relay_commands_kill_identity() { // Making the weight's ref time any lower will prevent the XCM from triggering // execution of the intended extrinsic on the People chain - beware of spurious // test failure due to this. - require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), call: kill_identity_call.encode().into(), } ]))), @@ -268,7 +265,6 @@ fn relay_commands_kill_identity_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), call: kill_identity_call.encode().into(), } ]))), @@ -334,7 +330,6 @@ fn relay_commands_add_remove_username_authority() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: add_username_authority.encode().into(), } ]))), @@ -424,7 +419,6 @@ fn relay_commands_add_remove_username_authority() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: remove_username_authority.encode().into(), } ]))), @@ -491,7 +485,6 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: add_username_authority.encode().into(), } ]))), @@ -543,7 +536,6 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: remove_username_authority.encode().into(), } ]))), diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index d21b7eeaba36f..3650d43ec1d73 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -55,7 +55,6 @@ fn relay_commands_add_registrar() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), call: add_registrar_call.encode().into(), } ]))), @@ -118,7 +117,6 @@ fn relay_commands_add_registrar_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), call: add_registrar_call.encode().into(), } ]))), @@ -209,10 +207,6 @@ fn relay_commands_kill_identity() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - // Making the weight's ref time any lower will prevent the XCM from triggering - // execution of the intended extrinsic on the People chain - beware of spurious - // test failure due to this. - require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), call: kill_identity_call.encode().into(), } ]))), @@ -274,7 +268,6 @@ fn relay_commands_kill_identity_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(11_000_000_000, 500_000), call: kill_identity_call.encode().into(), } ]))), @@ -325,7 +318,6 @@ fn relay_commands_add_remove_username_authority() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: add_username_authority.encode().into(), } ]))), @@ -415,7 +407,6 @@ fn relay_commands_add_remove_username_authority() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: remove_username_authority.encode().into(), } ]))), @@ -482,7 +473,6 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: add_username_authority.encode().into(), } ]))), @@ -534,7 +524,6 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::from_parts(500_000_000, 500_000), call: remove_username_authority.encode().into(), } ]))), From 20b20b78b97319c7c8f5daface50e981d6760481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Mon, 11 Nov 2024 15:32:57 +0000 Subject: [PATCH 11/14] Apply `fmt` --- .../people-rococo/src/tests/governance.rs | 30 ++++------------ .../people-westend/src/tests/governance.rs | 35 ++++--------------- 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index 95e33618930d4..3da6c8a94e98a 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -52,10 +52,7 @@ fn relay_commands_add_registrar() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - } + Transact { origin_kind, call: add_registrar_call.encode().into() } ]))), }); @@ -114,10 +111,7 @@ fn relay_commands_add_registrar_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - } + Transact { origin_kind, call: add_registrar_call.encode().into() } ]))), }); @@ -263,10 +257,7 @@ fn relay_commands_kill_identity_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: kill_identity_call.encode().into(), - } + Transact { origin_kind, call: kill_identity_call.encode().into() } ]))), }); @@ -328,10 +319,7 @@ fn relay_commands_add_remove_username_authority() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - } + Transact { origin_kind, call: add_username_authority.encode().into() } ]))), }); @@ -417,10 +405,7 @@ fn relay_commands_add_remove_username_authority() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: remove_username_authority.encode().into(), - } + Transact { origin_kind, call: remove_username_authority.encode().into() } ]))), }); @@ -483,10 +468,7 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - } + Transact { origin_kind, call: add_username_authority.encode().into() } ]))), }); diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index 3650d43ec1d73..48eb6565aedb0 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -53,10 +53,7 @@ fn relay_commands_add_registrar() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - } + Transact { origin_kind, call: add_registrar_call.encode().into() } ]))), }); @@ -115,10 +112,7 @@ fn relay_commands_add_registrar_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_registrar_call.encode().into(), - } + Transact { origin_kind, call: add_registrar_call.encode().into() } ]))), }); @@ -205,10 +199,7 @@ fn relay_commands_kill_identity() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: kill_identity_call.encode().into(), - } + Transact { origin_kind, call: kill_identity_call.encode().into() } ]))), }); @@ -266,10 +257,7 @@ fn relay_commands_kill_identity_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: kill_identity_call.encode().into(), - } + Transact { origin_kind, call: kill_identity_call.encode().into() } ]))), }); @@ -316,10 +304,7 @@ fn relay_commands_add_remove_username_authority() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - } + Transact { origin_kind, call: add_username_authority.encode().into() } ]))), }); @@ -405,10 +390,7 @@ fn relay_commands_add_remove_username_authority() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: remove_username_authority.encode().into(), - } + Transact { origin_kind, call: remove_username_authority.encode().into() } ]))), }); @@ -471,10 +453,7 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - call: add_username_authority.encode().into(), - } + Transact { origin_kind, call: add_username_authority.encode().into() } ]))), }); From 9464e639ffe0e085d29ffaed8b8ab0b8af432be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Mon, 11 Nov 2024 20:32:20 +0000 Subject: [PATCH 12/14] Remove commented code from tests --- .../people-rococo/src/tests/governance.rs | 233 ++++++++-------- .../people-westend/src/tests/governance.rs | 256 ++++++++---------- 2 files changed, 233 insertions(+), 256 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs index 3da6c8a94e98a..11a0bcba71aad 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs @@ -294,144 +294,139 @@ fn relay_commands_add_remove_username_authority() { let people_rococo_alice = PeopleRococo::account_id_of(ALICE); let people_rococo_bob = PeopleRococo::account_id_of(BOB); - let origins = vec![ - //(OriginKind::Xcm, GeneralAdminOrigin.into(), "generaladmin"), - (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"), - ]; - for (origin_kind, origin, usr) in origins { - // First, add a username authority. - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + let (origin_kind, origin, usr) = + (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"); - let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::add_username_authority { + // First, add a username authority. + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = + PeopleCall::Identity(pallet_identity::Call::::add_username_authority { authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), suffix: b"suffix1".into(), allocation: 10, }); - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_username_authority.encode().into() } - ]))), - }); + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { origin_kind, call: add_username_authority.encode().into() } + ]))), + }); - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); - // Check events system-parachain-side - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); + // Check events system-parachain-side + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - // Now, use the previously added username authority to concede a username to an account. - PeopleRococo::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(::Identity::set_username_for( - ::RuntimeOrigin::signed(people_rococo_alice.clone()), - people_rococo_runtime::MultiAddress::Id(people_rococo_bob.clone()), - full_username, - None, - true - )); - - assert_expected_events!( - PeopleRococo, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); - // Accept the given username - PeopleRococo::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(::Identity::accept_username( - ::RuntimeOrigin::signed(people_rococo_bob.clone()), - full_username.try_into().unwrap(), - )); - - assert_expected_events!( - PeopleRococo, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, - ] - ); - }); + // Now, use the previously added username authority to concede a username to an account. + PeopleRococo::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::set_username_for( + ::RuntimeOrigin::signed(people_rococo_alice.clone()), + people_rococo_runtime::MultiAddress::Id(people_rococo_bob.clone()), + full_username, + None, + true + )); - // Now, remove the username authority with another priviledged XCM call. - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + assert_expected_events!( + PeopleRococo, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, + ] + ); + }); - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into(), - }); + // Accept the given username + PeopleRococo::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - let remove_authority_xcm_msg = - RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: remove_username_authority.encode().into() } - ]))), - }); + assert_ok!(::Identity::accept_username( + ::RuntimeOrigin::signed(people_rococo_bob.clone()), + full_username.try_into().unwrap(), + )); - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + assert_expected_events!( + PeopleRococo, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, + ] + ); + }); + + // Now, remove the username authority with another priviledged XCM call. + Rococo::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), + suffix: b"suffix1".into(), }); - // Final event check. - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); + let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { origin_kind, call: remove_username_authority.encode().into() } + ]))), }); - } + + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Final event check. + PeopleRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleRococo, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); } #[test] diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index 48eb6565aedb0..b49360eb680f4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -281,142 +281,139 @@ fn relay_commands_add_remove_username_authority() { let people_westend_alice = PeopleWestend::account_id_of(ALICE); let people_westend_bob = PeopleWestend::account_id_of(BOB); - let origins = - vec![(OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername")]; - for (origin_kind, origin, usr) in origins { - // First, add a username authority. - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + let (origin_kind, origin, usr) = + (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"); - let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::add_username_authority { + // First, add a username authority. + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; + + let add_username_authority = + PeopleCall::Identity(pallet_identity::Call::::add_username_authority { authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), suffix: b"suffix1".into(), allocation: 10, }); - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_username_authority.encode().into() } - ]))), - }); - - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { origin_kind, call: add_username_authority.encode().into() } + ]))), }); - // Check events system-parachain-side - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - - // Now, use the previously added username authority to concede a username to an account. - PeopleWestend::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); - assert_ok!(::Identity::set_username_for( - ::RuntimeOrigin::signed(people_westend_alice.clone()), - people_westend_runtime::MultiAddress::Id(people_westend_bob.clone()), - full_username, - None, - true - )); + // Check events system-parachain-side + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - PeopleWestend, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, - ] - ); - }); + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); - // Accept the given username - PeopleWestend::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + // Now, use the previously added username authority to concede a username to an account. + PeopleWestend::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); + + assert_ok!(::Identity::set_username_for( + ::RuntimeOrigin::signed(people_westend_alice.clone()), + people_westend_runtime::MultiAddress::Id(people_westend_bob.clone()), + full_username, + None, + true + )); - assert_ok!(::Identity::accept_username( - ::RuntimeOrigin::signed(people_westend_bob.clone()), - full_username.try_into().unwrap(), - )); + assert_expected_events!( + PeopleWestend, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, + ] + ); + }); - assert_expected_events!( - PeopleWestend, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, - ] - ); - }); + // Accept the given username + PeopleWestend::execute_with(|| { + type PeopleRuntimeEvent = ::RuntimeEvent; + let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - // Now, remove the username authority with another priviledged XCM call. - Westend::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; + assert_ok!(::Identity::accept_username( + ::RuntimeOrigin::signed(people_westend_bob.clone()), + full_username.try_into().unwrap(), + )); - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), - suffix: b"suffix1".into(), - }); + assert_expected_events!( + PeopleWestend, + vec![ + PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, + ] + ); + }); - let remove_authority_xcm_msg = - RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: remove_username_authority.encode().into() } - ]))), - }); + // Now, remove the username authority with another priviledged XCM call. + Westend::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type RuntimeEvent = ::RuntimeEvent; + type PeopleCall = ::RuntimeCall; + type PeopleRuntime = ::Runtime; - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); + let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< + PeopleRuntime, + >::remove_username_authority { + authority: people_westend_runtime::MultiAddress::Id(people_westend_alice.clone()), + suffix: b"suffix1".into(), + }); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); + let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { origin_kind, call: remove_username_authority.encode().into() } + ]))), }); - // Final event check. - PeopleWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + assert_ok!(remove_authority_xcm_msg.dispatch(origin)); - assert_expected_events!( - PeopleWestend, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - } + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Final event check. + PeopleWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PeopleWestend, + vec![ + RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, + ] + ); + }); } #[test] @@ -428,11 +425,9 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { OriginKind::SovereignAccount, ::RuntimeOrigin::signed(people_westend_alice.clone()), ), - //(OriginKind::Xcm, GeneralAdminOrigin.into()), + (OriginKind::Xcm, GeneralAdminOrigin.into()), ]; - let mut signed_origin = true; - for (origin_kind, origin) in origins { Westend::execute_with(|| { type Runtime = ::Runtime; @@ -457,24 +452,13 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { ]))), }); - if signed_origin { - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - } else { - assert_err!( - add_authority_xcm_msg.dispatch(origin.clone()), - DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, - error: DispatchError::BadOrigin, - }, - ); - assert_expected_events!(Westend, vec![]); - } + assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); }); // Check events system-parachain-side @@ -520,7 +504,5 @@ fn relay_commands_add_remove_username_authority_wrong_origin() { PeopleWestend::execute_with(|| { assert_expected_events!(PeopleWestend, vec![]); }); - - signed_origin = false; } } From 0300305b357fcbef99a65b1a6861e6bdaf80fd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Tue, 12 Nov 2024 01:15:09 +0000 Subject: [PATCH 13/14] Remove unnused imports --- .../tests/people/people-westend/src/tests/governance.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs index b49360eb680f4..3dadcdd948705 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/governance.rs @@ -17,12 +17,7 @@ use crate::imports::*; use frame_support::traits::ProcessMessageError; use codec::Encode; -use frame_support::{ - assert_err, - dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, - pallet_prelude::{DispatchError, Pays}, - sp_runtime::traits::Dispatchable, -}; +use frame_support::sp_runtime::traits::Dispatchable; use parachains_common::AccountId; use people_westend_runtime::people::IdentityInfo; use westend_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; From 5df9be26542b108a29c502b83ce6967c8bc4bdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Tue, 12 Nov 2024 19:20:10 +0000 Subject: [PATCH 14/14] Remove Rococo tests (testnet is deprecated) --- Cargo.lock | 2 - .../tests/people/people-rococo/Cargo.toml | 2 - .../people-rococo/src/tests/governance.rs | 547 ------------------ .../people/people-rococo/src/tests/mod.rs | 1 - 4 files changed, 552 deletions(-) delete mode 100644 cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs diff --git a/Cargo.lock b/Cargo.lock index 91e8585e39d39..daf7494265e3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13687,11 +13687,9 @@ dependencies = [ "pallet-balances", "pallet-identity", "pallet-message-queue", - "pallet-xcm", "parachains-common", "parity-scale-codec", "polkadot-runtime-common", - "rococo-runtime", "rococo-runtime-constants", "rococo-system-emulated-network", "sp-runtime 31.0.1", diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml index 3e1d339eef8c4..011be93ecac73 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml @@ -15,13 +15,11 @@ frame-support = { workspace = true } pallet-balances = { workspace = true } pallet-message-queue = { workspace = true } pallet-identity = { workspace = true } -pallet-xcm = { workspace = true } sp-runtime = { workspace = true } # Polkadot polkadot-runtime-common = { workspace = true, default-features = true } rococo-runtime-constants = { workspace = true, default-features = true } -rococo-runtime = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs deleted file mode 100644 index 11a0bcba71aad..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs +++ /dev/null @@ -1,547 +0,0 @@ -// 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::imports::*; - -use codec::Encode; -use frame_support::{ - assert_err, - dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, - pallet_prelude::{DispatchError, Pays}, - sp_runtime::traits::Dispatchable, -}; -use parachains_common::AccountId; -use people_rococo_runtime::people::IdentityInfo; -use rococo_runtime::governance::pallet_custom_origins::Origin::GeneralAdmin as GeneralAdminOrigin; -use rococo_system_emulated_network::people_rococo_emulated_chain::people_rococo_runtime; - -use pallet_identity::Data; - -use emulated_integration_tests_common::accounts::{ALICE, BOB}; - -#[test] -fn relay_commands_add_registrar() { - let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); - - let registrar: AccountId = [1; 32].into(); - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_registrar_call.encode().into() } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::RegistrarAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_add_registrar_wrong_origin() { - let people_rococo_alice = PeopleRococo::account_id_of(ALICE); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_rococo_alice), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - let mut signed_origin = true; - - for (origin_kind, origin) in origins { - let registrar: AccountId = [1; 32].into(); - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_registrar_call = - PeopleCall::Identity(pallet_identity::Call::::add_registrar { - account: registrar.into(), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_registrar_call.encode().into() } - ]))), - }); - - if signed_origin { - assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - } else { - assert_err!( - xcm_message.dispatch(origin), - DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, - error: DispatchError::BadOrigin, - }, - ); - assert_expected_events!(Rococo, vec![]); - } - }); - - PeopleRococo::execute_with(|| { - assert_expected_events!(PeopleRococo, vec![]); - }); - - signed_origin = false; - } -} - -#[test] -fn relay_commands_kill_identity() { - // To kill an identity, first one must be set - PeopleRococo::execute_with(|| { - type PeopleRuntime = ::Runtime; - type PeopleRuntimeEvent = ::RuntimeEvent; - - let people_rococo_alice = - ::RuntimeOrigin::signed(PeopleRococo::account_id_of(ALICE)); - - let identity_info = IdentityInfo { - email: Data::Raw(b"test@test.io".to_vec().try_into().unwrap()), - ..Default::default() - }; - let identity: Box<::IdentityInformation> = - Box::new(identity_info); - - assert_ok!(::Identity::set_identity( - people_rococo_alice, - identity - )); - - assert_expected_events!( - PeopleRococo, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::IdentitySet { .. }) => {}, - ] - ); - }); - - let (origin_kind, origin) = (OriginKind::Superuser, ::RuntimeOrigin::root()); - - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type PeopleCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleRuntime = ::Runtime; - - let kill_identity_call = - PeopleCall::Identity(pallet_identity::Call::::kill_identity { - target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of(ALICE)), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind, - // Making the weight's ref time any lower will prevent the XCM from triggering - // execution of the intended extrinsic on the People chain - beware of spurious - // test failure due to this. - call: kill_identity_call.encode().into(), - } - ]))), - }); - - assert_ok!(xcm_message.dispatch(origin)); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::IdentityKilled { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_kill_identity_wrong_origin() { - let people_rococo_alice = PeopleRococo::account_id_of(BOB); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_rococo_alice), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - let mut signed_origin: bool = true; - - for (origin_kind, origin) in origins { - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type PeopleCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleRuntime = ::Runtime; - - let kill_identity_call = - PeopleCall::Identity(pallet_identity::Call::::kill_identity { - target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of( - ALICE, - )), - }); - - let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: kill_identity_call.encode().into() } - ]))), - }); - - if signed_origin { - assert_ok!(xcm_message.dispatch(origin)); - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - } else { - assert_err!( - xcm_message.dispatch(origin), - DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, - error: DispatchError::BadOrigin, - }, - ); - assert_expected_events!(Rococo, vec![]); - } - }); - - PeopleRococo::execute_with(|| { - assert_expected_events!(PeopleRococo, vec![]); - }); - - signed_origin = false; - } -} - -#[test] -fn relay_commands_add_remove_username_authority() { - let people_rococo_alice = PeopleRococo::account_id_of(ALICE); - let people_rococo_bob = PeopleRococo::account_id_of(BOB); - - let (origin_kind, origin, usr) = - (OriginKind::Superuser, ::RuntimeOrigin::root(), "rootusername"); - - // First, add a username authority. - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_username_authority = - PeopleCall::Identity(pallet_identity::Call::::add_username_authority { - authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into(), - allocation: 10, - }); - - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_username_authority.encode().into() } - ]))), - }); - - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Check events system-parachain-side - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityAdded { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); - - // Now, use the previously added username authority to concede a username to an account. - PeopleRococo::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(::Identity::set_username_for( - ::RuntimeOrigin::signed(people_rococo_alice.clone()), - people_rococo_runtime::MultiAddress::Id(people_rococo_bob.clone()), - full_username, - None, - true - )); - - assert_expected_events!( - PeopleRococo, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameQueued { .. }) => {}, - ] - ); - }); - - // Accept the given username - PeopleRococo::execute_with(|| { - type PeopleRuntimeEvent = ::RuntimeEvent; - let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); - - assert_ok!(::Identity::accept_username( - ::RuntimeOrigin::signed(people_rococo_bob.clone()), - full_username.try_into().unwrap(), - )); - - assert_expected_events!( - PeopleRococo, - vec![ - PeopleRuntimeEvent::Identity(pallet_identity::Event::UsernameSet { .. }) => {}, - ] - ); - }); - - // Now, remove the username authority with another priviledged XCM call. - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into(), - }); - - let remove_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: remove_username_authority.encode().into() } - ]))), - }); - - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); - - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Final event check. - PeopleRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PeopleRococo, - vec![ - RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, - ] - ); - }); -} - -#[test] -fn relay_commands_add_remove_username_authority_wrong_origin() { - let people_rococo_alice = PeopleRococo::account_id_of(ALICE); - - let origins = vec![ - ( - OriginKind::SovereignAccount, - ::RuntimeOrigin::signed(people_rococo_alice.clone()), - ), - (OriginKind::Xcm, GeneralAdminOrigin.into()), - ]; - - let mut signed_origin = true; - - for (origin_kind, origin) in origins { - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let add_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::add_username_authority { - authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into(), - allocation: 10, - }); - - let add_authority_xcm_msg = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { origin_kind, call: add_username_authority.encode().into() } - ]))), - }); - - if signed_origin { - assert_ok!(add_authority_xcm_msg.dispatch(origin.clone())); - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - } else { - assert_err!( - add_authority_xcm_msg.dispatch(origin.clone()), - DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, - error: DispatchError::BadOrigin, - }, - ); - assert_expected_events!(Rococo, vec![]); - } - }); - - // Check events system-parachain-side - PeopleRococo::execute_with(|| { - assert_expected_events!(PeopleRococo, vec![]); - }); - - Rococo::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type RuntimeEvent = ::RuntimeEvent; - type PeopleCall = ::RuntimeCall; - type PeopleRuntime = ::Runtime; - - let remove_username_authority = PeopleCall::Identity(pallet_identity::Call::< - PeopleRuntime, - >::remove_username_authority { - authority: people_rococo_runtime::MultiAddress::Id(people_rococo_alice.clone()), - suffix: b"suffix1".into(), - }); - - let remove_authority_xcm_msg = - RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::SovereignAccount, - call: remove_username_authority.encode().into(), - } - ]))), - }); - - if signed_origin { - assert_ok!(remove_authority_xcm_msg.dispatch(origin)); - assert_expected_events!( - Rococo, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - } else { - assert_err!( - remove_authority_xcm_msg.dispatch(origin), - DispatchErrorWithPostInfo { - post_info: PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes }, - error: DispatchError::BadOrigin, - }, - ); - assert_expected_events!(Rococo, vec![]); - } - }); - - PeopleRococo::execute_with(|| { - assert_expected_events!(PeopleRococo, vec![]); - }); - - signed_origin = false; - } -} diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs index b9ad9e3db467f..08749b295dc21 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/mod.rs @@ -14,5 +14,4 @@ // limitations under the License. mod claim_assets; -mod governance; mod teleport;