Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Emulated tests PR feedback #83

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ cumulus-pallet-dmp-queue = { path = "../../../../../../pallets/dmp-queue", defau
bridge-hub-rococo-runtime = { path = "../../../../../../parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false }
emulated-integration-tests-common = { path = "../../../common", default-features = false }
rococo-westend-system-emulated-network = { path = "../../../networks/rococo-westend-system" }
bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo" }
asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo" }
penpal-emulated-chain = { path = "../../../chains/parachains/testing/penpal" }
penpal-runtime = { path = "../../../../../runtimes/testing/penpal", default-features = false }
rococo-system-emulated-network = { path = "../../../networks/rococo-system" }
asset-hub-rococo-runtime = { path = "../../../../../runtimes/assets/asset-hub-rococo", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use asset_hub_rococo_emulated_chain::AssetHubRococoParaPallet as AssetHubRococoPallet;
use bridge_hub_rococo_emulated_chain::BridgeHubRococoParaPallet as BridgeHubRococoPallet;
use codec::{Decode, Encode};
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
use frame_support::pallet_prelude::TypeInfo;
use hex_literal::hex;
use snowbridge_core::outbound::OperatingMode;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use snowbridge_router_primitives::inbound::{
Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage,
};
use snowbridge_system;
use sp_core::H256;

Expand Down Expand Up @@ -51,13 +52,7 @@ pub enum SnowbridgeControl {
fn create_agent() {
let origin_para: u32 = 1001;

BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(origin_para)),
}),
INITIAL_FUND,
)]);
BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND);

let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into();
Expand Down Expand Up @@ -111,12 +106,7 @@ fn create_agent() {
fn create_channel() {
let origin_para: u32 = 1001;

let source_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para)) };

BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(source_location),
INITIAL_FUND,
)]);
BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND);

let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
let destination: VersionedMultiLocation =
Expand Down Expand Up @@ -187,14 +177,8 @@ fn create_channel() {
}

#[test]
fn register_token() {
BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(AssetHubRococo::para_id().into())),
}),
INITIAL_FUND,
)]);
fn register_weth_token_from_ethereum_to_asset_hub() {
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id().into(), INITIAL_FUND);

let message_id_: H256 = [1; 32].into();

Expand Down Expand Up @@ -230,7 +214,7 @@ fn register_token() {
}

#[test]
fn send_token_to_penpal() {
fn send_token_from_ethereum_to_penpal() {
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(AssetHubRococo::para_id().into())),
Expand All @@ -246,13 +230,14 @@ fn send_token_to_penpal() {
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
let weth_asset_id = weth_asset_location.into();

let origin_location =
MultiLocation { parents: 2, interior: weth_asset_location.interior.split_last().0 };
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();

// Fund ethereum sovereign in asset hub
let ethereum_sovereign: AccountId =
hex!("ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d").into();
GlobalConsensusEthereumConvertsFor::<AccountId>::convert_location(&origin_location)
.unwrap();
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on assethub.
AssetHubRococo::execute_with(|| {
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::ForeignAssets::create(
Expand Down Expand Up @@ -334,14 +319,8 @@ fn send_token_to_penpal() {
}

#[test]
fn send_token() {
BridgeHubRococo::fund_accounts(vec![(
BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(AssetHubRococo::para_id().into())),
}),
INITIAL_FUND,
)]);
fn send_token_from_ethereum_to_asset_hub() {
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id().into(), INITIAL_FUND);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);
Expand Down Expand Up @@ -391,7 +370,7 @@ fn send_token() {
}

#[test]
fn reserve_transfer_token() {
fn send_weth_asset_from_asset_hub_to_ethereum() {
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
Expand Down Expand Up @@ -520,7 +499,7 @@ fn reserve_transfer_token() {
RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount })
if *who == assethub_sovereign && *amount == 2680000000000,
)),
"Assethub sovereign takes remote fee."
"AssetHub sovereign takes remote fee."
);
});
}
Loading