difftreelog
refactor draft move xcm tests to playgrounds
in: master
3 files changed
tests/src/xcm/xcmOpal.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmOpal.test.ts
+++ b/tests/src/xcm/xcmOpal.test.ts
@@ -14,33 +14,27 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-
-import {WsProvider} from '@polkadot/api';
-import {ApiOptions} from '@polkadot/api/types';
import {IKeyringPair} from '@polkadot/types/types';
-import usingApi, {executeTransaction} from './../substrate/substrate-api';
-import {bigIntToDecimals, describe_xcm, getGenericResult, paraSiblingSovereignAccount, normalizeAccountId} from './../deprecated-helpers/helpers';
-import waitNewBlocks from './../substrate/wait-new-blocks';
+import {executeTransaction} from './../substrate/substrate-api';
+import {bigIntToDecimals, getGenericResult, paraSiblingSovereignAccount} from './../deprecated-helpers/helpers';
import getBalance from './../substrate/get-balance';
-
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, expect, describeXcm, usingPlaygrounds} from '../util/playgrounds';
const STATEMINE_CHAIN = 1000;
const UNIQUE_CHAIN = 2095;
const RELAY_PORT = '9844';
-const UNIQUE_PORT = '9944';
const STATEMINE_PORT = '9948';
+
+const relayUrl = 'ws://127.0.0.1:' + RELAY_PORT;
+const statemineUrl = 'ws://127.0.0.1:' + STATEMINE_PORT;
+
const STATEMINE_PALLET_INSTANCE = 50;
const ASSET_ID = 100;
const ASSET_METADATA_DECIMALS = 18;
const ASSET_METADATA_NAME = 'USDT';
const ASSET_METADATA_DESCRIPTION = 'USDT';
-const ASSET_METADATA_MINIMAL_BALANCE = 1;
+const ASSET_METADATA_MINIMAL_BALANCE = 1n;
const WESTMINT_DECIMALS = 12;
@@ -49,7 +43,7 @@
// 10,000.00 (ten thousands) USDT
const ASSET_AMOUNT = 1_000_000_000_000_000_000_000n;
-describe_xcm('[XCM] Integration test: Exchanging USDT with Westmint', () => {
+describeXcm('[XCM] Integration test: Exchanging USDT with Westmint', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
@@ -69,24 +63,13 @@
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
- alice = privateKeyWrapper('//Alice');
- bob = privateKeyWrapper('//Bob'); // funds donor
+ await usingPlaygrounds(async (_helper, privateKey) => {
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob'); // funds donor
});
-
- const statemineApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),
- };
- const uniqueApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
- };
-
- const relayApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),
- };
-
- await usingApi(async (api) => {
+ await usingPlaygrounds.atUrl(statemineUrl, async (helper) => {
+ const api = helper.getApi();
// 350.00 (three hundred fifty) DOT
const fundingAmount = 3_500_000_000_000;
@@ -115,11 +98,10 @@
const result4 = getGenericResult(events4);
expect(result4.success).to.be.true;
- }, statemineApiOptions);
+ });
- await usingApi(async (api) => {
-
+ await usingPlaygrounds(async (helper) => {
const location = {
V1: {
parents: 1,
@@ -144,20 +126,23 @@
decimals: ASSET_METADATA_DECIMALS,
minimalBalance: ASSET_METADATA_MINIMAL_BALANCE,
};
- //registerForeignAsset(owner, location, metadata)
- const tx = api.tx.foreignAssets.registerForeignAsset(alice.addressRaw, location, metadata);
- const sudoTx = api.tx.sudo.sudo(tx as any);
- const events = await executeTransaction(api, alice, sudoTx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ await helper.getSudo().foreignAssets.register(alice, alice.address, location, metadata);
+ // const tx = api.tx.foreignAssets.registerForeignAsset(alice.addressRaw, location, metadata);
+ // const sudoTx = api.tx.sudo.sudo(tx as any);
+ // const events = await executeTransaction(api, alice, sudoTx);
+ // const result = getGenericResult(events);
+ // expect(result.success).to.be.true;
- [balanceOpalBefore] = await getBalance(api, [alice.address]);
+ // [balanceOpalBefore] = await getBalance(api, [alice.address]);
+ balanceOpalBefore = await helper.balance.getSubstrate(alice.address);
- }, uniqueApiOptions);
+ });
// Providing the relay currency to the unique sender account
- await usingApi(async (api) => {
+ await usingPlaygrounds.atUrl(relayUrl, async (helper) => {
+ const api = helper.getApi();
+
const destination = {
V1: {
parents: 0,
@@ -205,22 +190,14 @@
const events = await executeTransaction(api, alice, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- }, relayApiOptions);
+ });
});
- it('Should connect and send USDT from Westmint to Opal', async () => {
-
- const statemineApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),
- };
-
- const uniqueApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
- };
+ itSub('Should connect and send USDT from Westmint to Opal', async ({helper}) => {
+ await usingPlaygrounds.atUrl(statemineUrl, async (helper) => {
+ const api = helper.getApi();
- await usingApi(async (api) => {
-
const dest = {
V1: {
parents: 1,
@@ -288,125 +265,109 @@
);
expect(balanceStmnBefore > balanceStmnAfter).to.be.true;
- }, statemineApiOptions);
+ });
// ensure that asset has been delivered
- await usingApi(async (api) => {
- await waitNewBlocks(api, 3);
- // expext collection id will be with id 1
- const free = (await api.query.fungible.balance(1, normalizeAccountId(alice.address))).toBigInt();
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- [balanceOpalAfter] = await getBalance(api, [alice.address]);
+ // expext collection id will be with id 1
+ // const free = (await api.query.fungible.balance(1, normalizeAccountId(alice.address))).toBigInt();
+ const free = await helper.ft.getBalance(1, {Substrate: alice.address});
- // commission has not paid in USDT token
- expect(free == TRANSFER_AMOUNT).to.be.true;
- console.log(
- 'Opal to Westmint transaction fees on Opal: %s USDT',
- bigIntToDecimals(TRANSFER_AMOUNT - free),
- );
- // ... and parachain native token
- expect(balanceOpalAfter == balanceOpalBefore).to.be.true;
- console.log(
- 'Opal to Westmint transaction fees on Opal: %s WND',
- bigIntToDecimals(balanceOpalAfter - balanceOpalBefore, WESTMINT_DECIMALS),
- );
+ // [balanceOpalAfter] = await getBalance(api, [alice.address]);
+ balanceOpalAfter = await helper.balance.getSubstrate(alice.address);
- }, uniqueApiOptions);
-
+ // commission has not paid in USDT token
+ expect(free == TRANSFER_AMOUNT).to.be.true;
+ console.log(
+ 'Opal to Westmint transaction fees on Opal: %s USDT',
+ bigIntToDecimals(TRANSFER_AMOUNT - free),
+ );
+ // ... and parachain native token
+ expect(balanceOpalAfter == balanceOpalBefore).to.be.true;
+ console.log(
+ 'Opal to Westmint transaction fees on Opal: %s WND',
+ bigIntToDecimals(balanceOpalAfter - balanceOpalBefore, WESTMINT_DECIMALS),
+ );
});
- it('Should connect and send USDT from Unique to Statemine back', async () => {
+ itSub('Should connect and send USDT from Unique to Statemine back', async ({helper}) => {
+ const api = helper.getApi();
- const uniqueApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
- };
-
- const statemineApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + STATEMINE_PORT),
+ const destination = {
+ V1: {
+ parents: 1,
+ interior: {X2: [
+ {
+ Parachain: STATEMINE_CHAIN,
+ },
+ {
+ AccountId32: {
+ network: 'Any',
+ id: alice.addressRaw,
+ },
+ },
+ ]},
+ },
};
- await usingApi(async (api) => {
- const destination = {
- V1: {
- parents: 1,
- interior: {X2: [
- {
- Parachain: STATEMINE_CHAIN,
- },
- {
- AccountId32: {
- network: 'Any',
- id: alice.addressRaw,
- },
- },
- ]},
+ const currencies: [any, bigint][] = [
+ [
+ {
+ ForeignAssetId: 0,
+ },
+ //10_000_000_000_000_000n,
+ TRANSFER_AMOUNT,
+ ],
+ [
+ {
+ NativeAssetId: 'Parent',
},
- };
+ 400_000_000_000_000n,
+ ],
+ ];
- const currencies: [any, bigint][] = [
- [
- {
- ForeignAssetId: 0,
- },
- //10_000_000_000_000_000n,
- TRANSFER_AMOUNT,
- ],
- [
- {
- NativeAssetId: 'Parent',
- },
- 400_000_000_000_000n,
- ],
- ];
+ const feeItem = 1;
+ const destWeight = 500000000000;
- const feeItem = 1;
- const destWeight = 500000000000;
+ const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);
+ const events = await executeTransaction(api, alice, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
+
+ // the commission has been paid in parachain native token
+ [balanceOpalFinal] = await getBalance(api, [alice.address]);
+ expect(balanceOpalAfter > balanceOpalFinal).to.be.true;
- const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);
- const events = await executeTransaction(api, alice, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
-
- // the commission has been paid in parachain native token
- [balanceOpalFinal] = await getBalance(api, [alice.address]);
- expect(balanceOpalAfter > balanceOpalFinal).to.be.true;
- }, uniqueApiOptions);
+ await usingPlaygrounds.atUrl(statemineUrl, async (helper) => {
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- await usingApi(async (api) => {
- await waitNewBlocks(api, 3);
+ const api = helper.getApi();
// The USDT token never paid fees. Its amount not changed from begin value.
// Also check that xcm transfer has been succeeded
const free = ((await api.query.assets.account(100, alice.address)).toHuman()) as any;
expect(BigInt(free.balance.replace(/,/g, '')) == ASSET_AMOUNT).to.be.true;
- }, statemineApiOptions);
+ });
});
-
- it('Should connect and send Relay token to Unique', async () => {
- const uniqueApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
- };
-
- const uniqueApiOptions2: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
- };
-
- const relayApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + RELAY_PORT),
- };
-
+ itSub('Should connect and send Relay token to Unique', async ({helper}) => {
const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;
- await usingApi(async (api) => {
- [balanceBobBefore] = await getBalance(api, [bob.address]);
- balanceBobRelayTokenBefore = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
+ // [balanceBobBefore] = await getBalance(api, [bob.address]);
+ // balanceBobRelayTokenBefore = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
+ balanceBobBefore = await helper.balance.getSubstrate(bob.address);
- }, uniqueApiOptions);
+ // TODO
+ balanceBobRelayTokenBefore = BigInt(((await helper.getApi().query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
// Providing the relay currency to the unique sender account
- await usingApi(async (api) => {
+ await usingPlaygrounds.atUrl(relayUrl, async (helper) => {
+ const api = helper.getApi();
+
const destination = {
V1: {
parents: 0,
@@ -454,73 +415,72 @@
const events = await executeTransaction(api, bob, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- }, relayApiOptions);
+ });
- await usingApi(async (api) => {
- await waitNewBlocks(api, 3);
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- [balanceBobAfter] = await getBalance(api, [bob.address]);
- balanceBobRelayTokenAfter = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
- const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;
- console.log(
- 'Relay (Westend) to Opal transaction fees: %s OPL',
- bigIntToDecimals(balanceBobAfter - balanceBobBefore),
- );
- console.log(
- 'Relay (Westend) to Opal transaction fees: %s WND',
- bigIntToDecimals(wndFee, WESTMINT_DECIMALS),
- );
- expect(balanceBobBefore == balanceBobAfter).to.be.true;
- expect(balanceBobRelayTokenBefore < balanceBobRelayTokenAfter).to.be.true;
- }, uniqueApiOptions2);
+ // [balanceBobAfter] = await getBalance(api, [bob.address]);
+ // balanceBobRelayTokenAfter = BigInt(((await api.query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
+ balanceBobAfter = await helper.balance.getSubstrate(bob.address);
+
+ // TODO
+ balanceBobRelayTokenAfter = BigInt(((await helper.getApi().query.tokens.accounts(bob.addressRaw, {NativeAssetId: 'Parent'})).toJSON() as any).free);
+ const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;
+ console.log(
+ 'Relay (Westend) to Opal transaction fees: %s OPL',
+ bigIntToDecimals(balanceBobAfter - balanceBobBefore),
+ );
+ console.log(
+ 'Relay (Westend) to Opal transaction fees: %s WND',
+ bigIntToDecimals(wndFee, WESTMINT_DECIMALS),
+ );
+ expect(balanceBobBefore == balanceBobAfter).to.be.true;
+ expect(balanceBobRelayTokenBefore < balanceBobRelayTokenAfter).to.be.true;
});
- it('Should connect and send Relay token back', async () => {
- const uniqueApiOptions: ApiOptions = {
- provider: new WsProvider('ws://127.0.0.1:' + UNIQUE_PORT),
+ itSub('Should connect and send Relay token back', async ({helper}) => {
+ const destination = {
+ V1: {
+ parents: 1,
+ interior: {X2: [
+ {
+ Parachain: STATEMINE_CHAIN,
+ },
+ {
+ AccountId32: {
+ network: 'Any',
+ id: bob.addressRaw,
+ },
+ },
+ ]},
+ },
};
- await usingApi(async (api) => {
- const destination = {
- V1: {
- parents: 1,
- interior: {X2: [
- {
- Parachain: STATEMINE_CHAIN,
- },
- {
- AccountId32: {
- network: 'Any',
- id: bob.addressRaw,
- },
- },
- ]},
+ const currencies: any = [
+ [
+ {
+ NativeAssetId: 'Parent',
},
- };
-
- const currencies: any = [
- [
- {
- NativeAssetId: 'Parent',
- },
- 50_000_000_000_000_000n,
- ],
- ];
-
- const feeItem = 0;
- const destWeight = 500000000000;
+ 50_000_000_000_000_000n,
+ ],
+ ];
- const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);
- const events = await executeTransaction(api, bob, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ const feeItem = 0;
+ const destWeight = 500000000000;
- [balanceBobFinal] = await getBalance(api, [bob.address]);
- console.log('Relay (Westend) to Opal transaction fees: %s OPL', balanceBobAfter - balanceBobFinal);
+ // TODO
+ const api = helper.getApi();
+ const tx = api.tx.xTokens.transferMulticurrencies(currencies, feeItem, destination, destWeight);
+ const events = await executeTransaction(api, bob, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- }, uniqueApiOptions);
+ // [balanceBobFinal] = await getBalance(api, [bob.address]);
+ balanceBobFinal = await helper.balance.getSubstrate(bob.address);
+ console.log('Relay (Westend) to Opal transaction fees: %s OPL', balanceBobAfter - balanceBobFinal);
});
});
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -14,23 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-
-import {WsProvider, Keyring} from '@polkadot/api';
-import {ApiOptions} from '@polkadot/api/types';
+import {Keyring} from '@polkadot/api';
import {IKeyringPair} from '@polkadot/types/types';
-import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';
+import {submitTransactionAsync} from '../substrate/substrate-api';
+import {getGenericResult, generateKeyringPair, waitEvent, bigIntToDecimals} from '../deprecated-helpers/helpers';
import {MultiLocation} from '@polkadot/types/interfaces';
import {blake2AsHex} from '@polkadot/util-crypto';
-import waitNewBlocks from '../substrate/wait-new-blocks';
import getBalance from '../substrate/get-balance';
import {XcmV2TraitsOutcome, XcmV2TraitsError} from '../interfaces';
+import {itSub, expect, describeXcm, usingPlaygrounds} from '../util/playgrounds';
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
const QUARTZ_CHAIN = 2095;
const KARURA_CHAIN = 2000;
const MOONRIVER_CHAIN = 2023;
@@ -39,29 +32,15 @@
const KARURA_PORT = 9946;
const MOONRIVER_PORT = 9947;
+const relayUrl = 'ws://127.0.0.1:' + RELAY_PORT;
+const karuraUrl = 'ws://127.0.0.1:' + KARURA_PORT;
+const moonriverUrl = 'ws://127.0.0.1:' + MOONRIVER_PORT;
+
const KARURA_DECIMALS = 12;
const TRANSFER_AMOUNT = 2000000000000000000000000n;
-function parachainApiOptions(port: number): ApiOptions {
- return {
- provider: new WsProvider('ws://127.0.0.1:' + port.toString()),
- };
-}
-
-function karuraOptions(): ApiOptions {
- return parachainApiOptions(KARURA_PORT);
-}
-
-function moonriverOptions(): ApiOptions {
- return parachainApiOptions(MOONRIVER_PORT);
-}
-
-function relayOptions(): ApiOptions {
- return parachainApiOptions(RELAY_PORT);
-}
-
-describe_xcm('[XCM] Integration test: Exchanging tokens with Karura', () => {
+describeXcm('[XCM] Integration test: Exchanging tokens with Karura', () => {
let alice: IKeyringPair;
let randomAccount: IKeyringPair;
@@ -76,233 +55,234 @@
let balanceQuartzForeignTokenFinal: bigint;
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingPlaygrounds(async (helper, privateKey) => {
const keyringSr25519 = new Keyring({type: 'sr25519'});
- alice = privateKeyWrapper('//Alice');
+ alice = privateKey('//Alice');
randomAccount = generateKeyringPair(keyringSr25519);
});
// Karura side
- await usingApi(
- async (api) => {
- const destination = {
- V0: {
- X2: [
- 'Parent',
- {
- Parachain: QUARTZ_CHAIN,
- },
- ],
- },
- };
+ await usingPlaygrounds.atUrl(karuraUrl, async (helper) => {
+ const api = helper.getApi();
+
+ const destination = {
+ V0: {
+ X2: [
+ 'Parent',
+ {
+ Parachain: QUARTZ_CHAIN,
+ },
+ ],
+ },
+ };
- const metadata = {
- name: 'QTZ',
- symbol: 'QTZ',
- decimals: 18,
- minimalBalance: 1,
- };
+ const metadata = {
+ name: 'QTZ',
+ symbol: 'QTZ',
+ decimals: 18,
+ minimalBalance: 1,
+ };
- const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);
- const sudoTx = api.tx.sudo.sudo(tx as any);
- const events = await submitTransactionAsync(alice, sudoTx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);
+ const sudoTx = api.tx.sudo.sudo(tx as any);
+ const events = await submitTransactionAsync(alice, sudoTx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);
- const events1 = await submitTransactionAsync(alice, tx1);
- const result1 = getGenericResult(events1);
- expect(result1.success).to.be.true;
+ const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);
+ const events1 = await submitTransactionAsync(alice, tx1);
+ const result1 = getGenericResult(events1);
+ expect(result1.success).to.be.true;
- [balanceKaruraTokenInit] = await getBalance(api, [randomAccount.address]);
- {
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
- balanceQuartzForeignTokenInit = BigInt(free);
- }
- },
- karuraOptions(),
- );
+ [balanceKaruraTokenInit] = await getBalance(api, [randomAccount.address]);
+ {
+ const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ balanceQuartzForeignTokenInit = BigInt(free);
+ }
+ });
// Quartz side
- await usingApi(async (api) => {
- const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);
- const events0 = await submitTransactionAsync(alice, tx0);
- const result0 = getGenericResult(events0);
- expect(result0.success).to.be.true;
+ await usingPlaygrounds(async (helper) => {
+ // const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);
+ // const events0 = await submitTransactionAsync(alice, tx0);
+ // const result0 = getGenericResult(events0);
+ // expect(result0.success).to.be.true;
+ await helper.balance.transferToSubstrate(alice, randomAccount.address, 10n * TRANSFER_AMOUNT);
- [balanceQuartzTokenInit] = await getBalance(api, [randomAccount.address]);
+ // [balanceQuartzTokenInit] = await getBalance(api, [randomAccount.address]);
+ balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccount.address);
});
});
- it('Should connect and send QTZ to Karura', async () => {
+ itSub('Should connect and send QTZ to Karura', async ({helper}) => {
// Quartz side
- await usingApi(async (api) => {
+ const destination = {
+ V0: {
+ X2: [
+ 'Parent',
+ {
+ Parachain: KARURA_CHAIN,
+ },
+ ],
+ },
+ };
- const destination = {
- V0: {
- X2: [
- 'Parent',
- {
- Parachain: KARURA_CHAIN,
- },
- ],
+ const beneficiary = {
+ V0: {
+ X1: {
+ AccountId32: {
+ network: 'Any',
+ id: randomAccount.addressRaw,
+ },
},
- };
+ },
+ };
- const beneficiary = {
- V0: {
- X1: {
- AccountId32: {
- network: 'Any',
- id: randomAccount.addressRaw,
+ const assets = {
+ V1: [
+ {
+ id: {
+ Concrete: {
+ parents: 0,
+ interior: 'Here',
},
},
+ fun: {
+ Fungible: TRANSFER_AMOUNT,
+ },
},
- };
+ ],
+ };
- const assets = {
- V1: [
- {
- id: {
- Concrete: {
- parents: 0,
- interior: 'Here',
- },
- },
- fun: {
- Fungible: TRANSFER_AMOUNT,
- },
- },
- ],
- };
+ const feeAssetItem = 0;
- const feeAssetItem = 0;
-
- const weightLimit = {
- Limited: 5000000000,
- };
+ const weightLimit = {
+ Limited: 5000000000,
+ };
- const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
- const events = await submitTransactionAsync(randomAccount, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ // TODO
+ const tx = helper.getApi().tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
+ const events = await submitTransactionAsync(randomAccount, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- [balanceQuartzTokenMiddle] = await getBalance(api, [randomAccount.address]);
+ // [balanceQuartzTokenMiddle] = await getBalance(api, [randomAccount.address]);
+ balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);
- const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
- console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
- expect(qtzFees > 0n).to.be.true;
- });
+ const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
+ console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
+ expect(qtzFees > 0n).to.be.true;
// Karura side
- await usingApi(
- async (api) => {
- await waitNewBlocks(api, 3);
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
- balanceQuartzForeignTokenMiddle = BigInt(free);
+ await usingPlaygrounds.atUrl(karuraUrl, async (helper) => {
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
+
+ // TODO
+ const {free} = (await helper.getApi().query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+ balanceQuartzForeignTokenMiddle = BigInt(free);
- [balanceKaruraTokenMiddle] = await getBalance(api, [randomAccount.address]);
+ // [balanceKaruraTokenMiddle] = await getBalance(api, [randomAccount.address]);
+ balanceKaruraTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);
- const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;
- const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;
+ const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;
+ const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;
- console.log(
- '[Quartz -> Karura] transaction fees on Karura: %s KAR',
- bigIntToDecimals(karFees, KARURA_DECIMALS),
- );
- console.log('[Quartz -> Karura] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));
- expect(karFees == 0n).to.be.true;
- expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
- },
- karuraOptions(),
- );
+ console.log(
+ '[Quartz -> Karura] transaction fees on Karura: %s KAR',
+ bigIntToDecimals(karFees, KARURA_DECIMALS),
+ );
+ console.log('[Quartz -> Karura] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));
+ expect(karFees == 0n).to.be.true;
+ expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
+ });
});
- it('Should connect to Karura and send QTZ back', async () => {
+ itSub('Should connect to Karura and send QTZ back', async ({helper}) => {
// Karura side
- await usingApi(
- async (api) => {
- const destination = {
- V1: {
- parents: 1,
- interior: {
- X2: [
- {Parachain: QUARTZ_CHAIN},
- {
- AccountId32: {
- network: 'Any',
- id: randomAccount.addressRaw,
- },
+ await usingPlaygrounds.atUrl(karuraUrl, async (helper) => {
+ const destination = {
+ V1: {
+ parents: 1,
+ interior: {
+ X2: [
+ {Parachain: QUARTZ_CHAIN},
+ {
+ AccountId32: {
+ network: 'Any',
+ id: randomAccount.addressRaw,
},
- ],
- },
+ },
+ ],
},
- };
+ },
+ };
- const id = {
- ForeignAsset: 0,
- };
+ const id = {
+ ForeignAsset: 0,
+ };
- const destWeight = 50000000;
+ const destWeight = 50000000;
- const tx = api.tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);
- const events = await submitTransactionAsync(randomAccount, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ // TODO
+ const tx = helper.getApi().tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);
+ const events = await submitTransactionAsync(randomAccount, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- [balanceKaruraTokenFinal] = await getBalance(api, [randomAccount.address]);
- {
- const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, id)).toJSON() as any;
- balanceQuartzForeignTokenFinal = BigInt(free);
- }
+ // [balanceKaruraTokenFinal] = await getBalance(api, [randomAccount.address]);
+ balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);
+ {
+ // TODO
+ const {free} = (await helper.getApi().query.tokens.accounts(randomAccount.addressRaw, id)).toJSON() as any;
+ balanceQuartzForeignTokenFinal = BigInt(free);
+ }
- const karFees = balanceKaruraTokenMiddle - balanceKaruraTokenFinal;
- const qtzOutcomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenFinal;
+ const karFees = balanceKaruraTokenMiddle - balanceKaruraTokenFinal;
+ const qtzOutcomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenFinal;
- console.log(
- '[Karura -> Quartz] transaction fees on Karura: %s KAR',
- bigIntToDecimals(karFees, KARURA_DECIMALS),
- );
- console.log('[Karura -> Quartz] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));
+ console.log(
+ '[Karura -> Quartz] transaction fees on Karura: %s KAR',
+ bigIntToDecimals(karFees, KARURA_DECIMALS),
+ );
+ console.log('[Karura -> Quartz] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));
- expect(karFees > 0).to.be.true;
- expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
- },
- karuraOptions(),
- );
+ expect(karFees > 0).to.be.true;
+ expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
+ });
// Quartz side
- await usingApi(async (api) => {
- await waitNewBlocks(api, 3);
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- [balanceQuartzTokenFinal] = await getBalance(api, [randomAccount.address]);
- const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
- expect(actuallyDelivered > 0).to.be.true;
+ // [balanceQuartzTokenFinal] = await getBalance(api, [randomAccount.address]);
+ balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccount.address);
+ const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
+ expect(actuallyDelivered > 0).to.be.true;
- console.log('[Karura -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));
+ console.log('[Karura -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));
- const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
- console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
- expect(qtzFees == 0n).to.be.true;
- });
+ const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
+ console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
+ expect(qtzFees == 0n).to.be.true;
});
});
// These tests are relevant only when the foreign asset pallet is disabled
-describe_xcm('[XCM] Integration test: Quartz rejects non-native tokens', () => {
+describeXcm('[XCM] Integration test: Quartz rejects non-native tokens', () => {
let alice: IKeyringPair;
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
- alice = privateKeyWrapper('//Alice');
+ await usingPlaygrounds(async (_helper, privateKey) => {
+ alice = privateKey('//Alice');
});
});
- it('Quartz rejects tokens from the Relay', async () => {
- await usingApi(async (api) => {
+ itSub('Quartz rejects tokens from the Relay', async ({helper}) => {
+ await usingPlaygrounds.atUrl(relayUrl, async (helper) => {
const destination = {
V1: {
parents: 0,
@@ -346,44 +326,45 @@
Limited: 5_000_000_000,
};
- const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
+ // TODO
+ const tx = helper.getApi().tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- }, relayOptions());
+ });
- await usingApi(async api => {
- const maxWaitBlocks = 3;
- const dmpQueueExecutedDownward = await waitEvent(
- api,
- maxWaitBlocks,
- 'dmpQueue',
- 'ExecutedDownward',
- );
+ const maxWaitBlocks = 3;
- expect(
- dmpQueueExecutedDownward != null,
- '[Relay] dmpQueue.ExecutedDownward event is expected',
- ).to.be.true;
+ // TODO
+ const dmpQueueExecutedDownward = await waitEvent(
+ helper.getApi(),
+ maxWaitBlocks,
+ 'dmpQueue',
+ 'ExecutedDownward',
+ );
- const event = dmpQueueExecutedDownward!.event;
- const outcome = event.data[1] as XcmV2TraitsOutcome;
+ expect(
+ dmpQueueExecutedDownward != null,
+ '[Relay] dmpQueue.ExecutedDownward event is expected',
+ ).to.be.true;
- expect(
- outcome.isIncomplete,
- '[Relay] The outcome of the XCM should be `Incomplete`',
- ).to.be.true;
+ const event = dmpQueueExecutedDownward!.event;
+ const outcome = event.data[1] as XcmV2TraitsOutcome;
+
+ expect(
+ outcome.isIncomplete,
+ '[Relay] The outcome of the XCM should be `Incomplete`',
+ ).to.be.true;
- const incomplete = outcome.asIncomplete;
- expect(
- incomplete[1].toString() == 'AssetNotFound',
- '[Relay] The XCM error should be `AssetNotFound`',
- ).to.be.true;
- });
+ const incomplete = outcome.asIncomplete;
+ expect(
+ incomplete[1].toString() == 'AssetNotFound',
+ '[Relay] The XCM error should be `AssetNotFound`',
+ ).to.be.true;
});
- it('Quartz rejects KAR tokens from Karura', async () => {
- await usingApi(async (api) => {
+ itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
+ await usingPlaygrounds.atUrl(karuraUrl, async (helper) => {
const destination = {
V1: {
parents: 1,
@@ -407,33 +388,34 @@
const destWeight = 50000000;
- const tx = api.tx.xTokens.transfer(id as any, 100_000_000_000, destination, destWeight);
+ // TODO
+ const tx = helper.getApi().tx.xTokens.transfer(id as any, 100_000_000_000, destination, destWeight);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- }, karuraOptions());
+ });
- await usingApi(async api => {
- const maxWaitBlocks = 3;
- const xcmpQueueFailEvent = await waitEvent(api, maxWaitBlocks, 'xcmpQueue', 'Fail');
+ const maxWaitBlocks = 3;
- expect(
- xcmpQueueFailEvent != null,
- '[Karura] xcmpQueue.FailEvent event is expected',
- ).to.be.true;
+ // TODO
+ const xcmpQueueFailEvent = await waitEvent(helper.getApi(), maxWaitBlocks, 'xcmpQueue', 'Fail');
- const event = xcmpQueueFailEvent!.event;
- const outcome = event.data[1] as XcmV2TraitsError;
+ expect(
+ xcmpQueueFailEvent != null,
+ '[Karura] xcmpQueue.FailEvent event is expected',
+ ).to.be.true;
- expect(
- outcome.isUntrustedReserveLocation,
- '[Karura] The XCM error should be `UntrustedReserveLocation`',
- ).to.be.true;
- });
+ const event = xcmpQueueFailEvent!.event;
+ const outcome = event.data[1] as XcmV2TraitsError;
+
+ expect(
+ outcome.isUntrustedReserveLocation,
+ '[Karura] The XCM error should be `UntrustedReserveLocation`',
+ ).to.be.true;
});
});
-describe_xcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
+describeXcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
// Quartz constants
let quartzAlice: IKeyringPair;
@@ -478,322 +460,327 @@
let balanceMovrTokenFinal: bigint;
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingPlaygrounds(async (_helper, privateKey) => {
const keyringEth = new Keyring({type: 'ethereum'});
const keyringSr25519 = new Keyring({type: 'sr25519'});
- quartzAlice = privateKeyWrapper('//Alice');
+ quartzAlice = privateKey('//Alice');
randomAccountQuartz = generateKeyringPair(keyringSr25519);
randomAccountMoonriver = generateKeyringPair(keyringEth);
balanceForeignQtzTokenInit = 0n;
});
- await usingApi(
- async (api) => {
+ await usingPlaygrounds.atUrl(moonriverUrl, async (helper) => {
+ // TODO
- // >>> Sponsoring Dorothy >>>
- console.log('Sponsoring Dorothy.......');
- const tx0 = api.tx.balances.transfer(dorothyAccount.address, 11_000_000_000_000_000_000n);
- const events0 = await submitTransactionAsync(alithAccount, tx0);
- const result0 = getGenericResult(events0);
- expect(result0.success).to.be.true;
- console.log('Sponsoring Dorothy.......DONE');
- // <<< Sponsoring Dorothy <<<
+ const api = helper.getApi();
- const sourceLocation: MultiLocation = api.createType(
- 'MultiLocation',
- {
- parents: 1,
- interior: {X1: {Parachain: QUARTZ_CHAIN}},
- },
- );
+ // >>> Sponsoring Dorothy >>>
+ console.log('Sponsoring Dorothy.......');
+ // const tx0 = api.tx.balances.transfer(dorothyAccount.address, 11_000_000_000_000_000_000n);
+ // const events0 = await submitTransactionAsync(alithAccount, tx0);
+ // const result0 = getGenericResult(events0);
+ // expect(result0.success).to.be.true;
+ await helper.balance.transferToSubstrate(alithAccount, dorothyAccount.address, 11_000_000_000_000_000_000n);
+ console.log('Sponsoring Dorothy.......DONE');
+ // <<< Sponsoring Dorothy <<<
- quartzAssetLocation = {XCM: sourceLocation};
- const existentialDeposit = 1;
- const isSufficient = true;
- const unitsPerSecond = '1';
- const numAssetsWeightHint = 0;
+ const sourceLocation: MultiLocation = api.createType(
+ 'MultiLocation',
+ {
+ parents: 1,
+ interior: {X1: {Parachain: QUARTZ_CHAIN}},
+ },
+ );
- const registerTx = api.tx.assetManager.registerForeignAsset(
- quartzAssetLocation,
- quartzAssetMetadata,
- existentialDeposit,
- isSufficient,
- );
- console.log('Encoded proposal for registerAsset is %s', registerTx.method.toHex() || '');
+ quartzAssetLocation = {XCM: sourceLocation};
+ const existentialDeposit = 1;
+ const isSufficient = true;
+ const unitsPerSecond = '1';
+ const numAssetsWeightHint = 0;
- const setUnitsTx = api.tx.assetManager.setAssetUnitsPerSecond(
- quartzAssetLocation,
- unitsPerSecond,
- numAssetsWeightHint,
- );
- console.log('Encoded proposal for setAssetUnitsPerSecond is %s', setUnitsTx.method.toHex() || '');
+ const registerTx = api.tx.assetManager.registerForeignAsset(
+ quartzAssetLocation,
+ quartzAssetMetadata,
+ existentialDeposit,
+ isSufficient,
+ );
+ console.log('Encoded proposal for registerAsset is %s', registerTx.method.toHex() || '');
- const batchCall = api.tx.utility.batchAll([registerTx, setUnitsTx]);
- console.log('Encoded proposal for batchCall is %s', batchCall.method.toHex() || '');
+ const setUnitsTx = api.tx.assetManager.setAssetUnitsPerSecond(
+ quartzAssetLocation,
+ unitsPerSecond,
+ numAssetsWeightHint,
+ );
+ console.log('Encoded proposal for setAssetUnitsPerSecond is %s', setUnitsTx.method.toHex() || '');
- // >>> Note motion preimage >>>
- console.log('Note motion preimage.......');
- const encodedProposal = batchCall?.method.toHex() || '';
- const proposalHash = blake2AsHex(encodedProposal);
- console.log('Encoded proposal for batch utility after schedule is %s', encodedProposal);
- console.log('Encoded proposal hash for batch utility after schedule is %s', proposalHash);
- console.log('Encoded length %d', encodedProposal.length);
+ const batchCall = api.tx.utility.batchAll([registerTx, setUnitsTx]);
+ console.log('Encoded proposal for batchCall is %s', batchCall.method.toHex() || '');
- const tx1 = api.tx.democracy.notePreimage(encodedProposal);
- const events1 = await submitTransactionAsync(baltatharAccount, tx1);
- const result1 = getGenericResult(events1);
- expect(result1.success).to.be.true;
- console.log('Note motion preimage.......DONE');
- // <<< Note motion preimage <<<
+ // >>> Note motion preimage >>>
+ console.log('Note motion preimage.......');
+ const encodedProposal = batchCall?.method.toHex() || '';
+ const proposalHash = blake2AsHex(encodedProposal);
+ console.log('Encoded proposal for batch utility after schedule is %s', encodedProposal);
+ console.log('Encoded proposal hash for batch utility after schedule is %s', proposalHash);
+ console.log('Encoded length %d', encodedProposal.length);
- // >>> Propose external motion through council >>>
- console.log('Propose external motion through council.......');
- const externalMotion = api.tx.democracy.externalProposeMajority(proposalHash);
- const tx2 = api.tx.councilCollective.propose(
- councilVotingThreshold,
- externalMotion,
- externalMotion.encodedLength,
- );
- const events2 = await submitTransactionAsync(baltatharAccount, tx2);
- const result2 = getGenericResult(events2);
- expect(result2.success).to.be.true;
+ const tx1 = api.tx.democracy.notePreimage(encodedProposal);
+ const events1 = await submitTransactionAsync(baltatharAccount, tx1);
+ const result1 = getGenericResult(events1);
+ expect(result1.success).to.be.true;
+ console.log('Note motion preimage.......DONE');
+ // <<< Note motion preimage <<<
- const encodedMotion = externalMotion?.method.toHex() || '';
- const motionHash = blake2AsHex(encodedMotion);
- console.log('Motion hash is %s', motionHash);
+ // >>> Propose external motion through council >>>
+ console.log('Propose external motion through council.......');
+ const externalMotion = api.tx.democracy.externalProposeMajority(proposalHash);
+ const tx2 = api.tx.councilCollective.propose(
+ councilVotingThreshold,
+ externalMotion,
+ externalMotion.encodedLength,
+ );
+ const events2 = await submitTransactionAsync(baltatharAccount, tx2);
+ const result2 = getGenericResult(events2);
+ expect(result2.success).to.be.true;
- const tx3 = api.tx.councilCollective.vote(motionHash, 0, true);
- {
- const events3 = await submitTransactionAsync(dorothyAccount, tx3);
- const result3 = getGenericResult(events3);
- expect(result3.success).to.be.true;
- }
- {
- const events3 = await submitTransactionAsync(baltatharAccount, tx3);
- const result3 = getGenericResult(events3);
- expect(result3.success).to.be.true;
- }
+ const encodedMotion = externalMotion?.method.toHex() || '';
+ const motionHash = blake2AsHex(encodedMotion);
+ console.log('Motion hash is %s', motionHash);
- const tx4 = api.tx.councilCollective.close(motionHash, 0, 1_000_000_000, externalMotion.encodedLength);
- const events4 = await submitTransactionAsync(dorothyAccount, tx4);
- const result4 = getGenericResult(events4);
- expect(result4.success).to.be.true;
- console.log('Propose external motion through council.......DONE');
- // <<< Propose external motion through council <<<
+ const tx3 = api.tx.councilCollective.vote(motionHash, 0, true);
+ {
+ const events3 = await submitTransactionAsync(dorothyAccount, tx3);
+ const result3 = getGenericResult(events3);
+ expect(result3.success).to.be.true;
+ }
+ {
+ const events3 = await submitTransactionAsync(baltatharAccount, tx3);
+ const result3 = getGenericResult(events3);
+ expect(result3.success).to.be.true;
+ }
- // >>> Fast track proposal through technical committee >>>
- console.log('Fast track proposal through technical committee.......');
- const fastTrack = api.tx.democracy.fastTrack(proposalHash, votingPeriod, delayPeriod);
- const tx5 = api.tx.techCommitteeCollective.propose(
- technicalCommitteeThreshold,
- fastTrack,
- fastTrack.encodedLength,
- );
- const events5 = await submitTransactionAsync(alithAccount, tx5);
- const result5 = getGenericResult(events5);
- expect(result5.success).to.be.true;
+ const tx4 = api.tx.councilCollective.close(motionHash, 0, 1_000_000_000, externalMotion.encodedLength);
+ const events4 = await submitTransactionAsync(dorothyAccount, tx4);
+ const result4 = getGenericResult(events4);
+ expect(result4.success).to.be.true;
+ console.log('Propose external motion through council.......DONE');
+ // <<< Propose external motion through council <<<
- const encodedFastTrack = fastTrack?.method.toHex() || '';
- const fastTrackHash = blake2AsHex(encodedFastTrack);
- console.log('FastTrack hash is %s', fastTrackHash);
+ // >>> Fast track proposal through technical committee >>>
+ console.log('Fast track proposal through technical committee.......');
+ const fastTrack = api.tx.democracy.fastTrack(proposalHash, votingPeriod, delayPeriod);
+ const tx5 = api.tx.techCommitteeCollective.propose(
+ technicalCommitteeThreshold,
+ fastTrack,
+ fastTrack.encodedLength,
+ );
+ const events5 = await submitTransactionAsync(alithAccount, tx5);
+ const result5 = getGenericResult(events5);
+ expect(result5.success).to.be.true;
- const proposalIdx = Number(await api.query.techCommitteeCollective.proposalCount()) - 1;
- const tx6 = api.tx.techCommitteeCollective.vote(fastTrackHash, proposalIdx, true);
- {
- const events6 = await submitTransactionAsync(baltatharAccount, tx6);
- const result6 = getGenericResult(events6);
- expect(result6.success).to.be.true;
- }
- {
- const events6 = await submitTransactionAsync(alithAccount, tx6);
- const result6 = getGenericResult(events6);
- expect(result6.success).to.be.true;
- }
+ const encodedFastTrack = fastTrack?.method.toHex() || '';
+ const fastTrackHash = blake2AsHex(encodedFastTrack);
+ console.log('FastTrack hash is %s', fastTrackHash);
- const tx7 = api.tx.techCommitteeCollective
- .close(fastTrackHash, proposalIdx, 1_000_000_000, fastTrack.encodedLength);
- const events7 = await submitTransactionAsync(baltatharAccount, tx7);
- const result7 = getGenericResult(events7);
- expect(result7.success).to.be.true;
- console.log('Fast track proposal through technical committee.......DONE');
- // <<< Fast track proposal through technical committee <<<
+ const proposalIdx = Number(await api.query.techCommitteeCollective.proposalCount()) - 1;
+ const tx6 = api.tx.techCommitteeCollective.vote(fastTrackHash, proposalIdx, true);
+ {
+ const events6 = await submitTransactionAsync(baltatharAccount, tx6);
+ const result6 = getGenericResult(events6);
+ expect(result6.success).to.be.true;
+ }
+ {
+ const events6 = await submitTransactionAsync(alithAccount, tx6);
+ const result6 = getGenericResult(events6);
+ expect(result6.success).to.be.true;
+ }
- // >>> Referendum voting >>>
- console.log('Referendum voting.......');
- const tx8 = api.tx.democracy.vote(
- 0,
- {Standard: {balance: 10_000_000_000_000_000_000n, vote: {aye: true, conviction: 1}}},
- );
- const events8 = await submitTransactionAsync(dorothyAccount, tx8);
- const result8 = getGenericResult(events8);
- expect(result8.success).to.be.true;
- console.log('Referendum voting.......DONE');
- // <<< Referendum voting <<<
+ const tx7 = api.tx.techCommitteeCollective
+ .close(fastTrackHash, proposalIdx, 1_000_000_000, fastTrack.encodedLength);
+ const events7 = await submitTransactionAsync(baltatharAccount, tx7);
+ const result7 = getGenericResult(events7);
+ expect(result7.success).to.be.true;
+ console.log('Fast track proposal through technical committee.......DONE');
+ // <<< Fast track proposal through technical committee <<<
- // >>> Acquire Quartz AssetId Info on Moonriver >>>
- console.log('Acquire Quartz AssetId Info on Moonriver.......');
+ // >>> Referendum voting >>>
+ console.log('Referendum voting.......');
+ const tx8 = api.tx.democracy.vote(
+ 0,
+ {Standard: {balance: 10_000_000_000_000_000_000n, vote: {aye: true, conviction: 1}}},
+ );
+ const events8 = await submitTransactionAsync(dorothyAccount, tx8);
+ const result8 = getGenericResult(events8);
+ expect(result8.success).to.be.true;
+ console.log('Referendum voting.......DONE');
+ // <<< Referendum voting <<<
- // Wait for the democracy execute
- await waitNewBlocks(api, 5);
+ // >>> Acquire Quartz AssetId Info on Moonriver >>>
+ console.log('Acquire Quartz AssetId Info on Moonriver.......');
- assetId = (await api.query.assetManager.assetTypeId({
- XCM: sourceLocation,
- })).toString();
+ // Wait for the democracy execute
+ // await waitNewBlocks(api, 5);
+ await helper.wait.newBlocks(5);
- console.log('QTZ asset ID is %s', assetId);
- console.log('Acquire Quartz AssetId Info on Moonriver.......DONE');
- // >>> Acquire Quartz AssetId Info on Moonriver >>>
+ assetId = (await api.query.assetManager.assetTypeId({
+ XCM: sourceLocation,
+ })).toString();
- // >>> Sponsoring random Account >>>
- console.log('Sponsoring random Account.......');
- const tx10 = api.tx.balances.transfer(randomAccountMoonriver.address, 11_000_000_000_000_000_000n);
- const events10 = await submitTransactionAsync(baltatharAccount, tx10);
- const result10 = getGenericResult(events10);
- expect(result10.success).to.be.true;
- console.log('Sponsoring random Account.......DONE');
- // <<< Sponsoring random Account <<<
+ console.log('QTZ asset ID is %s', assetId);
+ console.log('Acquire Quartz AssetId Info on Moonriver.......DONE');
+ // >>> Acquire Quartz AssetId Info on Moonriver >>>
- [balanceMovrTokenInit] = await getBalance(api, [randomAccountMoonriver.address]);
- },
- moonriverOptions(),
- );
+ // >>> Sponsoring random Account >>>
+ console.log('Sponsoring random Account.......');
+ // const tx10 = api.tx.balances.transfer(randomAccountMoonriver.address, 11_000_000_000_000_000_000n);
+ // const events10 = await submitTransactionAsync(baltatharAccount, tx10);
+ // const result10 = getGenericResult(events10);
+ // expect(result10.success).to.be.true;
+ await helper.balance.transferToSubstrate(baltatharAccount, randomAccountMoonriver.address, 11_000_000_000_000_000_000n);
+ console.log('Sponsoring random Account.......DONE');
+ // <<< Sponsoring random Account <<<
- await usingApi(async (api) => {
- const tx0 = api.tx.balances.transfer(randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);
- const events0 = await submitTransactionAsync(quartzAlice, tx0);
- const result0 = getGenericResult(events0);
- expect(result0.success).to.be.true;
+ // [balanceMovrTokenInit] = await getBalance(api, [randomAccountMoonriver.address]);
+ balanceMovrTokenInit = await helper.balance.getSubstrate(randomAccountMoonriver.address);
+ });
- [balanceQuartzTokenInit] = await getBalance(api, [randomAccountQuartz.address]);
+ await usingPlaygrounds(async (helper) => {
+ // const tx0 = api.tx.balances.transfer(randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);
+ // const events0 = await submitTransactionAsync(quartzAlice, tx0);
+ // const result0 = getGenericResult(events0);
+ // expect(result0.success).to.be.true;
+ await helper.balance.transferToSubstrate(quartzAlice, randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);
+
+ // [balanceQuartzTokenInit] = await getBalance(api, [randomAccountQuartz.address]);
+ balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccountQuartz.address);
});
});
- it('Should connect and send QTZ to Moonriver', async () => {
- await usingApi(async (api) => {
- const currencyId = {
- NativeAssetId: 'Here',
- };
- const dest = {
- V1: {
- parents: 1,
- interior: {
- X2: [
- {Parachain: MOONRIVER_CHAIN},
- {AccountKey20: {network: 'Any', key: randomAccountMoonriver.address}},
- ],
- },
+ itSub('Should connect and send QTZ to Moonriver', async ({helper}) => {
+ const currencyId = {
+ NativeAssetId: 'Here',
+ };
+ const dest = {
+ V1: {
+ parents: 1,
+ interior: {
+ X2: [
+ {Parachain: MOONRIVER_CHAIN},
+ {AccountKey20: {network: 'Any', key: randomAccountMoonriver.address}},
+ ],
},
- };
- const amount = TRANSFER_AMOUNT;
- const destWeight = 850000000;
+ },
+ };
+ const amount = TRANSFER_AMOUNT;
+ const destWeight = 850000000;
- const tx = api.tx.xTokens.transfer(currencyId, amount, dest, destWeight);
- const events = await submitTransactionAsync(randomAccountQuartz, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ // TODO
+ const tx = helper.getApi().tx.xTokens.transfer(currencyId, amount, dest, destWeight);
+ const events = await submitTransactionAsync(randomAccountQuartz, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- [balanceQuartzTokenMiddle] = await getBalance(api, [randomAccountQuartz.address]);
- expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;
+ // [balanceQuartzTokenMiddle] = await getBalance(api, [randomAccountQuartz.address]);
+ balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccountQuartz.address);
+ expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;
- const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
- console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', bigIntToDecimals(transactionFees));
- expect(transactionFees > 0).to.be.true;
- });
+ const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
+ console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', bigIntToDecimals(transactionFees));
+ expect(transactionFees > 0).to.be.true;
- await usingApi(
- async (api) => {
- await waitNewBlocks(api, 3);
+ await usingPlaygrounds.atUrl(moonriverUrl, async (helper) => {
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- [balanceMovrTokenMiddle] = await getBalance(api, [randomAccountMoonriver.address]);
+ // [balanceMovrTokenMiddle] = await getBalance(api, [randomAccountMoonriver.address]);
+ balanceMovrTokenMiddle = await helper.balance.getSubstrate(randomAccountMoonriver.address);
- const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;
- console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',bigIntToDecimals(movrFees));
- expect(movrFees == 0n).to.be.true;
+ const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;
+ console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',bigIntToDecimals(movrFees));
+ expect(movrFees == 0n).to.be.true;
- const qtzRandomAccountAsset = (
- await api.query.assets.account(assetId, randomAccountMoonriver.address)
- ).toJSON()! as any;
+ // TODO
+ const qtzRandomAccountAsset = (
+ await helper.getApi().query.assets.account(assetId, randomAccountMoonriver.address)
+ ).toJSON()! as any;
- balanceForeignQtzTokenMiddle = BigInt(qtzRandomAccountAsset['balance']);
- const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;
- console.log('[Quartz -> Moonriver] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));
- expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
- },
- moonriverOptions(),
- );
+ balanceForeignQtzTokenMiddle = BigInt(qtzRandomAccountAsset['balance']);
+ const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;
+ console.log('[Quartz -> Moonriver] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));
+ expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
+ });
});
- it('Should connect to Moonriver and send QTZ back', async () => {
- await usingApi(
- async (api) => {
- const asset = {
- V1: {
- id: {
- Concrete: {
- parents: 1,
- interior: {
- X1: {Parachain: QUARTZ_CHAIN},
- },
+ itSub('Should connect to Moonriver and send QTZ back', async ({helper}) => {
+ await usingPlaygrounds.atUrl(moonriverUrl, async (helper) => {
+ const asset = {
+ V1: {
+ id: {
+ Concrete: {
+ parents: 1,
+ interior: {
+ X1: {Parachain: QUARTZ_CHAIN},
},
},
- fun: {
- Fungible: TRANSFER_AMOUNT,
- },
},
- };
- const destination = {
- V1: {
- parents: 1,
- interior: {
- X2: [
- {Parachain: QUARTZ_CHAIN},
- {AccountId32: {network: 'Any', id: randomAccountQuartz.addressRaw}},
- ],
- },
+ fun: {
+ Fungible: TRANSFER_AMOUNT,
+ },
+ },
+ };
+ const destination = {
+ V1: {
+ parents: 1,
+ interior: {
+ X2: [
+ {Parachain: QUARTZ_CHAIN},
+ {AccountId32: {network: 'Any', id: randomAccountQuartz.addressRaw}},
+ ],
},
- };
- const destWeight = 50000000;
+ },
+ };
+ const destWeight = 50000000;
- const tx = api.tx.xTokens.transferMultiasset(asset, destination, destWeight);
- const events = await submitTransactionAsync(randomAccountMoonriver, tx);
- const result = getGenericResult(events);
- expect(result.success).to.be.true;
+ // TODO
+ const tx = helper.getApi().tx.xTokens.transferMultiasset(asset, destination, destWeight);
+ const events = await submitTransactionAsync(randomAccountMoonriver, tx);
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- [balanceMovrTokenFinal] = await getBalance(api, [randomAccountMoonriver.address]);
+ // [balanceMovrTokenFinal] = await getBalance(api, [randomAccountMoonriver.address]);
+ balanceMovrTokenFinal = await helper.balance.getSubstrate(randomAccountMoonriver.address);
- const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;
- console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', bigIntToDecimals(movrFees));
- expect(movrFees > 0).to.be.true;
+ const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;
+ console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', bigIntToDecimals(movrFees));
+ expect(movrFees > 0).to.be.true;
- const qtzRandomAccountAsset = (
- await api.query.assets.account(assetId, randomAccountMoonriver.address)
- ).toJSON()! as any;
+ const qtzRandomAccountAsset = (
+ await helper.getApi().query.assets.account(assetId, randomAccountMoonriver.address)
+ ).toJSON()! as any;
- expect(qtzRandomAccountAsset).to.be.null;
+ expect(qtzRandomAccountAsset).to.be.null;
- balanceForeignQtzTokenFinal = 0n;
+ balanceForeignQtzTokenFinal = 0n;
- const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;
- console.log('[Quartz -> Moonriver] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));
- expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
- },
- moonriverOptions(),
- );
+ const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;
+ console.log('[Quartz -> Moonriver] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));
+ expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
+ });
- await usingApi(async (api) => {
- await waitNewBlocks(api, 3);
+ // await waitNewBlocks(api, 3);
+ await helper.wait.newBlocks(3);
- [balanceQuartzTokenFinal] = await getBalance(api, [randomAccountQuartz.address]);
- const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
- expect(actuallyDelivered > 0).to.be.true;
+ // [balanceQuartzTokenFinal] = await getBalance(api, [randomAccountQuartz.address]);
+ balanceQuartzTokenFinal = await helper.balance.getSubstrate(randomAccountQuartz.address);
+ const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
+ expect(actuallyDelivered > 0).to.be.true;
- console.log('[Moonriver -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));
+ console.log('[Moonriver -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));
- const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
- console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
- expect(qtzFees == 0n).to.be.true;
- });
+ const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
+ console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));
+ expect(qtzFees == 0n).to.be.true;
});
});
tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';191620import {WsProvider, Keyring} from '@polkadot/api';17import {Keyring} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';19import {submitTransactionAsync} from '../substrate/substrate-api';24import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';20import {getGenericResult, generateKeyringPair, waitEvent, bigIntToDecimals} from '../deprecated-helpers/helpers';25import {MultiLocation} from '@polkadot/types/interfaces';21import {MultiLocation} from '@polkadot/types/interfaces';26import {blake2AsHex} from '@polkadot/util-crypto';22import {blake2AsHex} from '@polkadot/util-crypto';27import waitNewBlocks from '../substrate/wait-new-blocks';28import getBalance from '../substrate/get-balance';23import getBalance from '../substrate/get-balance';29import {XcmV2TraitsError, XcmV2TraitsOutcome} from '../interfaces';24import {XcmV2TraitsError, XcmV2TraitsOutcome} from '../interfaces';3031chai.use(chaiAsPromised);32const expect = chai.expect;25import {itSub, expect, describeXcm, usingPlaygrounds} from '../util/playgrounds';332634const UNIQUE_CHAIN = 2037;27const UNIQUE_CHAIN = 2037;35const ACALA_CHAIN = 2000;28const ACALA_CHAIN = 2000;39const ACALA_PORT = 9946;32const ACALA_PORT = 9946;40const MOONBEAM_PORT = 9947;33const MOONBEAM_PORT = 9947;413442const ACALA_DECIMALS = 12;35const relayUrl = 'ws://127.0.0.1:' + RELAY_PORT;4344const TRANSFER_AMOUNT = 2000000000000000000000000n;36const acalaUrl = 'ws://127.0.0.1:' + ACALA_PORT;4546function parachainApiOptions(port: number): ApiOptions {47 return {48 provider: new WsProvider('ws://127.0.0.1:' + port.toString()),37const moonbeamUrl = 'ws://127.0.0.1:' + MOONBEAM_PORT;49 };3850}5152function acalaOptions(): ApiOptions {53 return parachainApiOptions(ACALA_PORT);39const ACALA_DECIMALS = 12;54}405556function moonbeamOptions(): ApiOptions {57 return parachainApiOptions(MOONBEAM_PORT);41const TRANSFER_AMOUNT = 2000000000000000000000000n;58}5960function relayOptions(): ApiOptions {61 return parachainApiOptions(RELAY_PORT);62}634264describe_xcm('[XCM] Integration test: Exchanging tokens with Acala', () => {43describeXcm('[XCM] Integration test: Exchanging tokens with Acala', () => {65 let alice: IKeyringPair;44 let alice: IKeyringPair;66 let randomAccount: IKeyringPair;45 let randomAccount: IKeyringPair;674676 let balanceUniqueForeignTokenFinal: bigint;55 let balanceUniqueForeignTokenFinal: bigint;775678 before(async () => {57 before(async () => {79 await usingApi(async (api, privateKeyWrapper) => {58 await usingPlaygrounds(async (_helper, privateKey) => {80 const keyringSr25519 = new Keyring({type: 'sr25519'});59 const keyringSr25519 = new Keyring({type: 'sr25519'});816082 alice = privateKeyWrapper('//Alice');61 alice = privateKey('//Alice');83 randomAccount = generateKeyringPair(keyringSr25519);62 randomAccount = generateKeyringPair(keyringSr25519);84 });63 });856486 // Acala side65 // Acala side87 await usingApi(66 await usingPlaygrounds.atUrl(acalaUrl, async (helper) => {88 async (api) => {89 const destination = {67 const destination = {90 V0: {68 V0: {91 X2: [69 X2: [104 minimalBalance: 1,82 minimalBalance: 1,105 };83 };1068485 // TODO107 const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);86 const tx = helper.getApi().tx.assetRegistry.registerForeignAsset(destination, metadata);108 const sudoTx = api.tx.sudo.sudo(tx as any);87 const sudoTx = helper.getApi().tx.sudo.sudo(tx as any);109 const events = await submitTransactionAsync(alice, sudoTx);88 const events = await submitTransactionAsync(alice, sudoTx);110 const result = getGenericResult(events);89 const result = getGenericResult(events);111 expect(result.success).to.be.true;90 expect(result.success).to.be.true;1129192 // const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);93 // const events1 = await submitTransactionAsync(alice, tx1);94 // const result1 = getGenericResult(events1);95 // expect(result1.success).to.be.true;113 const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);96 await helper.balance.transferToSubstrate(alice, randomAccount.address, 10000000000000n);114 const events1 = await submitTransactionAsync(alice, tx1);97115 const result1 = getGenericResult(events1);98 // [balanceAcalaTokenInit] = await getBalance(api, [randomAccount.address]);116 expect(result1.success).to.be.true;117118 [balanceAcalaTokenInit] = await getBalance(api, [randomAccount.address]);99 balanceAcalaTokenInit = await helper.balance.getSubstrate(randomAccount.address);119 {100 {101 // TODO120 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;102 const {free} = (await helper.getApi().query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;121 balanceUniqueForeignTokenInit = BigInt(free);103 balanceUniqueForeignTokenInit = BigInt(free);122 }104 }123 },105 });124 acalaOptions(),125 );126106127 // Unique side107 // Unique side128 await usingApi(async (api) => {108 await usingPlaygrounds(async (helper) => {109 // const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);110 // const events0 = await submitTransactionAsync(alice, tx0);111 // const result0 = getGenericResult(events0);112 // expect(result0.success).to.be.true;129 const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);113 await helper.balance.transferToSubstrate(alice, randomAccount.address, 10n * TRANSFER_AMOUNT);130 const events0 = await submitTransactionAsync(alice, tx0);114131 const result0 = getGenericResult(events0);115 // [balanceUniqueTokenInit] = await getBalance(api, [randomAccount.address]);132 expect(result0.success).to.be.true;133134 [balanceUniqueTokenInit] = await getBalance(api, [randomAccount.address]);116 balanceUniqueTokenInit = await helper.balance.getSubstrate(randomAccount.address);135 });117 });136 });118 });137119138 it('Should connect and send UNQ to Acala', async () => {120 itSub('Should connect and send UNQ to Acala', async ({helper}) => {139121140 // Unique side122 // Unique side141 await usingApi(async (api) => {142143 const destination = {123 const destination = {144 V0: {124 V0: {184 Limited: 5000000000,164 Limited: 5000000000,185 };165 };186166167 // TODO187 const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);168 const tx = helper.getApi().tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);188 const events = await submitTransactionAsync(randomAccount, tx);169 const events = await submitTransactionAsync(randomAccount, tx);189 const result = getGenericResult(events);170 const result = getGenericResult(events);190 expect(result.success).to.be.true;171 expect(result.success).to.be.true;191172173 // [balanceUniqueTokenMiddle] = await getBalance(api, [randomAccount.address]);192 [balanceUniqueTokenMiddle] = await getBalance(api, [randomAccount.address]);174 balanceUniqueTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);193175194 const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;176 const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;195 console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));177 console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));196 expect(unqFees > 0n).to.be.true;178 expect(unqFees > 0n).to.be.true;197 });198179199 // Acala side180 // Acala side200 await usingApi(181 await usingPlaygrounds.atUrl(acalaUrl, async (helper) => {201 async (api) => {182 // await waitNewBlocks(api, 3);202 await waitNewBlocks(api, 3);183 await helper.wait.newBlocks(3);184185 // TODO203 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;186 const {free} = (await helper.getApi().query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;204 balanceUniqueForeignTokenMiddle = BigInt(free);187 balanceUniqueForeignTokenMiddle = BigInt(free);205188189 // [balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);206 [balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);190 balanceAcalaTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);207191208 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;192 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;209 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;193 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;215 console.log('[Unique -> Acala] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));199 console.log('[Unique -> Acala] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));216 expect(acaFees == 0n).to.be.true;200 expect(acaFees == 0n).to.be.true;217 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;201 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;218 },202 });219 acalaOptions(),220 );221 });203 });222204223 it('Should connect to Acala and send UNQ back', async () => {205 itSub('Should connect to Acala and send UNQ back', async ({helper}) => {224206225 // Acala side207 // Acala side226 await usingApi(208 await usingPlaygrounds.atUrl(acalaUrl, async (helper) => {227 async (api) => {228 const destination = {209 const destination = {229 V1: {210 V1: {230 parents: 1,211 parents: 1,248229249 const destWeight = 50000000;230 const destWeight = 50000000;250231232 // TODO251 const tx = api.tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);233 const tx = helper.getApi().tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);252 const events = await submitTransactionAsync(randomAccount, tx);234 const events = await submitTransactionAsync(randomAccount, tx);253 const result = getGenericResult(events);235 const result = getGenericResult(events);254 expect(result.success).to.be.true;236 expect(result.success).to.be.true;255237238 // [balanceAcalaTokenFinal] = await getBalance(api, [randomAccount.address]);256 [balanceAcalaTokenFinal] = await getBalance(api, [randomAccount.address]);239 balanceAcalaTokenFinal = await helper.balance.getSubstrate(randomAccount.address);257 {240 {241 // TODO258 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, id)).toJSON() as any;242 const {free} = (await helper.getApi().query.tokens.accounts(randomAccount.addressRaw, id)).toJSON() as any;259 balanceUniqueForeignTokenFinal = BigInt(free);243 balanceUniqueForeignTokenFinal = BigInt(free);260 }244 }261245270254271 expect(acaFees > 0).to.be.true;255 expect(acaFees > 0).to.be.true;272 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;256 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;273 },257 });274 acalaOptions(),258275 );259 // await waitNewBlocks(api, 3);276277 // Unique side278 await usingApi(async (api) => {279 await waitNewBlocks(api, 3);260 await helper.wait.newBlocks(3);280261262 // [balanceUniqueTokenFinal] = await getBalance(api, [randomAccount.address]);281 [balanceUniqueTokenFinal] = await getBalance(api, [randomAccount.address]);263 balanceUniqueTokenFinal = await helper.balance.getSubstrate(randomAccount.address);282 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;264 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;283 expect(actuallyDelivered > 0).to.be.true;265 expect(actuallyDelivered > 0).to.be.true;284266287 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;269 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;288 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));270 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));289 expect(unqFees == 0n).to.be.true;271 expect(unqFees == 0n).to.be.true;290 });291 });272 });292});273});293274294// These tests are relevant only when the foreign asset pallet is disabled275// These tests are relevant only when the foreign asset pallet is disabled295describe_xcm('[XCM] Integration test: Unique rejects non-native tokens', () => {276describeXcm('[XCM] Integration test: Unique rejects non-native tokens', () => {296 let alice: IKeyringPair;277 let alice: IKeyringPair;297278298 before(async () => {279 before(async () => {299 await usingApi(async (api, privateKeyWrapper) => {280 await usingPlaygrounds(async (_helper, privateKey) => {300 alice = privateKeyWrapper('//Alice');281 alice = privateKey('//Alice');301 });282 });302 });283 });303284304 it('Unique rejects tokens from the Relay', async () => {285 itSub('Unique rejects tokens from the Relay', async ({helper}) => {305 await usingApi(async (api) => {286 await usingPlaygrounds.atUrl(relayUrl, async (helper) => {306 const destination = {287 const destination = {307 V1: {288 V1: {308 parents: 0,289 parents: 0,346 Limited: 5_000_000_000,327 Limited: 5_000_000_000,347 };328 };348329330 // TODO349 const tx = api.tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);331 const tx = helper.getApi().tx.xcmPallet.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);350 const events = await submitTransactionAsync(alice, tx);332 const events = await submitTransactionAsync(alice, tx);351 const result = getGenericResult(events);333 const result = getGenericResult(events);352 expect(result.success).to.be.true;334 expect(result.success).to.be.true;353 }, relayOptions());335 });354336355 await usingApi(async api => {356 const maxWaitBlocks = 3;337 const maxWaitBlocks = 3;338339 // TODO357 const dmpQueueExecutedDownward = await waitEvent(340 const dmpQueueExecutedDownward = await waitEvent(358 api,341 helper.getApi(),359 maxWaitBlocks,342 maxWaitBlocks,360 'dmpQueue',343 'dmpQueue',361 'ExecutedDownward',344 'ExecutedDownward',379 incomplete[1].toString() == 'AssetNotFound',362 incomplete[1].toString() == 'AssetNotFound',380 '[Relay] The XCM error should be `AssetNotFound`',363 '[Relay] The XCM error should be `AssetNotFound`',381 ).to.be.true;364 ).to.be.true;382 });383 });365 });384366385 it('Unique rejects ACA tokens from Acala', async () => {367 itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {386 await usingApi(async (api) => {368 await usingPlaygrounds.atUrl(acalaUrl, async (helper) => {387 const destination = {369 const destination = {388 V1: {370 V1: {389 parents: 1,371 parents: 1,407389408 const destWeight = 50000000;390 const destWeight = 50000000;409391392 // TODO410 const tx = api.tx.xTokens.transfer(id as any, 100_000_000_000, destination, destWeight);393 const tx = helper.getApi().tx.xTokens.transfer(id as any, 100_000_000_000, destination, destWeight);411 const events = await submitTransactionAsync(alice, tx);394 const events = await submitTransactionAsync(alice, tx);412 const result = getGenericResult(events);395 const result = getGenericResult(events);413 expect(result.success).to.be.true;396 expect(result.success).to.be.true;414 }, acalaOptions());397 });415398416 await usingApi(async api => {417 const maxWaitBlocks = 3;399 const maxWaitBlocks = 3;400401 // TODO418 const xcmpQueueFailEvent = await waitEvent(api, maxWaitBlocks, 'xcmpQueue', 'Fail');402 const xcmpQueueFailEvent = await waitEvent(helper.getApi(), maxWaitBlocks, 'xcmpQueue', 'Fail');419403420 expect(404 expect(421 xcmpQueueFailEvent != null,405 xcmpQueueFailEvent != null,429 outcome.isUntrustedReserveLocation,413 outcome.isUntrustedReserveLocation,430 '[Acala] The XCM error should be `UntrustedReserveLocation`',414 '[Acala] The XCM error should be `UntrustedReserveLocation`',431 ).to.be.true;415 ).to.be.true;432 });433 });416 });434});417});435418436describe_xcm('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {419describeXcm('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {437420438 // Unique constants421 // Unique constants439 let uniqueAlice: IKeyringPair;422 let uniqueAlice: IKeyringPair;478 let balanceGlmrTokenFinal: bigint;461 let balanceGlmrTokenFinal: bigint;479462480 before(async () => {463 before(async () => {481 await usingApi(async (api, privateKeyWrapper) => {464 await usingPlaygrounds(async (_helper, privateKey) => {482 const keyringEth = new Keyring({type: 'ethereum'});465 const keyringEth = new Keyring({type: 'ethereum'});483 const keyringSr25519 = new Keyring({type: 'sr25519'});466 const keyringSr25519 = new Keyring({type: 'sr25519'});484467485 uniqueAlice = privateKeyWrapper('//Alice');468 uniqueAlice = privateKey('//Alice');486 randomAccountUnique = generateKeyringPair(keyringSr25519);469 randomAccountUnique = generateKeyringPair(keyringSr25519);487 randomAccountMoonbeam = generateKeyringPair(keyringEth);470 randomAccountMoonbeam = generateKeyringPair(keyringEth);488471489 balanceForeignUnqTokenInit = 0n;472 balanceForeignUnqTokenInit = 0n;490 });473 });491474492 await usingApi(475 await usingPlaygrounds.atUrl(moonbeamUrl, async (helper) => {493 async (api) => {476 // TODO477478 const api = helper.getApi();494479495 // >>> Sponsoring Dorothy >>>480 // >>> Sponsoring Dorothy >>>496 console.log('Sponsoring Dorothy.......');481 console.log('Sponsoring Dorothy.......');482 // const tx0 = api.tx.balances.transfer(dorothyAccount.address, 11_000_000_000_000_000_000n);483 // const events0 = await submitTransactionAsync(alithAccount, tx0);484 // const result0 = getGenericResult(events0);485 // expect(result0.success).to.be.true;497 const tx0 = api.tx.balances.transfer(dorothyAccount.address, 11_000_000_000_000_000_000n);486 await helper.balance.transferToSubstrate(alithAccount, dorothyAccount.address, 11_000_000_000_000_000_000n);498 const events0 = await submitTransactionAsync(alithAccount, tx0);499 const result0 = getGenericResult(events0);500 expect(result0.success).to.be.true;501 console.log('Sponsoring Dorothy.......DONE');487 console.log('Sponsoring Dorothy.......DONE');502 // <<< Sponsoring Dorothy <<<488 // <<< Sponsoring Dorothy <<<503489636 console.log('Acquire Unique AssetId Info on Moonbeam.......');622 console.log('Acquire Unique AssetId Info on Moonbeam.......');637623638 // Wait for the democracy execute624 // Wait for the democracy execute625 // await waitNewBlocks(api, 5);639 await waitNewBlocks(api, 5);626 await helper.wait.newBlocks(5);640627641 assetId = (await api.query.assetManager.assetTypeId({628 assetId = (await api.query.assetManager.assetTypeId({642 XCM: sourceLocation,629 XCM: sourceLocation,648635649 // >>> Sponsoring random Account >>>636 // >>> Sponsoring random Account >>>650 console.log('Sponsoring random Account.......');637 console.log('Sponsoring random Account.......');638 // const tx10 = api.tx.balances.transfer(randomAccountMoonbeam.address, 11_000_000_000_000_000_000n);639 // const events10 = await submitTransactionAsync(baltatharAccount, tx10);640 // const result10 = getGenericResult(events10);641 // expect(result10.success).to.be.true;651 const tx10 = api.tx.balances.transfer(randomAccountMoonbeam.address, 11_000_000_000_000_000_000n);642 await helper.balance.transferToSubstrate(baltatharAccount, randomAccountMoonbeam.address, 11_000_000_000_000_000_000n);652 const events10 = await submitTransactionAsync(baltatharAccount, tx10);653 const result10 = getGenericResult(events10);654 expect(result10.success).to.be.true;655 console.log('Sponsoring random Account.......DONE');643 console.log('Sponsoring random Account.......DONE');656 // <<< Sponsoring random Account <<<644 // <<< Sponsoring random Account <<<657645658 [balanceGlmrTokenInit] = await getBalance(api, [randomAccountMoonbeam.address]);646 [balanceGlmrTokenInit] = await getBalance(api, [randomAccountMoonbeam.address]);659 },647 });660 moonbeamOptions(),661 );662648663 await usingApi(async (api) => {649 await usingPlaygrounds(async (helper) => {650 // const tx0 = api.tx.balances.transfer(randomAccountUnique.address, 10n * TRANSFER_AMOUNT);651 // const events0 = await submitTransactionAsync(uniqueAlice, tx0);652 // const result0 = getGenericResult(events0);653 // expect(result0.success).to.be.true;664 const tx0 = api.tx.balances.transfer(randomAccountUnique.address, 10n * TRANSFER_AMOUNT);654 await helper.balance.transferToSubstrate(uniqueAlice, randomAccountUnique.address, 10n * TRANSFER_AMOUNT);665 const events0 = await submitTransactionAsync(uniqueAlice, tx0);655666 const result0 = getGenericResult(events0);656 // [balanceUniqueTokenInit] = await getBalance(api, [randomAccountUnique.address]);667 expect(result0.success).to.be.true;668669 [balanceUniqueTokenInit] = await getBalance(api, [randomAccountUnique.address]);657 balanceUniqueTokenInit = await helper.balance.getSubstrate(randomAccountUnique.address);670 });658 });671 });659 });672660673 it('Should connect and send UNQ to Moonbeam', async () => {661 itSub('Should connect and send UNQ to Moonbeam', async ({helper}) => {674 await usingApi(async (api) => {675 const currencyId = {662 const currencyId = {676 NativeAssetId: 'Here',663 NativeAssetId: 'Here',677 };664 };689 const amount = TRANSFER_AMOUNT;676 const amount = TRANSFER_AMOUNT;690 const destWeight = 850000000;677 const destWeight = 850000000;691678679 // TODO692 const tx = api.tx.xTokens.transfer(currencyId, amount, dest, destWeight);680 const tx = helper.getApi().tx.xTokens.transfer(currencyId, amount, dest, destWeight);693 const events = await submitTransactionAsync(randomAccountUnique, tx);681 const events = await submitTransactionAsync(randomAccountUnique, tx);694 const result = getGenericResult(events);682 const result = getGenericResult(events);695 expect(result.success).to.be.true;683 expect(result.success).to.be.true;696684685 // [balanceUniqueTokenMiddle] = await getBalance(api, [randomAccountUnique.address]);697 [balanceUniqueTokenMiddle] = await getBalance(api, [randomAccountUnique.address]);686 balanceUniqueTokenMiddle = await helper.balance.getSubstrate(randomAccountUnique.address);698 expect(balanceUniqueTokenMiddle < balanceUniqueTokenInit).to.be.true;687 expect(balanceUniqueTokenMiddle < balanceUniqueTokenInit).to.be.true;699688700 const transactionFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;689 const transactionFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;701 console.log('[Unique -> Moonbeam] transaction fees on Unique: %s UNQ', bigIntToDecimals(transactionFees));690 console.log('[Unique -> Moonbeam] transaction fees on Unique: %s UNQ', bigIntToDecimals(transactionFees));702 expect(transactionFees > 0).to.be.true;691 expect(transactionFees > 0).to.be.true;703 });704692705 await usingApi(693 await usingPlaygrounds.atUrl(moonbeamUrl, async (helper) => {706 async (api) => {694 // await waitNewBlocks(api, 3);707 await waitNewBlocks(api, 3);695 await helper.wait.newBlocks(3);708696697 // [balanceGlmrTokenMiddle] = await getBalance(api, [randomAccountMoonbeam.address]);709 [balanceGlmrTokenMiddle] = await getBalance(api, [randomAccountMoonbeam.address]);698 balanceGlmrTokenMiddle = await helper.balance.getSubstrate(randomAccountMoonbeam.address);710699711 const glmrFees = balanceGlmrTokenInit - balanceGlmrTokenMiddle;700 const glmrFees = balanceGlmrTokenInit - balanceGlmrTokenMiddle;712 console.log('[Unique -> Moonbeam] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));701 console.log('[Unique -> Moonbeam] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));713 expect(glmrFees == 0n).to.be.true;702 expect(glmrFees == 0n).to.be.true;714703704 // TODO715 const unqRandomAccountAsset = (705 const unqRandomAccountAsset = (716 await api.query.assets.account(assetId, randomAccountMoonbeam.address)706 await helper.getApi().query.assets.account(assetId, randomAccountMoonbeam.address)717 ).toJSON()! as any;707 ).toJSON()! as any;718708719 balanceForeignUnqTokenMiddle = BigInt(unqRandomAccountAsset['balance']);709 balanceForeignUnqTokenMiddle = BigInt(unqRandomAccountAsset['balance']);720 const unqIncomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenInit;710 const unqIncomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenInit;721 console.log('[Unique -> Moonbeam] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));711 console.log('[Unique -> Moonbeam] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));722 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;712 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;723 },713 });724 moonbeamOptions(),725 );726 });714 });727715728 it('Should connect to Moonbeam and send UNQ back', async () => {716 itSub('Should connect to Moonbeam and send UNQ back', async ({helper}) => {729 await usingApi(717 await usingPlaygrounds.atUrl(moonbeamUrl, async (helper) => {730 async (api) => {731 const asset = {718 const asset = {732 V1: {719 V1: {733 id: {720 id: {756 };743 };757 const destWeight = 50000000;744 const destWeight = 50000000;758745746 // TODO759 const tx = api.tx.xTokens.transferMultiasset(asset, destination, destWeight);747 const tx = helper.getApi().tx.xTokens.transferMultiasset(asset, destination, destWeight);760 const events = await submitTransactionAsync(randomAccountMoonbeam, tx);748 const events = await submitTransactionAsync(randomAccountMoonbeam, tx);761 const result = getGenericResult(events);749 const result = getGenericResult(events);762 expect(result.success).to.be.true;750 expect(result.success).to.be.true;763751752 // [balanceGlmrTokenFinal] = await getBalance(api, [randomAccountMoonbeam.address]);764 [balanceGlmrTokenFinal] = await getBalance(api, [randomAccountMoonbeam.address]);753 balanceGlmrTokenFinal = await helper.balance.getSubstrate(randomAccountMoonbeam.address);765754766 const glmrFees = balanceGlmrTokenMiddle - balanceGlmrTokenFinal;755 const glmrFees = balanceGlmrTokenMiddle - balanceGlmrTokenFinal;767 console.log('[Moonbeam -> Unique] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));756 console.log('[Moonbeam -> Unique] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));768 expect(glmrFees > 0).to.be.true;757 expect(glmrFees > 0).to.be.true;769758759 // TODO770 const unqRandomAccountAsset = (760 const unqRandomAccountAsset = (771 await api.query.assets.account(assetId, randomAccountMoonbeam.address)761 await helper.getApi().query.assets.account(assetId, randomAccountMoonbeam.address)772 ).toJSON()! as any;762 ).toJSON()! as any;773763774 expect(unqRandomAccountAsset).to.be.null;764 expect(unqRandomAccountAsset).to.be.null;778 const unqOutcomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenFinal;768 const unqOutcomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenFinal;779 console.log('[Unique -> Moonbeam] outcome %s UNQ', bigIntToDecimals(unqOutcomeTransfer));769 console.log('[Unique -> Moonbeam] outcome %s UNQ', bigIntToDecimals(unqOutcomeTransfer));780 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;770 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;781 },771 });782 moonbeamOptions(),772783 );773 // await waitNewBlocks(api, 3);784785 await usingApi(async (api) => {786 await waitNewBlocks(api, 3);774 await helper.wait.newBlocks(3);787775776 // [balanceUniqueTokenFinal] = await getBalance(api, [randomAccountUnique.address]);788 [balanceUniqueTokenFinal] = await getBalance(api, [randomAccountUnique.address]);777 balanceUniqueTokenFinal = await helper.balance.getSubstrate(randomAccountUnique.address);789 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;778 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;790 expect(actuallyDelivered > 0).to.be.true;779 expect(actuallyDelivered > 0).to.be.true;791780794 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;783 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;795 console.log('[Moonbeam -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));784 console.log('[Moonbeam -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));796 expect(unqFees == 0n).to.be.true;785 expect(unqFees == 0n).to.be.true;797 });798 });786 });799});787});800788