mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 02:51:01 +00:00
18d53dbf91
# Description Adds Snowbridge to the Rococo bridge hub runtime. Includes config changes required in Rococo asset hub. --------- Co-authored-by: Alistair Singh <alistair.singh7@gmail.com> Co-authored-by: ron <yrong1997@gmail.com> Co-authored-by: Vincent Geddes <vincent.geddes@hey.com> Co-authored-by: claravanstaden <Cats 4 life!>
95 lines
2.6 KiB
Rust
95 lines
2.6 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
|
|
|
#![cfg(test)]
|
|
|
|
mod test_cases;
|
|
|
|
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
|
|
use bridge_hub_rococo_runtime::{
|
|
xcm_config::XcmConfig, MessageQueueServiceWeight, Runtime, RuntimeEvent, SessionKeys,
|
|
};
|
|
use codec::Decode;
|
|
use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees};
|
|
use parachains_common::{AccountId, AuraId};
|
|
use snowbridge_ethereum_beacon_client::WeightInfo;
|
|
use sp_core::H160;
|
|
use sp_keyring::AccountKeyring::Alice;
|
|
|
|
pub fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime> {
|
|
bridge_hub_test_utils::CollatorSessionKeys::new(
|
|
AccountId::from(Alice),
|
|
AccountId::from(Alice),
|
|
SessionKeys { aura: AuraId::from(Alice.public()) },
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
pub fn transfer_token_to_ethereum_works() {
|
|
test_cases::send_transfer_token_message_success::<Runtime, XcmConfig>(
|
|
collator_session_keys(),
|
|
1013,
|
|
1000,
|
|
H160::random(),
|
|
H160::random(),
|
|
DefaultBridgeHubEthereumBaseFee::get(),
|
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
|
Ok(RuntimeEvent::EthereumOutboundQueue(event)) => Some(event),
|
|
_ => None,
|
|
}
|
|
}),
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() {
|
|
test_cases::send_unpaid_transfer_token_message::<Runtime, XcmConfig>(
|
|
collator_session_keys(),
|
|
1013,
|
|
1000,
|
|
H160::random(),
|
|
H160::random(),
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
pub fn transfer_token_to_ethereum_fee_not_enough() {
|
|
test_cases::send_transfer_token_message_failure::<Runtime, XcmConfig>(
|
|
collator_session_keys(),
|
|
1013,
|
|
1000,
|
|
DefaultBridgeHubEthereumBaseFee::get() + 1_000_000_000,
|
|
H160::random(),
|
|
H160::random(),
|
|
// fee not enough
|
|
1_000_000_000,
|
|
NotHoldingFees,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
pub fn transfer_token_to_ethereum_insufficient_fund() {
|
|
test_cases::send_transfer_token_message_failure::<Runtime, XcmConfig>(
|
|
collator_session_keys(),
|
|
1013,
|
|
1000,
|
|
1_000_000_000,
|
|
H160::random(),
|
|
H160::random(),
|
|
DefaultBridgeHubEthereumBaseFee::get(),
|
|
FailedToTransactAsset("InsufficientBalance"),
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn max_message_queue_service_weight_is_more_than_beacon_extrinsic_weights() {
|
|
let max_message_queue_weight = MessageQueueServiceWeight::get();
|
|
let force_checkpoint =
|
|
<Runtime as snowbridge_ethereum_beacon_client::Config>::WeightInfo::force_checkpoint();
|
|
let submit_checkpoint =
|
|
<Runtime as snowbridge_ethereum_beacon_client::Config>::WeightInfo::submit();
|
|
max_message_queue_weight.all_gt(force_checkpoint);
|
|
max_message_queue_weight.all_gt(submit_checkpoint);
|
|
}
|