difftreelog
tests(parallel): fix phantom errors
in: master
7 files changed
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -227,7 +227,7 @@
});
});
-describe('Approved amount decreases by the transferred amount.:', () => {
+describe('Approved amount decreases by the transferred amount:', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';1920async function setSponsorHelper(collection: any, signer: IKeyringPair, sponsorAddress: string) {21 await collection.setSponsor(signer, sponsorAddress);22 const raw = (await collection.getData())?.raw;23 expect(raw.sponsorship.Unconfirmed).to.be.equal(sponsorAddress);24}2526async function confirmSponsorHelper(collection: any, signer: IKeyringPair) {27 await collection.confirmSponsorship(signer);28 const raw = (await collection.getData())?.raw;29 expect(raw.sponsorship.Confirmed).to.be.equal(signer.address);30}3132describe('integration test: ext. confirmSponsorship():', () => {33 let alice: IKeyringPair;34 let bob: IKeyringPair;35 let charlie: IKeyringPair;36 let zeroBalance: IKeyringPair;3738 before(async () => {39 await usingPlaygrounds(async (helper, privateKey) => {40 const donor = await privateKey({filename: __filename});41 [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);42 });43 });4445 itSub('Confirm collection sponsorship', async ({helper}) => {46 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});47 await setSponsorHelper(collection, alice, bob.address);48 await confirmSponsorHelper(collection, bob);49 });5051 itSub('Add sponsor to a collection after the same sponsor was already added and confirmed', async ({helper}) => {52 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});53 await setSponsorHelper(collection, alice, bob.address);54 await confirmSponsorHelper(collection, bob);55 await setSponsorHelper(collection, alice, bob.address);56 });57 itSub('Add new sponsor to a collection after another sponsor was already added and confirmed', async ({helper}) => {58 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});59 await setSponsorHelper(collection, alice, bob.address);60 await confirmSponsorHelper(collection, bob);61 await setSponsorHelper(collection, alice, charlie.address);62 });6364 itSub('NFT: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {65 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});66 await collection.setSponsor(alice, bob.address);67 await collection.confirmSponsorship(bob);68 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);69 const token = await collection.mintToken(alice, {Substrate: zeroBalance.address});70 await token.transfer(zeroBalance, {Substrate: alice.address});71 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);72 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;73 });7475 itSub('Fungible: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {76 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);77 await collection.setSponsor(alice, bob.address);78 await collection.confirmSponsorship(bob);79 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);80 await collection.mint(alice, 100n, {Substrate: zeroBalance.address});81 await collection.transfer(zeroBalance, {Substrate: alice.address}, 1n);82 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);83 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;84 });8586 itSub.ifWithPallets('ReFungible: Transfer fees are paid by the sponsor after confirmation', [Pallets.ReFungible], async ({helper}) => {87 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});88 await collection.setSponsor(alice, bob.address);89 await collection.confirmSponsorship(bob);90 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);91 const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});92 await token.transfer(zeroBalance, {Substrate: alice.address}, 1n);93 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);94 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;95 });9697 itSub('CreateItem fees are paid by the sponsor after confirmation', async ({helper}) => {98 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});99 await collection.setSponsor(alice, bob.address);100 await collection.confirmSponsorship(bob);101 await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});102 await collection.addToAllowList(alice, {Substrate: zeroBalance.address});103104 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);105 await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});106 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);107108 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;109 });110111 itSub('NFT: Sponsoring of transfers is rate limited', async ({helper}) => {112 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL', limits: {113 sponsorTransferTimeout: 1000,114 }});115 await collection.setSponsor(alice, bob.address);116 await collection.confirmSponsorship(bob);117118 const token = await collection.mintToken(alice, {Substrate: alice.address});119 await token.transfer(alice, {Substrate: zeroBalance.address});120 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);121122 const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});123 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');124 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);125126 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;127 });128129 itSub('Fungible: Sponsoring is rate limited', async ({helper}) => {130 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL', limits: {131 sponsorTransferTimeout: 1000,132 }});133 await collection.setSponsor(alice, bob.address);134 await collection.confirmSponsorship(bob);135136 await collection.mint(alice, 100n, {Substrate: zeroBalance.address});137 await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);138 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);139140 const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});141 await expect(transferTx()).to.be.rejected;142 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);143144 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;145 });146147 itSub.ifWithPallets('ReFungible: Sponsoring is rate limited', [Pallets.ReFungible], async ({helper}) => {148 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL', limits: {149 sponsorTransferTimeout: 1000,150 }});151 await collection.setSponsor(alice, bob.address);152 await collection.confirmSponsorship(bob);153154 const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});155 await token.transfer(zeroBalance, {Substrate: alice.address});156157 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);158 const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});159 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');160 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);161162 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;163 });164165 itSub('NFT: Sponsoring of createItem is rate limited', async ({helper}) => {166 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});167 await collection.setSponsor(alice, bob.address);168 await collection.confirmSponsorship(bob);169 await collection.setPermissions(alice, {mintMode: true, access: 'AllowList'});170 await collection.addToAllowList(alice, {Substrate: zeroBalance.address});171172 await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});173174 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);175 const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});176 await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');177 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);178179 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;180 });181});182183describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {184 let alice: IKeyringPair;185 let bob: IKeyringPair;186 let charlie: IKeyringPair;187 let ownerZeroBalance: IKeyringPair;188 let senderZeroBalance: IKeyringPair;189190 before(async () => {191 await usingPlaygrounds(async (helper, privateKey) => {192 const donor = await privateKey({filename: __filename});193 [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);194 });195 });196197 itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {198 const collectionId = 1_000_000;199 const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);200 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);201 });202203 itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {204 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});205 await collection.setSponsor(alice, bob.address);206 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);207 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);208 });209210 itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {211 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});212 await collection.setSponsor(alice, bob.address);213 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);214 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);215 });216217 itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {218 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});219 await collection.setSponsor(alice, bob.address);220 await collection.addAdmin(alice, {Substrate: charlie.address});221 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);222 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);223 });224225 itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {226 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});227 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);228 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);229 });230231 itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {232 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});233 await collection.burn(alice);234 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);235 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);236 });237238 itSub('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async ({helper}) => {239 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});240 await collection.setSponsor(alice, bob.address);241 await collection.confirmSponsorship(bob);242 const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});243 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);244 const transferTx = async () => token.transfer(senderZeroBalance, {Substrate: alice.address});245 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');246 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);247 expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);248 });249});tests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth--- a/tests/src/deprecated-helpers/helpers.ts
+++ b/tests/src/deprecated-helpers/helpers.ts
@@ -1764,11 +1764,11 @@
return (await api.rpc.unique.collectionById(collectionId)).unwrap();
}
-/*export const describe_xcm = (
+export const describeXCM = (
process.env.RUN_XCM_TESTS
? describe
: describe.skip
-);*/
+);
export async function waitNewBlocks(blocksCount = 1): Promise<void> {
await usingApi(async (api) => {
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -62,7 +62,7 @@
.to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);
});
- itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper}) => {
+ itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {
const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
@@ -212,7 +212,8 @@
const token = await collection.mintToken(alice, 100n);
await token.repartition(alice, 200n);
const chainEvents = helper.chainLog.slice(-1)[0].events;
- expect(chainEvents).to.deep.include({
+ const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemCreated');
+ expect(event).to.deep.include({
section: 'common',
method: 'ItemCreated',
index: [66, 2],
@@ -222,7 +223,6 @@
{substrate: alice.address},
100n,
],
- phase: {applyExtrinsic: 2},
});
});
@@ -231,9 +231,10 @@
const token = await collection.mintToken(alice, 100n);
await token.repartition(alice, 50n);
const chainEvents = helper.chainLog.slice(-1)[0].events;
- expect(chainEvents).to.deep.include({
+ const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemDestroyed');
+ expect(event).to.deep.include({
+ section: 'common',
method: 'ItemDestroyed',
- section: 'common',
index: [66, 3],
data: [
collection.collectionId,
@@ -241,7 +242,6 @@
{substrate: alice.address},
50n,
],
- phase: {applyExtrinsic: 2},
});
});
tests/src/xcm/xcmOpal.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmOpal.test.ts
+++ b/tests/src/xcm/xcmOpal.test.ts
@@ -21,7 +21,7 @@
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 {bigIntToDecimals, describeXCM, getGenericResult, paraSiblingSovereignAccount, normalizeAccountId} from './../deprecated-helpers/helpers';
import waitNewBlocks from './../substrate/wait-new-blocks';
import getBalance from './../substrate/get-balance';
@@ -49,7 +49,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;
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -21,7 +21,7 @@
import {ApiOptions} from '@polkadot/api/types';
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 {getGenericResult, generateKeyringPair, waitEvent, describeXCM, bigIntToDecimals} from '../deprecated-helpers/helpers';
import {MultiLocation} from '@polkadot/types/interfaces';
import {blake2AsHex} from '@polkadot/util-crypto';
import waitNewBlocks from '../substrate/wait-new-blocks';
@@ -61,7 +61,7 @@
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;
@@ -292,7 +292,7 @@
});
// 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 () => {
@@ -433,7 +433,7 @@
});
});
-describe_xcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
+describeXCM('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
// Quartz constants
let quartzAlice: IKeyringPair;
tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -21,7 +21,7 @@
import {ApiOptions} from '@polkadot/api/types';
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 {getGenericResult, generateKeyringPair, waitEvent, describeXCM, bigIntToDecimals} from '../deprecated-helpers/helpers';
import {MultiLocation} from '@polkadot/types/interfaces';
import {blake2AsHex} from '@polkadot/util-crypto';
import waitNewBlocks from '../substrate/wait-new-blocks';
@@ -61,7 +61,7 @@
return parachainApiOptions(RELAY_PORT);
}
-describe_xcm('[XCM] Integration test: Exchanging tokens with Acala', () => {
+describeXCM('[XCM] Integration test: Exchanging tokens with Acala', () => {
let alice: IKeyringPair;
let randomAccount: IKeyringPair;
@@ -292,7 +292,7 @@
});
// These tests are relevant only when the foreign asset pallet is disabled
-describe_xcm('[XCM] Integration test: Unique rejects non-native tokens', () => {
+describeXCM('[XCM] Integration test: Unique rejects non-native tokens', () => {
let alice: IKeyringPair;
before(async () => {
@@ -433,7 +433,7 @@
});
});
-describe_xcm('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {
+describeXCM('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {
// Unique constants
let uniqueAlice: IKeyringPair;