Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Sep 6, 2024
1 parent 8337f9b commit 1314a18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 56 deletions.
1 change: 0 additions & 1 deletion bridges/snowbridge/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ parameter_types! {
multiplier: FixedU128::from_rational(4, 3)
};
pub const InboundDeliveryCost: u128 = 1_000_000_000;
pub const EnableRegisterToken: bool = false;
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
use crate::imports::*;
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
use bridge_hub_westend_runtime::{xcm_config::TreasuryAccount, EthereumInboundQueue};
use bridge_hub_westend_runtime::EthereumInboundQueue;
use codec::{Decode, Encode};
use emulated_integration_tests_common::{
PenpalBSiblingSovereignAccount, RESERVABLE_ASSET_ID, TELEPORTABLE_ASSET_ID,
Expand Down Expand Up @@ -294,7 +294,6 @@ fn transfer_relay_token() {
BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id()),
);
BridgeHubWestend::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]);
BridgeHubWestend::fund_accounts(vec![(TreasuryAccount::get(), INITIAL_FUND * 10)]);

let asset_id: Location = Location { parents: 1, interior: [].into() };
let expected_asset_id: Location =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,22 @@
use bp_asset_hub_westend::ASSET_HUB_WESTEND_PARACHAIN_ID;
use bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID;
use bp_polkadot_core::Signature;
use bridge_hub_test_utils::{ExtBuilder, RuntimeHelper};
use bridge_hub_westend_runtime::{
bridge_to_ethereum_config::EnableRegisterToken, bridge_to_rococo_config, xcm_config::XcmConfig,
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive,
MessageQueueServiceWeight, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra,
UncheckedExtrinsic,
bridge_to_rococo_config, xcm_config::XcmConfig, AllPalletsWithoutSystem,
BridgeRejectObsoleteHeadersAndMessages, Executive, MessageQueueServiceWeight, Runtime,
RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra, UncheckedExtrinsic,
};
use codec::{Decode, Encode};
use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees};
use frame_support::{assert_err, assert_ok, parameter_types};
use frame_support::parameter_types;
use parachains_common::{AccountId, AuraId, Balance};
use snowbridge_core::{outbound::SendError, AssetMetadata};
use snowbridge_pallet_ethereum_client::WeightInfo;
use sp_core::H160;
use sp_keyring::AccountKeyring::{Alice, Ferdie};
use sp_keyring::AccountKeyring::Alice;
use sp_runtime::{
generic::{Era, SignedPayload},
traits::BadOrigin,
AccountId32,
};
use xcm::{
prelude::{GlobalConsensus, Location, Westend},
VersionedLocation,
};

parameter_types! {
pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000;
Expand Down Expand Up @@ -208,43 +200,3 @@ fn construct_and_apply_extrinsic(
let r = Executive::apply_extrinsic(xt);
r.unwrap()
}

#[test]
fn enable_register_token_flag_works() {
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_keys().collators())
.with_session_keys(collator_session_keys().session_keys())
.with_para_id(BRIDGE_HUB_WESTEND_PARACHAIN_ID.into())
.with_tracing()
.build()
.execute_with(|| {
let location: VersionedLocation =
VersionedLocation::from(Location::new(1, [GlobalConsensus(Westend)]));
let metadata: AssetMetadata = AssetMetadata {
name: "wnd".as_bytes().to_vec().try_into().unwrap(),
symbol: "wnd".as_bytes().to_vec().try_into().unwrap(),
decimals: 12,
};
assert_err!(
<snowbridge_pallet_system::Pallet<Runtime>>::register_token(
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(Ferdie.into()),
Box::new(location.clone()),
metadata.clone(),
),
BadOrigin
);
assert_ok!(<frame_system::Pallet<Runtime>>::set_storage(
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::root_origin(),
vec![(EnableRegisterToken::key().to_vec(), true.encode())],
));
// Send error here means the origin check is passed and register token is enabled
assert_err!(
<snowbridge_pallet_system::Pallet<Runtime>>::register_token(
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(Ferdie.into()),
Box::new(location.clone()),
metadata.clone(),
),
<snowbridge_pallet_system::Error<Runtime>>::Send(SendError::InvalidChannel)
);
});
}

0 comments on commit 1314a18

Please sign in to comment.