Files
pezkuwi-sdk/pezcumulus/teyrchains/runtimes/bridge-hubs/common/tests/tests.rs
T
pezkuwichain cf463fe8ee FAZ 1 Complete: Workspace compile fixes, warning cleanup, version bumps
- Fixed is_using_frame_crate() macro to check for pezframe/pezkuwi_sdk
- Removed disable_pezframe_system_supertrait_check temporary bypasses
- Feature-gated storage-benchmark and teyrchain-benchmarks code
- Fixed dead_code warnings with underscore prefix (_Header)
- Removed unused imports and shadowing use statements
- Version bumps: procedural-tools 10.0.1, benchmarking-cli 32.0.1,
  docs 0.0.2, minimal-runtime 0.0.1, yet-another-teyrchain 0.6.1, umbrella 0.1.2
- Updated MAINNET_ROADMAP.md with FAZ 1 completion status
2026-01-02 11:41:09 +03:00

86 lines
2.7 KiB
Rust

// Copyright (C) Parity Technologies (UK) Ltd. and Dijital Kurdistan Tech Institute
// This file is part of Pezcumulus.
// 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.
#![cfg(test)]
use pezbridge_hub_common::DenyExportMessageFrom;
use pezframe_support::{
parameter_types,
traits::{Equals, EverythingBut, ProcessMessageError::Unsupported},
};
use xcm::prelude::{
AliasOrigin, ByGenesis, ExportMessage, Here, Instruction, Location, NetworkId, Teyrchain,
Weight,
};
use xcm_executor::traits::{DenyExecution, Properties};
#[test]
fn test_deny_export_message_from() {
parameter_types! {
pub Source1: Location = Location::new(1, Teyrchain(1));
pub Source2: Location = Location::new(1, Teyrchain(2));
pub Remote1: NetworkId = ByGenesis([1;32]);
pub Remote2: NetworkId = ByGenesis([2;32]);
}
// Deny ExportMessage when both of the conditions met:
// 1: source != Source1
// 2: network == Remote1
pub type Denied = DenyExportMessageFrom<EverythingBut<Equals<Source1>>, Equals<Remote1>>;
let assert_deny_execution = |mut xcm: Vec<Instruction<()>>, origin, expected_result| {
assert_eq!(
Denied::deny_execution(
&origin,
&mut xcm,
Weight::zero(),
&mut Properties { weight_credit: Weight::zero(), message_id: None }
),
expected_result
);
};
// A message without an `ExportMessage` should pass
assert_deny_execution(vec![AliasOrigin(Here.into())], Source1::get(), Ok(()));
// `ExportMessage` from source1 and remote1 should pass
assert_deny_execution(
vec![ExportMessage { network: Remote1::get(), destination: Here, xcm: Default::default() }],
Source1::get(),
Ok(()),
);
// `ExportMessage` from source1 and remote2 should pass
assert_deny_execution(
vec![ExportMessage { network: Remote2::get(), destination: Here, xcm: Default::default() }],
Source1::get(),
Ok(()),
);
// `ExportMessage` from source2 and remote2 should pass
assert_deny_execution(
vec![ExportMessage { network: Remote2::get(), destination: Here, xcm: Default::default() }],
Source2::get(),
Ok(()),
);
// `ExportMessage` from source2 and remote1 should be banned
assert_deny_execution(
vec![ExportMessage { network: Remote1::get(), destination: Here, xcm: Default::default() }],
Source2::get(),
Err(Unsupported),
);
}