Skip to content

Commit

Permalink
refactor test names
Browse files Browse the repository at this point in the history
  • Loading branch information
magecnion committed Nov 4, 2024
1 parent 6571135 commit f47c079
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions e2e-tests/tests/test-teleport-laos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ONE_LAOS = new BN("1000000000000000000");
const ONE_DOT = new BN("1000000000000");
const WAITING_BLOCKS_FOR_EVENTS = 20; // Number of blocks we wait at max to receive an event

describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
describeWithExistingNode("Teleport Asset Hub <-> Laos", (context) => {
const laosSiblingAccount = sovereignAccountOf(LAOS_PARA_ID);

// APIS
Expand All @@ -52,25 +52,25 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
alice = new Keyring({ type: "sr25519" }).addFromUri("//Alice");
alith = new Keyring({ type: "ethereum" }).addFromUri(ALITH_PRIVATE_KEY);

debugTeleport("Waiting until all the relay chain, Asset Hub and LAOS produce blocks...");
debugTeleport("Waiting until all the relay chain, Asset Hub and Laos produce blocks...");
await Promise.all([awaitBlockChange(apiRelaychain), awaitBlockChange(apiAssetHub), awaitBlockChange(apiLaos)]);

debugTeleport("[RELAY_CHAIN] Send transaction to open HRMP channels between AssetHub and LAOS..."); // See: https://github.com/paritytech/polkadot-sdk/pull/1616
debugTeleport("[RELAY_CHAIN] Send transaction to open HRMP channels between AssetHub and Laos..."); // See: https://github.com/paritytech/polkadot-sdk/pull/1616
await sendOpenHrmpChannelTxs(apiRelaychain, LAOS_PARA_ID, ASSET_HUB_PARA_ID);
});

step("HRMP channels between AssetHub and LAOS are open", async function () {
step("HRMP channels between AssetHub and Laos are open", async function () {
expect(await isChannelOpen(apiRelaychain, LAOS_PARA_ID, ASSET_HUB_PARA_ID)).to.be.true;
expect(await isChannelOpen(apiRelaychain, ASSET_HUB_PARA_ID, LAOS_PARA_ID)).to.be.true;
});

step("Create LAOS Foreign Asset in AssetHub", async function () {
step("Create $LAOS asset in AssetHub", async function () {
const laosForeignAssetExists = !(await apiAssetHub.query.foreignAssets.asset(apiAssetHub.laosAssetId)).isEmpty;

// NOTE: We only create the foreign asset if it hasn't been created yet, in this way we ensure tests are idempotent
if (!laosForeignAssetExists) {
//Fund LAOS sovereigna account
debugTeleport("[ASSET_HUB] Funding LAOS sovereign account...");
debugTeleport("[ASSET_HUB] Funding Laos sovereign account...");
await transferBalance(apiAssetHub, alice, laosSiblingAccount, ONE_DOT.muln(100));

// Build XCM instruction
Expand Down Expand Up @@ -102,7 +102,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
const alithBalanceBefore = new BN((await apiLaos.query.system.account(alith.address)).data.free);
const laosBalanceBefore = new BN((await apiAssetHub.query.system.account(laosSiblingAccount)).data.free);

// Send the XCM instruction from LAOS too Asset Hub
// Send the XCM instruction from Laos to Asset Hub
const sudoCall = apiLaos.tx.sudo.sudo(apiLaos.tx.polkadotXcm.send(destination, instruction));
try {
await sudoCall.signAndSend(alith);
Expand Down Expand Up @@ -136,14 +136,14 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {

expect(
(await apiAssetHub.query.foreignAssets.asset(apiAssetHub.laosAssetId)).isEmpty,
"LAOS foreign asset has not been created"
"$LAOS asset has not been created"
).to.be.false;
} else {
debugTeleport("LAOS foreign asset already exists, skipping creation...");
debugTeleport("$LAOS asset already exists, skipping creation...");
}
});

step("Mint LAOS foreign asset in AssetHub", async function () {
step("Mint $LAOS asset in AssetHub", async function () {
// Build XCM instructions
const ferdie = new Keyring({ type: "sr25519" }).addFromUri("//Ferdie");
const ferdieMultiaddress = apiAssetHub.createType("MultiAddress", ferdie.address) as MultiAddress;
Expand Down Expand Up @@ -198,7 +198,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
expect(ferdieXLaosBalance.gte(new BN(0)), "Ferdie balance should be > 0");
});

step("Create LAOS/RelayToken pool in AssetHub", async function () {
step("Create $LAOS/$DOT pool in AssetHub", async function () {
// NOTE: We only create the pool if it hasn't been created yet, in this way we ensure tests are idempotent
const poolExists = !(
await apiAssetHub.query.assetConversion.pools([apiAssetHub.relayAssetId, apiAssetHub.laosAssetId])
Expand Down Expand Up @@ -277,7 +277,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
);
expect(
ferdieXLaosBalance.gte(liquidityAmountLaos),
"Ferdie's LAOS balance should be greater than the amount to be sent to the pool"
"Ferdie's $LAOS balance should be greater than the amount to be sent to the pool"
);

try {
Expand All @@ -297,14 +297,14 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
}
});

step("Teleport from LAOS to AssetHub", async function () {
step("Teleport from Laos to AssetHub", async function () {
const charlie = new Keyring({ type: "sr25519" }).addFromUri("//Charlie");

const destination = apiLaos.createType("XcmVersionedLocation", {
V3: siblingLocation(ASSET_HUB_PARA_ID),
});

// We need to use AssetHub api otherwise we get an error as LAOS does not use AccountId32
// We need to use AssetHub api otherwise we get an error as Laos does not use AccountId32
let accountId = apiAssetHub.createType("AccountId", charlie.address);
const beneficiary = apiLaos.createType("XcmVersionedLocation", {
V3: {
Expand Down Expand Up @@ -356,7 +356,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
console.log("transaction failed", error);
}

// Check that LAOS has been sent in Asset Hub
// Check that $LAOS has been sent in Asset Hub
const event = await waitForEvent(
apiAssetHub,
({ event }) => apiAssetHub.events.foreignAssets.Issued.is(event),
Expand Down Expand Up @@ -384,7 +384,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
);
});

step("Teleport back from AssetHub to LAOS", async function () {
step("Teleport back from AssetHub to Laos", async function () {
const charlie = new Keyring({ type: "sr25519" }).addFromUri("//Charlie");

const destination = apiAssetHub.createType("XcmVersionedLocation", {
Expand Down Expand Up @@ -442,7 +442,7 @@ describeWithExistingNode("Teleport Asset Hub <-> LAOS", (context) => {
console.log("transaction failed", error);
}

// Check that LAOS has been sent back in LAOS
// Check that $LAOS has been sent back to Laos
const event = await waitForEvent(
apiLaos,
({ event }) => {
Expand Down

0 comments on commit f47c079

Please sign in to comment.