-
Notifications
You must be signed in to change notification settings - Fork 1.2k
People chain integration tests #6377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1f1efd5
Replicate people chain integration tests in Rococo
rockbmb 7a284fd
Replicate people chain integration tests in Westend
rockbmb 96cb9a8
Remove unused import
rockbmb 2b2955d
Apply `fmt`
rockbmb d2e4072
Merge branch 'master' into people-chain-integration-tests
rockbmb 1f2a958
Add origin check tests to Westend
rockbmb 0fc54ca
Check general admin origin with username authorities
rockbmb 2af0b7d
Fix tests checking wrong origin in extrinsics (Rococo)
rockbmb 15a231b
Add origin check integration tests to Westend
rockbmb 52d6f78
Apply `cargo fmt`
rockbmb 4159e9e
Merge branch 'master' into people-chain-integration-tests
rockbmb 12d8979
Remove `require_weight_at_most` from test `Transact`s
rockbmb 20b20b7
Apply `fmt`
rockbmb 9464e63
Remove commented code from tests
rockbmb 0300305
Remove unnused imports
rockbmb 5df9be2
Remove Rococo tests (testnet is deprecated)
rockbmb 77535da
Merge branch 'master' into people-chain-integration-tests
rockbmb 9e9ad83
Merge branch 'master' into people-chain-integration-tests
rockbmb 9c9a503
Merge branch 'master' into people-chain-integration-tests
seadanda 6eb8c63
Merge branch 'master' into people-chain-integration-tests
seadanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
317 changes: 317 additions & 0 deletions
317
.../parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/governance.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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_rococo_runtime::people::IdentityInfo; | ||
| 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, <Rococo as Chain>::RuntimeOrigin::root()), | ||
| ]; | ||
| for (origin_kind, origin) in origins { | ||
| let registrar: AccountId = [1; 32].into(); | ||
| Rococo::execute_with(|| { | ||
| type Runtime = <Rococo as Chain>::Runtime; | ||
| type RuntimeCall = <Rococo as Chain>::RuntimeCall; | ||
| type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; | ||
| type PeopleCall = <PeopleRococo as Chain>::RuntimeCall; | ||
| type PeopleRuntime = <PeopleRococo as Chain>::Runtime; | ||
|
|
||
| let add_registrar_call = | ||
| PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::add_registrar { | ||
| account: registrar.into(), | ||
| }); | ||
|
|
||
| let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::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 = <PeopleRococo as Chain>::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 = <PeopleRococo as Chain>::Runtime; | ||
| type PeopleRuntimeEvent = <PeopleRococo as Chain>::RuntimeEvent; | ||
|
|
||
| let people_rococo_alice = | ||
| <PeopleRococo as Chain>::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<<PeopleRuntime as pallet_identity::Config>::IdentityInformation> = | ||
| Box::new(identity_info); | ||
|
|
||
| assert_ok!(<PeopleRococo as PeopleRococoPallet>::Identity::set_identity( | ||
| people_rococo_alice, | ||
| identity | ||
| )); | ||
|
|
||
| assert_expected_events!( | ||
| PeopleRococo, | ||
| vec![ | ||
| PeopleRuntimeEvent::Identity(pallet_identity::Event::IdentitySet { .. }) => {}, | ||
| ] | ||
| ); | ||
| }); | ||
|
|
||
| let (origin_kind, origin) = (OriginKind::Superuser, <Rococo as Chain>::RuntimeOrigin::root()); | ||
|
|
||
| Rococo::execute_with(|| { | ||
| type Runtime = <Rococo as Chain>::Runtime; | ||
| type RuntimeCall = <Rococo as Chain>::RuntimeCall; | ||
| type PeopleCall = <PeopleRococo as Chain>::RuntimeCall; | ||
| type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; | ||
| type PeopleRuntime = <PeopleRococo as Chain>::Runtime; | ||
|
|
||
| let kill_identity_call = | ||
| PeopleCall::Identity(pallet_identity::Call::<PeopleRuntime>::kill_identity { | ||
| target: people_rococo_runtime::MultiAddress::Id(PeopleRococo::account_id_of(ALICE)), | ||
| }); | ||
|
|
||
| let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::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 = <PeopleRococo as Chain>::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, <Rococo as Chain>::RuntimeOrigin::root(), "rootusername"), | ||
| ]; | ||
| for (origin_kind, origin, usr) in origins { | ||
| // First, add a username authority. | ||
| Rococo::execute_with(|| { | ||
| type Runtime = <Rococo as Chain>::Runtime; | ||
| type RuntimeCall = <Rococo as Chain>::RuntimeCall; | ||
| type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; | ||
| type PeopleCall = <PeopleRococo as Chain>::RuntimeCall; | ||
| type PeopleRuntime = <PeopleRococo as Chain>::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::<Runtime>::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 = <PeopleRococo as Chain>::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 = <PeopleRococo as Chain>::RuntimeEvent; | ||
| let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); | ||
|
|
||
| assert_ok!(<PeopleRococo as PeopleRococoPallet>::Identity::set_username_for( | ||
| <PeopleRococo as Chain>::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 = <PeopleRococo as Chain>::RuntimeEvent; | ||
| let full_username = [usr.to_owned(), ".suffix1".to_owned()].concat().into_bytes(); | ||
|
|
||
| assert_ok!(<PeopleRococo as PeopleRococoPallet>::Identity::accept_username( | ||
| <PeopleRococo as Chain>::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 = <Rococo as Chain>::Runtime; | ||
| type RuntimeCall = <Rococo as Chain>::RuntimeCall; | ||
| type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; | ||
| type PeopleCall = <PeopleRococo as Chain>::RuntimeCall; | ||
| type PeopleRuntime = <PeopleRococo as Chain>::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::<Runtime>::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 = <PeopleRococo as Chain>::RuntimeEvent; | ||
|
|
||
| assert_expected_events!( | ||
| PeopleRococo, | ||
| vec![ | ||
| RuntimeEvent::Identity(pallet_identity::Event::AuthorityRemoved { .. }) => {}, | ||
| RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, | ||
| ] | ||
| ); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,5 @@ | |
| // limitations under the License. | ||
|
|
||
| mod claim_assets; | ||
| mod governance; | ||
| mod teleport; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.