git.delta.rocks / unique-network / refs/commits / 9812643539bc

difftreelog

Add Unique-Astar integration tests

Max Andreev2023-03-28parent: #f628606.patch.diff
in: master

5 files changed

modifiedtests/src/config.tsdiffbeforeafterboth
--- a/tests/src/config.ts
+++ b/tests/src/config.ts
@@ -24,6 +24,8 @@
   karuraUrl: process.env.acalaUrl || 'ws://127.0.0.1:9946',
   moonbeamUrl: process.env.moonbeamUrl || 'ws://127.0.0.1:9947',
   moonriverUrl: process.env.moonbeamUrl || 'ws://127.0.0.1:9947',
+  astarUrl: process.env.astarUrl || 'ws://127.0.0.1:9949',
+  shidenUrl: process.env.shidenUrl || 'ws://127.0.0.1:9949',
   westmintUrl: process.env.westmintUrl || 'ws://127.0.0.1:9948',
   statemineUrl: process.env.statemineUrl || 'ws://127.0.0.1:9948',
   statemintUrl: process.env.statemintUrl || 'ws://127.0.0.1:9948',
modifiedtests/src/util/index.tsdiffbeforeafterboth
before · tests/src/util/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import * as crypto from 'crypto';6import {IKeyringPair} from '@polkadot/types/types/interfaces';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import chaiSubset from 'chai-subset';10import {Context} from 'mocha';11import config from '../config';12import {ChainHelperBase} from './playgrounds/unique';13import {ILogger} from './playgrounds/types';14import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper, DevStatemineHelper, DevStatemintHelper} from './playgrounds/unique.dev';15import {dirname} from 'path';16import {fileURLToPath} from 'url';1718chai.use(chaiAsPromised);19chai.use(chaiSubset);20export const expect = chai.expect;2122const getTestHash = (filename: string) => {23  return crypto.createHash('md5').update(filename).digest('hex');24};2526export const getTestSeed = (filename: string) => {27  return `//Alice+${getTestHash(filename)}`;28};2930async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {31  const silentConsole = new SilentConsole();32  silentConsole.enable();3334  const helper = new helperType(new SilentLogger());3536  try {37    await helper.connect(url);38    const ss58Format = helper.chain.getChainProperties().ss58Format;39    const privateKey = async (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => {40      if (typeof seed === 'string') {41        return helper.util.fromSeed(seed, ss58Format);42      }43      if (seed.url) {44        const {filename} = makeNames(seed.url);45        seed.filename = filename;46      } else if (seed.filename) {47        // Pass48      } else {49        throw new Error('no url nor filename set');50      }51      const actualSeed = getTestSeed(seed.filename);52      let account = helper.util.fromSeed(actualSeed, ss58Format);53      // here's to hoping that no54      if (!seed.ignoreFundsPresence && ((helper as any)['balance'] == undefined || await (helper as any).balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND)) {55        console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);56        account = helper.util.fromSeed('//Alice', ss58Format);57      }58      return account;59    };60    await code(helper, privateKey);61  }62  finally {63    await helper.disconnect();64    silentConsole.disable();65  }66}6768export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {69  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);70};7172export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {73  return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);74};7576export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {77  return usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);78};7980export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {81  return usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);82};8384export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {85  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);86};8788export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {89  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);90};9192export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {93  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);94};9596export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {97  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);98};99100export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {101  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);102};103104export const MINIMUM_DONOR_FUND = 100_000n;105export const DONOR_FUNDING = 2_000_000n;106107// App-promotion periods:108export const LOCKING_PERIOD = 12n; // 12 blocks of relay109export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain110111// Native contracts112export const COLLECTION_HELPER = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';113export const CONTRACT_HELPER = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';114115export enum Pallets {116  Inflation = 'inflation',117  ReFungible = 'refungible',118  Fungible = 'fungible',119  NFT = 'nonfungible',120  Scheduler = 'scheduler',121  AppPromotion = 'apppromotion',122  CollatorSelection = 'collatorselection',123  Session = 'session',124  Identity = 'identity',125  Preimage = 'preimage',126  Maintenance = 'maintenance',127  TestUtils = 'testutils',128}129130export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {131  const missingPallets = helper.fetchMissingPalletNames(requiredPallets);132133  if (missingPallets.length > 0) {134    const skipMsg = `\tSkipping test '${test.test?.title}'.\n\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;135    console.warn('\x1b[38:5:208m%s\x1b[0m', skipMsg);136    test.skip();137  }138}139140export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {141  (opts.only ? it.only :142    opts.skip ? it.skip : it)(name, async function () {143    await usingPlaygrounds(async (helper, privateKey) => {144      if (opts.requiredPallets) {145        requirePalletsOrSkip(this, helper, opts.requiredPallets);146      }147148      await cb({helper, privateKey});149    });150  });151}152export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {153  return itSub(name, cb, {requiredPallets: required, ...opts});154}155itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});156itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {skip: true});157158itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {only: true});159itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});160itSub.ifWithPallets = itSubIfWithPallet;161162export type SchedKind = 'anon' | 'named';163164export function itSched(165  name: string,166  cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,167  opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},168) {169  itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);170  itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);171}172itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});173itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});174itSched.ifWithPallets = itSchedIfWithPallets;175176function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {177  return itSched(name, cb, {requiredPallets: required, ...opts});178}179180export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {181  (process.env.RUN_XCM_TESTS && !opts.skip182    ? describe183    : describe.skip)(title, fn);184}185186describeXCM.skip = (name: string, fn: (this: Mocha.Suite) => void) => describeXCM(name, fn, {skip: true});187188export function sizeOfInt(i: number) {189  if (i < 0 || i > 0xffffffff) throw new Error('out of range');190  if(i < 0b11_1111) {191    return 1;192  } else if (i < 0b11_1111_1111_1111) {193    return 2;194  } else if (i < 0b11_1111_1111_1111_1111_1111_1111_1111) {195    return 4;196  } else {197    return 5;198  }199}200201const UTF8_ENCODER = new TextEncoder();202export function sizeOfEncodedStr(v: string) {203  const encoded = UTF8_ENCODER.encode(v);204  return sizeOfInt(encoded.length) + encoded.length;205}206207export function sizeOfProperty(prop: {key: string, value: string}) {208  return sizeOfEncodedStr(prop.key) + sizeOfEncodedStr(prop.value);209}210211export function makeNames(url: string) {212  const filename = fileURLToPath(url);213  return {214    filename,215    dirname: dirname(filename),216  };217}
after · tests/src/util/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import * as crypto from 'crypto';6import {IKeyringPair} from '@polkadot/types/types/interfaces';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import chaiSubset from 'chai-subset';10import {Context} from 'mocha';11import config from '../config';12import {ChainHelperBase} from './playgrounds/unique';13import {ILogger} from './playgrounds/types';14import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper, DevStatemineHelper, DevStatemintHelper, DevAstarHelper} from './playgrounds/unique.dev';15import {dirname} from 'path';16import {fileURLToPath} from 'url';1718chai.use(chaiAsPromised);19chai.use(chaiSubset);20export const expect = chai.expect;2122const getTestHash = (filename: string) => {23  return crypto.createHash('md5').update(filename).digest('hex');24};2526export const getTestSeed = (filename: string) => {27  return `//Alice+${getTestHash(filename)}`;28};2930async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {31  const silentConsole = new SilentConsole();32  silentConsole.enable();3334  const helper = new helperType(new SilentLogger());3536  try {37    await helper.connect(url);38    const ss58Format = helper.chain.getChainProperties().ss58Format;39    const privateKey = async (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => {40      if (typeof seed === 'string') {41        return helper.util.fromSeed(seed, ss58Format);42      }43      if (seed.url) {44        const {filename} = makeNames(seed.url);45        seed.filename = filename;46      } else if (seed.filename) {47        // Pass48      } else {49        throw new Error('no url nor filename set');50      }51      const actualSeed = getTestSeed(seed.filename);52      let account = helper.util.fromSeed(actualSeed, ss58Format);53      // here's to hoping that no54      if (!seed.ignoreFundsPresence && ((helper as any)['balance'] == undefined || await (helper as any).balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND)) {55        console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);56        account = helper.util.fromSeed('//Alice', ss58Format);57      }58      return account;59    };60    await code(helper, privateKey);61  }62  finally {63    await helper.disconnect();64    silentConsole.disable();65  }66}6768export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {69  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);70};7172export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {73  return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);74};7576export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {77  return usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);78};7980export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {81  return usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);82};8384export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {85  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);86};8788export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {89  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);90};9192export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {93  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);94};9596export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {97  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);98};99100export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {101  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);102};103104export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {105  return usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);106};107108109export const MINIMUM_DONOR_FUND = 100_000n;110export const DONOR_FUNDING = 2_000_000n;111112// App-promotion periods:113export const LOCKING_PERIOD = 12n; // 12 blocks of relay114export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain115116// Native contracts117export const COLLECTION_HELPER = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';118export const CONTRACT_HELPER = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';119120export enum Pallets {121  Inflation = 'inflation',122  ReFungible = 'refungible',123  Fungible = 'fungible',124  NFT = 'nonfungible',125  Scheduler = 'scheduler',126  AppPromotion = 'apppromotion',127  CollatorSelection = 'collatorselection',128  Session = 'session',129  Identity = 'identity',130  Preimage = 'preimage',131  Maintenance = 'maintenance',132  TestUtils = 'testutils',133}134135export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {136  const missingPallets = helper.fetchMissingPalletNames(requiredPallets);137138  if (missingPallets.length > 0) {139    const skipMsg = `\tSkipping test '${test.test?.title}'.\n\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;140    console.warn('\x1b[38:5:208m%s\x1b[0m', skipMsg);141    test.skip();142  }143}144145export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {146  (opts.only ? it.only :147    opts.skip ? it.skip : it)(name, async function () {148    await usingPlaygrounds(async (helper, privateKey) => {149      if (opts.requiredPallets) {150        requirePalletsOrSkip(this, helper, opts.requiredPallets);151      }152153      await cb({helper, privateKey});154    });155  });156}157export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {158  return itSub(name, cb, {requiredPallets: required, ...opts});159}160itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});161itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {skip: true});162163itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {only: true});164itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});165itSub.ifWithPallets = itSubIfWithPallet;166167export type SchedKind = 'anon' | 'named';168169export function itSched(170  name: string,171  cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,172  opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},173) {174  itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);175  itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);176}177itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});178itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});179itSched.ifWithPallets = itSchedIfWithPallets;180181function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {182  return itSched(name, cb, {requiredPallets: required, ...opts});183}184185export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {186  (process.env.RUN_XCM_TESTS && !opts.skip187    ? describe188    : describe.skip)(title, fn);189}190191describeXCM.skip = (name: string, fn: (this: Mocha.Suite) => void) => describeXCM(name, fn, {skip: true});192193export function sizeOfInt(i: number) {194  if (i < 0 || i > 0xffffffff) throw new Error('out of range');195  if(i < 0b11_1111) {196    return 1;197  } else if (i < 0b11_1111_1111_1111) {198    return 2;199  } else if (i < 0b11_1111_1111_1111_1111_1111_1111_1111) {200    return 4;201  } else {202    return 5;203  }204}205206const UTF8_ENCODER = new TextEncoder();207export function sizeOfEncodedStr(v: string) {208  const encoded = UTF8_ENCODER.encode(v);209  return sizeOfInt(encoded.length) + encoded.length;210}211212export function sizeOfProperty(prop: {key: string, value: string}) {213  return sizeOfEncodedStr(prop.key) + sizeOfEncodedStr(prop.value);214}215216export function makeNames(url: string) {217  const filename = fileURLToPath(url);218  return {219    filename,220    dirname: dirname(filename),221  };222}
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -3,7 +3,7 @@
 
 import {stringToU8a} from '@polkadot/util';
 import {encodeAddress, mnemonicGenerate} from '@polkadot/util-crypto';
-import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper} from './unique';
+import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper, AstarHelper} from './unique';
 import {ApiPromise, Keyring, WsProvider} from '@polkadot/api';
 import * as defs from '../../interfaces/definitions';
 import {IKeyringPair} from '@polkadot/types/types';
@@ -173,6 +173,17 @@
   }
 }
 
+export class DevAstarHelper extends AstarHelper {
+  wait: WaitGroup;
+
+  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
+    options.helperBase = options.helperBase ?? DevAstarHelper;
+
+    super(logger, options);
+    this.wait = new WaitGroup(this);
+  }
+}
+
 export class DevAcalaHelper extends AcalaHelper {
   wait: WaitGroup;
 
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -3243,6 +3243,26 @@
   }
 }
 
+export class AstarHelper extends XcmChainHelper {
+  balance: SubstrateBalanceGroup<AstarHelper>;
+  assets: AssetsGroup<AstarHelper>;
+  xcm: XcmGroup<AstarHelper>;
+
+  constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
+    super(logger, options.helperBase ?? AstarHelper);
+
+    this.balance = new SubstrateBalanceGroup(this);
+    this.assets = new AssetsGroup(this);
+    this.xcm = new XcmGroup(this, 'polkadotXcm');
+  }
+
+  getSudo<T extends UniqueHelper>() {
+    // eslint-disable-next-line @typescript-eslint/naming-convention
+    const SudoHelperType = SudoHelper(this.helperBase);
+    return this.clone(SudoHelperType) as T;
+  }
+}
+
 export class AcalaHelper extends XcmChainHelper {
   balance: SubstrateBalanceGroup<AcalaHelper>;
   assetRegistry: AcalaAssetRegistryGroup;
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -18,12 +18,13 @@
 import {blake2AsHex} from '@polkadot/util-crypto';
 import config from '../config';
 import {XcmV2TraitsError} from '../interfaces';
-import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds} from '../util';
+import {itSub, expect, describeXCM, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds, usingStatemintPlaygrounds, usingAstarPlaygrounds} from '../util';
 
 const UNIQUE_CHAIN = 2037;
 const STATEMINT_CHAIN = 1000;
 const ACALA_CHAIN = 2000;
 const MOONBEAM_CHAIN = 2004;
+const ASTAR_CHAIN = 2006;
 
 const STATEMINT_PALLET_INSTANCE = 50;
 
@@ -31,6 +32,7 @@
 const statemintUrl = config.statemintUrl;
 const acalaUrl = config.acalaUrl;
 const moonbeamUrl = config.moonbeamUrl;
+const astarUrl = config.astarUrl;
 
 const RELAY_DECIMALS = 12;
 const STATEMINT_DECIMALS = 12;
@@ -980,3 +982,189 @@
     expect(unqFees == 0n).to.be.true;
   });
 });
