-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collectives tests: Teleports and Whitelist Call (#251)
Introduce teleport and whitelist call tests for Polkadot Collectives. Based on #233 - [x] Does not require a CHANGELOG entry --------- Co-authored-by: joe petrowski <[email protected]> Co-authored-by: Branislav Kontur <[email protected]>
- Loading branch information
1 parent
67af9b9
commit c2886b9
Showing
16 changed files
with
348 additions
and
15 deletions.
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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
72 changes: 72 additions & 0 deletions
72
integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship.rs
This file contains 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,72 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::*; | ||
use codec::Encode; | ||
use collectives_polkadot_runtime::fellowship::pallet_fellowship_origins::Origin::Fellows as FellowsOrigin; | ||
use frame_support::{assert_ok, sp_runtime::traits::Dispatchable}; | ||
|
||
#[test] | ||
fn fellows_whitelist_call() { | ||
CollectivesPolkadot::execute_with(|| { | ||
type RuntimeEvent = <CollectivesPolkadot as Chain>::RuntimeEvent; | ||
type RuntimeCall = <CollectivesPolkadot as Chain>::RuntimeCall; | ||
type RuntimeOrigin = <CollectivesPolkadot as Chain>::RuntimeOrigin; | ||
type Runtime = <CollectivesPolkadot as Chain>::Runtime; | ||
type PolkadotCall = <Polkadot as Chain>::RuntimeCall; | ||
type PolkadotRuntime = <Polkadot as Chain>::Runtime; | ||
|
||
let call_hash = [1u8; 32].into(); | ||
|
||
let whitelist_call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::<Runtime>::send { | ||
dest: bx!(VersionedLocation::V4(Parent.into())), | ||
message: bx!(VersionedXcm::V4(Xcm(vec![ | ||
UnpaidExecution { weight_limit: Unlimited, check_origin: None }, | ||
Transact { | ||
origin_kind: OriginKind::Xcm, | ||
require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000), | ||
call: PolkadotCall::Whitelist( | ||
pallet_whitelist::Call::<PolkadotRuntime>::whitelist_call { call_hash } | ||
) | ||
.encode() | ||
.into(), | ||
} | ||
]))), | ||
}); | ||
|
||
let fellows_origin: RuntimeOrigin = FellowsOrigin.into(); | ||
|
||
assert_ok!(whitelist_call.dispatch(fellows_origin)); | ||
|
||
assert_expected_events!( | ||
CollectivesPolkadot, | ||
vec![ | ||
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
|
||
Polkadot::execute_with(|| { | ||
type RuntimeEvent = <Polkadot as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
Polkadot, | ||
vec![ | ||
RuntimeEvent::Whitelist(pallet_whitelist::Event::CallWhitelisted { .. }) => {}, | ||
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) => {}, | ||
] | ||
); | ||
}); | ||
} |
This file contains 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
Oops, something went wrong.