Lines
100 %
Functions
Branches
// Copyright (C) Moondance Labs Ltd.
// This file is part of Tanssi.
// Tanssi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Tanssi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>
#![cfg(test)]
use {
crate::{tests::common::*, EthereumSystem},
frame_support::assert_noop,
pallet_xcm::Origin as XcmOrigin,
snowbridge_core::outbound::OperatingMode,
sp_core::H160,
sp_runtime::DispatchError::BadOrigin,
sp_std::vec,
xcm::latest::{Junction::Parachain, Location},
};
#[test]
fn test_create_agent_not_allowed() {
ExtBuilder::default()
.with_balances(vec![(AccountId::from(ALICE), 210_000 * UNIT)])
.build()
.execute_with(|| {
let sibling_para_location = Location::new(1, [Parachain(2000)]);
// create_agent is disabled for sibling parachains
assert_noop!(
EthereumSystem::create_agent(XcmOrigin::Xcm(sibling_para_location).into()),
BadOrigin
);
let relay_location = Location::new(1, []);
// create_agent also disabled for relay origin
EthereumSystem::create_agent(XcmOrigin::Xcm(relay_location).into()),
// create_agent is disabled for signed origins
EthereumSystem::create_agent(
<Runtime as frame_system::Config>::RuntimeOrigin::signed(AccountId::from(
ALICE
))
),
// create_agent is disabled for root
<Runtime as frame_system::Config>::RuntimeOrigin::root()
})
}
fn test_create_channel_not_allowed() {
// create_channel is disabled for sibling parachains
EthereumSystem::create_channel(
XcmOrigin::Xcm(sibling_para_location).into(),
OperatingMode::Normal
// create_channel also disabled for relay origin
XcmOrigin::Xcm(relay_location).into(),
// create_channel is disabled for signed origins
)),
// create_channel is disabled for root
<Runtime as frame_system::Config>::RuntimeOrigin::root(),
fn test_update_channel_not_allowed() {
// update_channel is disabled for sibling parachains
EthereumSystem::update_channel(
// update_channel also disabled for relay origin
// update_channel is disabled for signed origins
// update_channel is disabled for root
fn test_transfer_native_from_agent_not_allowed() {
// transfer_native_from_agent is disabled for sibling parachains
EthereumSystem::transfer_native_from_agent(
H160::default(),
1000u128
// transfer_native_from_agent also disabled for relay origin
// transfer_native_from_agent is disabled for signed origins
// transfer_native_from_agent is disabled for root