Skip to content

Commit

Permalink
update test spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Dec 12, 2024
1 parent 3ece583 commit 5ca1d1c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 142 deletions.
3 changes: 1 addition & 2 deletions integration-tests/xcm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
],
"scripts": {
"test:call": "jest call.spec.ts",
"test:e2e": "jest --forceExit e2e.spec.ts",
"test:exec": "jest --forceExit exec.spec.ts"
"test:e2e": "jest --forceExit e2e.spec.ts"
},
"devDependencies": {
"@acala-network/chopsticks-testing": "1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/xcm-test/src/__db__/metadata.db.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
}
},
"hydration-moonbeam-glmr": {
"updated": 1733843723282,
"updated": 1734017990497,
"destination": {
"fee": "0.0095040525",
"feeAsset": "GLMR",
Expand Down
8 changes: 7 additions & 1 deletion integration-tests/xcm-test/src/call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import console from 'console';

import { setup, xcm } from './ctx/call';

import { getRouteInfo } from './utils/route';
import { getRouteInfo, getRouteKey } from './utils/route';

const jestConsole = console;

Expand Down Expand Up @@ -78,12 +78,15 @@ describe('Wallet with XCM config', () => {
}

const info = getRouteInfo(chain, route);
const key = getRouteKey(chain, route);

runXcm(
`${info} transfer`,
async () => {
return {
chain: chain,
route: route,
key: key,
};
},
async () => {
Expand Down Expand Up @@ -111,12 +114,15 @@ describe('Wallet with XCM config', () => {
}

const info = getRouteInfo(chain, route);
const key = getRouteKey(chain, route);

runXcm(
`${info} transfer`,
async () => {
return {
chain: chain,
route: route,
key: key,
};
},
async () => {
Expand Down
7 changes: 2 additions & 5 deletions integration-tests/xcm-test/src/ctx/call/xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
import { getAddress } from './account';
import { getAmount } from './amount';

import { getRouteKey } from '../../utils/route';

const BALANCE = 10;
const FEE = 0.1;
const TRANSFER_AMOUNT = '1';
Expand All @@ -22,6 +20,7 @@ export const runXcm = (
cfg: () => Promise<{
chain: AnyChain;
route: AssetRoute;
key: string;
}>,
ctx: () => Promise<{
wallet: Wallet;
Expand All @@ -32,11 +31,9 @@ export const runXcm = (
itfn(
name,
async () => {
const { chain, route } = await cfg();
const { chain, route, key } = await cfg();
const { wallet } = await ctx();

const key = getRouteKey(chain, route);

try {
const transfer = await getTransfer(wallet, chain, route);
const { data } = await transfer.buildCall(TRANSFER_AMOUNT);
Expand Down
7 changes: 2 additions & 5 deletions integration-tests/xcm-test/src/ctx/e2e/xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ import {
} from './xcm.utils';
import { SetupCtx } from './types';

import { getRouteKey } from '../../utils/route';

const TRANSFER_AMOUNT = '10';

export const runXcm = (
name: string,
cfg: () => Promise<{
chain: AnyChain;
route: AssetRoute;
key: string;
}>,
ctx: () => Promise<{
report: Map<any, any>;
Expand All @@ -48,16 +47,14 @@ export const runXcm = (
itfn(
name,
async () => {
const { chain, route } = await cfg();
const { chain, route, key } = await cfg();
const { report, networks, wallet } = await ctx();

const srcChain = chain as Parachain;
const srcNetwork = networks.find((n) => n.config.key === srcChain.key)!;
const destChain = route.destination.chain as Parachain;
const destNetwork = networks.find((n) => n.config.key === destChain.key)!;

const key = getRouteKey(chain, route);

console.log('\n🥢 Executing ' + name + ' ...');
console.log('🥢 Route key: ' + key);

Expand Down
41 changes: 37 additions & 4 deletions integration-tests/xcm-test/src/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
import { Wallet } from '@galacticcouncil/xcm-sdk';

import console from 'console';
import outdent from 'outdent';

import { setup, network, xcm, SetupCtx } from './ctx/e2e';

import { getRouteInfo } from './utils/route';
import { parseArgs } from './utils/cmd';
import { getRouteInfo, getRouteKey } from './utils/route';
import { write, loadExisting } from './utils/file';

const jestConsole = console;
Expand All @@ -19,6 +21,19 @@ const { configService, initWithCtx } = setup;
const { createNetworks } = network;
const { runXcm } = xcm;

const usage = outdent`
Usage:
npm run test:e2e
Options:
-key Execute transfer for given key
-chain Execute transfers from given chain
Examples:
npm run test:e2e -- -key hydration-moonbeam-glmr
npm run test:e2e -- -chain hydration
`;

/**
* Supported polkadot consensus ctx.
*
Expand All @@ -45,6 +60,13 @@ const getPolkadotChains = () => {

describe('Wallet with XCM config', () => {
jest.setTimeout(3 * 60 * 1000); // Execution time <= 3 min
console.log(usage + '\n');

const args = process.argv.slice(2);
const params = parseArgs(args);

const keyParam = params['key'];
const chainParam = params['chain'];

let wallet: Wallet;
let networks: SetupCtx[] = [];
Expand Down Expand Up @@ -79,21 +101,28 @@ describe('Wallet with XCM config', () => {
for (const route of Array.from(routes.values())) {
const { skipFor } = polkadot;
const { source, destination } = route;
const { asset } = source;

if (skipFor.includes(destination.chain.key)) {
continue;
}

const info = getRouteInfo(chain, route);
const key = getRouteKey(chain, route);

const isKeyConstraint = keyParam ? keyParam !== key : false;
const isChainConstraint = chainParam ? chainParam !== chain.key : false;

const isContractTransfer = !!route.contract;
const isAcalaErc20Transfer = source.asset.key.endsWith('_awh');
const isAcalaErc20Transfer = asset.key.endsWith('_awh');

const info = getRouteInfo(chain, route);
runXcm(
`${info} transfer`,
async () => {
return {
chain: chain,
route: route,
key: key,
};
},
async () => {
Expand All @@ -104,7 +133,11 @@ describe('Wallet with XCM config', () => {
};
},
{
skip: isContractTransfer || isAcalaErc20Transfer,
skip:
isKeyConstraint ||
isChainConstraint ||
isContractTransfer ||
isAcalaErc20Transfer,
sync: true,
snapshot: true,
}
Expand Down
124 changes: 0 additions & 124 deletions integration-tests/xcm-test/src/exec.spec.ts

This file was deleted.

0 comments on commit 5ca1d1c

Please sign in to comment.