+
+describeXCM('[XCM] Integration test: Exchanging tokens with Astar', () => {
+  let alice: IKeyringPair;
+  let randomAccount: IKeyringPair;
+
+  const astarInitialBalance = 1n * (10n ** 18n);
+  const unqToAstarAmount = 10n * (10n ** 18n);
+
+  before(async () => {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      alice = await privateKey('//Alice');
+      [randomAccount] = await helper.arrange.createAccounts([100n], alice);
+      console.log('randomAccount', randomAccount.address);
+    });
+
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      console.log('1. Create foreign asset and metadata');
+      await helper.assets.create(
+        alice,
+        1,
+        alice.address,
+        1n, // TODO set correct minimal balance
+      );
+
+      await helper.assets.setMetadata(
+        alice,
+        1,
+        'Cross chain UNQ',
+        'xcUNQ',
+        18,
+      );
+
+      console.log('2. Register asset location');
+      const assetLocation = {
+        V1: {
+          parents: 1,
+          interior: {
+            X1: {
+              Parachain: UNIQUE_CHAIN,
+            },
+          },
+        },
+      };
+
+      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.registerAssetLocation', [assetLocation, 1]);
+
+      console.log('3. Set payment for computation');
+      // TODO this is Phala's price, what price will be for Unique?
+      const unitsPerSecond = 228_000_000_000n;
+      await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
+
+      console.log('4. Transfer 1 ASTAR for recepient');
+      await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
+    });
+  });
+
+  itSub.only('Should connect and send UNQ to Astar', async ({helper}) => {
+    const destination = {
+      V1: {
+        parents: 1,
+        interior: {
+          X1: {
+            Parachain: ASTAR_CHAIN,
+          },
+        },
+      },
+    };
+
+    const beneficiary = {
+      V1: {
+        parents: 0,
+        interior: {
+          X1: {
+            AccountId32: {
+              network: 'Any',
+              id: randomAccount.addressRaw,
+            },
+          },
+        },
+      },
+    };
+
+    const assets = {
+      V1: [
+        {
+          id: {
+            Concrete: {
+              parents: 0,
+              interior: 'Here',
+            },
+          },
+          fun: {
+            Fungible: unqToAstarAmount,
+          },
+        },
+      ],
+    };
+
+    // Initial balance is 100 UNQ
+    expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(100n * (10n ** 18n));
+
+    const feeAssetItem = 0;
+    await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');
+
+    // Balance after reserve transfer is less than 90
+    expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(89_941967662676666465n);
+
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      await helper.wait.newBlocks(3);
+      const xcUNQbalance = await helper.assets.account(1, randomAccount.address);
+      const astarBalance = await helper.balance.getSubstrate(randomAccount.address);
+
+      expect(xcUNQbalance).to.eq(9_999_999_999_088_000_000n);
+      // Astar balance does not changed
+      expect(astarBalance).to.eq(1_000_000_000_000_000_000n);
+    });
+  });
+
+  itSub.only('Should connect to Astar and send UNQ back', async ({helper}) => {
+    await usingAstarPlaygrounds(astarUrl, async (helper) => {
+      const destination = {
+        V1: {
+          parents: 1,
+          interior: {
+            X1: {
+              Parachain: UNIQUE_CHAIN,
+            },
+          },
+        },
+      };
+
+      const beneficiary = {
+        V1: {
+          parents: 0,
+          interior: {
+            X1: {
+              AccountId32: {
+                network: 'Any',
+                id: randomAccount.addressRaw,
+              },
+            },
+          },
+        },
+      };
+
+      const assets = {
+        V1: [
+          {
+            id: {
+              Concrete: {
+                parents: 1,
+                interior: {
+                  X1: {
+                    Parachain: UNIQUE_CHAIN,
+                  },
+                },
+              },
+            },
+            fun: {
+              Fungible: 5_000_000_000_000_000_000n, // TODO set another value
+            },
+          },
+        ],
+      };
+
+      // Initial balance is 1 ASTAR
+      expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(1_000_000_000_000_000_000n);
+
+      const feeAssetItem = 0;
+      await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');
+
+      // Balance after reserve transfer is less than 1 ASTAR
+      const xcUNQbalance = await helper.assets.account(1, randomAccount.address);
+      const balanceAstar = await helper.balance.getSubstrate(randomAccount.address);
+
+      // xcUNQ balance decreased
+      expect(xcUNQbalance).to.eq(4_999_999_999_088_000_000n);
+      // Astar balance is 0.997...
+      expect(balanceAstar / (10n ** 15n)).to.eq(997n);
+    });
+
+    await helper.wait.newBlocks(3);
+    const balanceUNQ = await helper.balance.getSubstrate(randomAccount.address);
+    expect(balanceUNQ).to.eq(89_941967662676666465n + 5_000_000_000_000_000_000n);
+  });
+});