Skip to content

Commit

Permalink
update smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Nov 28, 2023
1 parent 88c1a16 commit efbc8d6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 44 deletions.
1 change: 0 additions & 1 deletion smoketest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ src/parachains/assethub.rs
src/parachains/bridgehub.rs
src/parachains/penpal.rs
src/parachains/relaychain.rs
src/parachains/template.rs
src/contracts
4 changes: 2 additions & 2 deletions smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ pub const BRIDGE_HUB_AGENT_ID: [u8; 32] =
// Agent for asset hub parachain 1000
pub const ASSET_HUB_AGENT_ID: [u8; 32] =
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4");
// Agent for template parachain 1001
// Agent for penpal parachain 2000
pub const SIBLING_AGENT_ID: [u8; 32] =
hex!("e01018a3378502770faff44fbef3910d120a0353d18be653625b8daa88a86453");
hex!("5097ee1101e90c3aadb882858c59a22108668021ec81bce9f4930155e5c21e59");

pub const ASSET_HUB_SOVEREIGN: [u8; 32] =
hex!("7369626ce8030000000000000000000000000000000000000000000000000000");
Expand Down
43 changes: 12 additions & 31 deletions smoketest/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use crate::{
VersionedXcm as RelaychainVersionedXcm,
},
},
template::{
api::runtime_types as templateTypes,
penpal::{
api::runtime_types as penpalTypes,
{self},
},
},
Expand All @@ -53,28 +53,16 @@ use subxt::{
tx::{PairSigner, TxPayload},
Config, OnlineClient, PolkadotConfig, SubstrateConfig,
};
use templateTypes::{
use penpalTypes::{
staging_xcm::v3::multilocation::MultiLocation,
xcm::{
v3::{junction::Junction, junctions::Junctions},
VersionedMultiLocation, VersionedXcm,
},
pallet_xcm::pallet::Call,
penpal_runtime::RuntimeCall
};

/// Custom config that works with TemplateParachain
pub enum TemplateConfig {}

impl Config for TemplateConfig {
type Index = <PolkadotConfig as Config>::Index;
type Hash = <PolkadotConfig as Config>::Hash;
type AccountId = <PolkadotConfig as Config>::AccountId;
type Address = <PolkadotConfig as Config>::Address;
type Signature = <PolkadotConfig as Config>::Signature;
type Hasher = <PolkadotConfig as Config>::Hasher;
type Header = <PolkadotConfig as Config>::Header;
type ExtrinsicParams = <PolkadotConfig as Config>::ExtrinsicParams;
}

/// Custom config that works with Penpal
pub enum PenpalConfig {}

Expand Down Expand Up @@ -106,7 +94,6 @@ impl Config for AssetHubConfig {
pub struct TestClients {
pub asset_hub_client: Box<OnlineClient<PolkadotConfig>>,
pub bridge_hub_client: Box<OnlineClient<PolkadotConfig>>,
pub template_client: Box<OnlineClient<TemplateConfig>>,
pub penpal_client: Box<OnlineClient<PenpalConfig>>,
pub relaychain_client: Box<OnlineClient<PolkadotConfig>>,
pub ethereum_client: Box<Arc<Provider<Ws>>>,
Expand All @@ -122,11 +109,6 @@ pub async fn initial_clients() -> Result<TestClients, Box<dyn std::error::Error>
.await
.expect("can not connect to bridgehub");

let template_client: OnlineClient<TemplateConfig> =
OnlineClient::from_url(TEMPLATE_NODE_WS_URL)
.await
.expect("can not connect to template parachain");

let penpal_client: OnlineClient<PenpalConfig> = OnlineClient::from_url(PENPAL_WS_URL)
.await
.expect("can not connect to penpal parachain");
Expand All @@ -148,7 +130,6 @@ pub async fn initial_clients() -> Result<TestClients, Box<dyn std::error::Error>
Ok(TestClients {
asset_hub_client: Box::new(asset_hub_client),
bridge_hub_client: Box::new(bridge_hub_client),
template_client: Box::new(template_client),
penpal_client: Box::new(penpal_client),
relaychain_client: Box::new(relaychain_client),
ethereum_client: Box::new(ethereum_client),
Expand Down Expand Up @@ -207,24 +188,24 @@ pub async fn wait_for_ethereum_event<Ev: EthEvent>(ethereum_client: &Box<Arc<Pro
assert!(ethereum_event_found);
}

pub async fn send_xcm_transact(
template_client: &Box<OnlineClient<TemplateConfig>>,
pub async fn send_sudo_xcm_transact(
penpal_client: &Box<OnlineClient<PenpalConfig>>,
message: Box<VersionedXcm>,
) -> Result<ExtrinsicEvents<TemplateConfig>, Box<dyn std::error::Error>> {
) -> Result<ExtrinsicEvents<PenpalConfig>, Box<dyn std::error::Error>> {
let dest = Box::new(VersionedMultiLocation::V3(MultiLocation {
parents: 1,
interior: Junctions::X1(Junction::Parachain(BRIDGE_HUB_PARA_ID)),
}));

let xcm_call = template::api::template_pallet::calls::TransactionApi.send_xcm(*dest, *message);
let sudo_call = penpal::api::sudo::calls::TransactionApi::sudo(&penpal::api::sudo::calls::TransactionApi,RuntimeCall::PolkadotXcm(Call::send { dest, message }));

let owner: Pair = Pair::from_string("//Alice", None).expect("cannot create keypair");

let signer: PairSigner<TemplateConfig, _> = PairSigner::new(owner);
let signer: PairSigner<PenpalConfig, _> = PairSigner::new(owner);

let result = template_client
let result = penpal_client
.tx()
.sign_and_submit_then_watch_default(&xcm_call, &signer)
.sign_and_submit_then_watch_default(&sudo_call, &signer)
.await
.expect("send through xcm call.")
.wait_for_finalized_success()
Expand Down
1 change: 0 additions & 1 deletion smoketest/src/parachains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ pub mod assethub;
pub mod bridgehub;
pub mod penpal;
pub mod relaychain;
pub mod template;
10 changes: 5 additions & 5 deletions smoketest/src/xcm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::parachains::template::api::{
runtime_types as templateTypes, runtime_types::staging_xcm as templateXcm,
use crate::parachains::penpal::api::{
runtime_types as penpalTypes, runtime_types::staging_xcm as penpalXcm,
};
use templateTypes::sp_weights::weight_v2::Weight;
use templateXcm::v3::multilocation::MultiLocation;
use penpalTypes::sp_weights::weight_v2::Weight;
use penpalXcm::v3::multilocation::MultiLocation;

use templateTypes::xcm::{
use penpalTypes::xcm::{
double_encoded::DoubleEncoded,
v2::OriginKind,
v3::{
Expand Down
2 changes: 1 addition & 1 deletion smoketest/tests/create_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn create_agent() {

let message = construct_xcm_message_with_fee(encoded_call).await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down
4 changes: 2 additions & 2 deletions smoketest/tests/create_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ async fn create_channel() {

let encoded_call = construct_create_channel_call(&test_clients.bridge_hub_client)
.await
.expect("construct innner call.");
.expect("construct inner call.");

let message = construct_xcm_message_with_fee(encoded_call).await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down
2 changes: 1 addition & 1 deletion smoketest/tests/transfer_native_from_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn transfer_native_from_agent() {
)
.await;

let result = send_xcm_transact(&test_clients.template_client, message)
let result = send_sudo_xcm_transact(&test_clients.penpal_client, message)
.await
.expect("failed to send xcm transact.");

Expand Down

0 comments on commit efbc8d6

Please sign in to comment.