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

Updates pallet indices in integration tests #45

Merged
merged 3 commits into from
Nov 28, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ const TREASURY_ACCOUNT: [u8; 32] =
const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d");
const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e");

#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum ControlCall {
#[codec(index = 2)]
CreateAgent,
#[codec(index = 3)]
CreateChannel { mode: OperatingMode, outbound_fee: u128 },
}

#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum SnowbridgeControl {
#[codec(index = 83)]
Control(ControlCall),
}

#[test]
fn create_agent() {
let origin_para: u32 = 1001;
Expand All @@ -46,13 +61,15 @@ fn create_agent() {
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into();

let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});

let remote_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![63, 2].into(),
call: create_agent_call.encode().into(),
},
]));

Expand Down Expand Up @@ -89,19 +106,6 @@ fn create_agent() {
});
}

#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum CreateChannelCall {
#[codec(index = 3)]
CreateChannel { mode: OperatingMode, outbound_fee: u128 },
}

#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum SnowbridgeControl {
#[codec(index = 63)]
Control(CreateChannelCall),
}

#[test]
fn create_channel() {
let origin_para: u32 = 1001;
Expand All @@ -117,17 +121,19 @@ fn create_channel() {
let destination: VersionedMultiLocation =
Rococo::child_location_of(BridgeHubRococo::para_id()).into();

let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});

let create_agent_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![63, 2].into(),
call: create_agent_call.encode().into(),
},
]));

let create_channel_call = SnowbridgeControl::Control(CreateChannelCall::CreateChannel {
let create_channel_call = SnowbridgeControl::Control(ControlCall::CreateChannel {
mode: OperatingMode::Normal,
outbound_fee: 1,
});
Expand Down Expand Up @@ -226,33 +232,23 @@ fn register_token() {

#[test]
fn send_token_to_penpal() {
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(
MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
}
);
BridgeHubRococo::fund_accounts(vec![(
asset_hub_sovereign.clone(),
INITIAL_FUND,
)]);
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
});
BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

PenpalA::fund_accounts(vec![
(PenpalAReceiver::get(), INITIAL_FUND),
(PenpalASender::get(), INITIAL_FUND),
]);

let weth_asset_id: MultiLocation = (
Parent,
Parent,
Ethereum { chain_id: 15 },
AccountKey20 { network: None, key: WETH }
).into();
let weth_asset_id: MultiLocation =
(Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH })
.into();

// Create asset on penpal.
PenpalA::execute_with(|| {
Expand Down Expand Up @@ -282,7 +278,10 @@ fn send_token_to_penpal() {
chain_id: CHAIN_ID,
command: Command::SendToken {
token: WETH.into(),
destination: Destination::ForeignAccountId32 { para_id: 2000, id: PenpalAReceiver::get().into() },
destination: Destination::ForeignAccountId32 {
para_id: 2000,
id: PenpalAReceiver::get().into(),
},
amount: 1_000_000_000,
},
});
Expand Down Expand Up @@ -332,9 +331,7 @@ fn send_token() {
)]);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

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

Expand Down Expand Up @@ -381,20 +378,14 @@ fn send_token() {

#[test]
fn reserve_transfer_token() {
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(
MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
}
);
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
});

BridgeHubRococo::fund_accounts(vec![
(assethub_sovereign.clone(), INITIAL_FUND)
]);
BridgeHubRococo::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]);

AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

const WETH_AMOUNT: u128 = 1_000_000_000;
let message_id_: H256 = [1; 32].into();
Expand Down
Loading