git.delta.rocks / unique-network / refs/commits / da0f86127809

difftreelog

test run eslint --fix

Yaroslav Bolyukin2023-05-30parent: #833ab94.patch.diff
in: master

20 files changed

modifiedtests/src/benchmarks/mintFee/index.tsdiffbeforeafterboth
222 await collection.mintToken(222 await collection.mintToken(
223 donor,223 donor,
224 {Substrate: susbstrateReceiver.address},224 {Substrate: susbstrateReceiver.address},
225 PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {225 PROPERTIES.slice(0, setup.propertiesNumber).map((p) => ({key: p.key, value: Buffer.from(p.value).toString()})),
226 return {key: p.key, value: Buffer.from(p.value).toString()};
227 }),
228 );226 );
229 },227 },
modifiedtests/src/benchmarks/opsFee/index.tsdiffbeforeafterboth
379 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(379 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
380 {Substrate: donor.address},380 {Substrate: donor.address},
381 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)381 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)
382 .map(p => { return {key: p.key, value: p.value.toString()}; })),382 .map(p => ({key: p.key, value: p.value.toString()}))),
383 )));383 )));
384384
385 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(385 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
755 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(755 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
756 {Substrate: donor.address},756 {Substrate: donor.address},
757 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)757 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)
758 .map(p => { return {key: p.key, value: p.value.toString()}; })),758 .map(p => ({key: p.key, value: p.value.toString()}))),
759 )));759 )));
760760
761 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(761 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
modifiedtests/src/benchmarks/utils/common.tsdiffbeforeafterboth
55
6export const PROPERTIES = Array(40)6export const PROPERTIES = Array(40)
7 .fill(0)7 .fill(0)
8 .map((_, i) => {8 .map((_, i) => ({
9 return {
10 key: `key_${i}`,9 key: `key_${i}`,
11 value: Uint8Array.from(Buffer.from(`value_${i}`)),10 value: Uint8Array.from(Buffer.from(`value_${i}`)),
12 };
13 });11 }));
1412
15export const SUBS_PROPERTIES = Array(40)13export const SUBS_PROPERTIES = Array(40)
16 .fill(0)14 .fill(0)
17 .map((_, i) => {15 .map((_, i) => ({
18 return {
19 key: `key_${i}`,16 key: `key_${i}`,
20 value: `value_${i}`,17 value: `value_${i}`,
21 };
22 });18 }));
2319
24export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => {20export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => ({
25 return {
26 key: p.key,21 key: p.key,
27 permission: {22 permission: {
28 tokenOwner: true,23 tokenOwner: true,
29 collectionAdmin: true,24 collectionAdmin: true,
30 mutable: true,25 mutable: true,
31 },26 },
32 };
33});27}));
3428
35export function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {29export function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {
36 return Number((value * 1000n) / nominal) / 1000;30 return Number((value * 1000n) / nominal) / 1000;
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
7676
77 // 2. Expect methods.collectionAdmins == api.rpc.unique.adminlist77 // 2. Expect methods.collectionAdmins == api.rpc.unique.adminlist
78 let adminListEth = await collectionEvm.methods.collectionAdmins().call();78 let adminListEth = await collectionEvm.methods.collectionAdmins().call();
79 adminListEth = adminListEth.map((element: IEthCrossAccountId) => {79 adminListEth = adminListEth.map((element: IEthCrossAccountId) => helper.address.convertCrossAccountFromEthCrossAccount(element));
80 return helper.address.convertCrossAccountFromEthCrossAccount(element);
81 });
82 expect(adminListRpc).to.be.like(adminListEth);80 expect(adminListRpc).to.be.like(adminListEth);
8381
84 // 3. check isOwnerOrAdminCross returns true:82 // 3. check isOwnerOrAdminCross returns true:
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
181 const propertyPermissions = data2?.raw.tokenPropertyPermissions;181 const propertyPermissions = data2?.raw.tokenPropertyPermissions;
182 expect(propertyPermissions?.length).to.equal(2);182 expect(propertyPermissions?.length).to.equal(2);
183183
184 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {184 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;
185 return tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
186 })).to.be.not.null;
187185
188 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {186 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;
189 return tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;
190 })).to.be.not.null;
191187
192 expect(data2?.raw.properties?.find((property: IProperty) => {188 expect(data2?.raw.properties?.find((property: IProperty) => property.key === 'baseURI' && property.value === BASE_URI)).to.be.not.null;
193 return property.key === 'baseURI' && property.value === BASE_URI;
194 })).to.be.not.null;
195189
196 const token1Result = await contract.methods.mint(bruh).send();190 const token1Result = await contract.methods.mint(bruh).send();
197 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;191 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;
modifiedtests/src/eth/evmCoder.test.tsdiffbeforeafterboth
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import {itEth, expect, usingEthPlaygrounds} from './util';18import {itEth, expect, usingEthPlaygrounds} from './util';
1919
20const getContractSource = (collectionAddress: string, contractAddress: string): string => {20const getContractSource = (collectionAddress: string, contractAddress: string): string => `
21 return `21 // SPDX-License-Identifier: MIT
22 // SPDX-License-Identifier: MIT22 pragma solidity ^0.8.0;
23 pragma solidity ^0.8.0;23 interface ITest {
24 interface ITest {24 function ztestzzzzzzz() external returns (uint256 n);
50 ITest(${collectionAddress}).ztestzzzzzzz();50 }
51 }51 }
52 }52 `;
53 `;
54};
5553
5654
57describe('Evm Coder tests', () => {55describe('Evm Coder tests', () => {
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
102 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);102 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);
103103
104 // const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);104 // const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);
105 const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });105 const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
106 const permissions: ITokenPropertyPermission[] = properties106 const permissions: ITokenPropertyPermission[] = properties
107 .map(p => {107 .map(p => ({
108 return {
109 key: p.key, permission: {108 key: p.key, permission: {
110 tokenOwner: false,109 tokenOwner: false,
111 collectionAdmin: true,110 collectionAdmin: true,
112 mutable: false,111 mutable: false,
113 },112 },
114 };
115 });113 }));
116114
117 const collection = await helper.nft.mintCollection(minter, {115 const collection = await helper.nft.mintCollection(minter, {
118 tokenPrefix: 'ethp',116 tokenPrefix: 'ethp',
146 expect(tokenId).to.be.equal(expectedTokenId);144 expect(tokenId).to.be.equal(expectedTokenId);
147145
148 expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties146 expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
149 .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));147 .map(p => helper.ethProperty.property(p.key, p.value.toString())));
150148
151 expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))149 expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))
152 .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});150 .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
46 const receiverSub = bob;46 const receiverSub = bob;
47 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);47 const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);
4848
49 const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });49 const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
50 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {50 const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {
51 tokenOwner: false,51 tokenOwner: false,
52 collectionAdmin: true,52 collectionAdmin: true,
53 mutable: false}};53 mutable: false}}));
54 });
5554
5655
86 expect(tokenId).to.be.equal(expectedTokenId);85 expect(tokenId).to.be.equal(expectedTokenId);
8786
88 expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties87 expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
89 .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));88 .map(p => helper.ethProperty.property(p.key, p.value.toString())));
9089
91 expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))90 expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))
92 .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});91 .to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
241 itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {241 itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {
242 const caller = await helper.eth.createAccountWithBalance(donor);242 const caller = await helper.eth.createAccountWithBalance(donor);
243243
244 const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });244 const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
245 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,245 const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {tokenOwner: true,
246 collectionAdmin: true,246 collectionAdmin: true,
247 mutable: true}}; });247 mutable: true}}));
248248
249 const collection = await helper[testCase.mode].mintCollection(alice, {249 const collection = await helper[testCase.mode].mintCollection(alice, {
250 tokenPrefix: 'ethp',250 tokenPrefix: 'ethp',
267 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});267 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
268268
269 const values = await token.getProperties(properties.map(p => p.key));269 const values = await token.getProperties(properties.map(p => p.key));
270 expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));270 expect(values).to.be.deep.equal(properties.map(p => ({key: p.key, value: p.value.toString()})));
271271
272 expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties272 expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties
273 .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));273 .map(p => helper.ethProperty.property(p.key, p.value.toString())));
274274
275 expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())275 expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())
276 .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);276 .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);
modifiedtests/src/fungible.test.tsdiffbeforeafterboth
4646
47 itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper}) => {47 itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper}) => {
48 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};48 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
49 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});49 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
5050
51 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});51 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
5252
modifiedtests/src/getPropertiesRpc.test.tsdiffbeforeafterboth
48describe('query properties RPC', () => {48describe('query properties RPC', () => {
49 let alice: IKeyringPair;49 let alice: IKeyringPair;
5050
51 const mintCollection = async (helper: UniqueHelper) => {51 const mintCollection = async (helper: UniqueHelper) => await helper.nft.mintCollection(alice, {
52 return await helper.nft.mintCollection(alice, {
53 tokenPrefix: 'prps',52 tokenPrefix: 'prps',
54 properties: collectionProps,53 properties: collectionProps,
55 tokenPropertyPermissions: tokenPropPermissions,54 tokenPropertyPermissions: tokenPropPermissions,
56 });55 });
57 };
5856
59 const mintToken = async (collection: UniqueNFTCollection) => {57 const mintToken = async (collection: UniqueNFTCollection) => await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
60 return await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
61 };
6258
6359
64 before(async () => {60 before(async () => {
modifiedtests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth
44 async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {44 async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
45 const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {45 const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
46 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>46 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
47 signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),47 signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
48 });48 });
49 return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];49 return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
50 }50 }
201 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});201 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
202 const collectionB = await helper.nft.mintCollection(alice, {202 const collectionB = await helper.nft.mintCollection(alice, {
203 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>203 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
204 signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),204 signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
205 });205 });
206 const targetToken = await collectionA.mintToken(alice);206 const targetToken = await collectionA.mintToken(alice);
207 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());207 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
239 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});239 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
240 const collectionB = await helper.nft.mintCollection(alice, {240 const collectionB = await helper.nft.mintCollection(alice, {
241 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>241 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
242 signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),242 signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
243 });243 });
244 const targetToken = await collectionA.mintToken(alice);244 const targetToken = await collectionA.mintToken(alice);
245 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());245 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
284 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});284 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
285 const collectionB = await helper.nft.mintCollection(alice, {285 const collectionB = await helper.nft.mintCollection(alice, {
286 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>286 tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
287 signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),287 signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
288 });288 });
289 const targetToken = await collectionA.mintToken(alice);289 const targetToken = await collectionA.mintToken(alice);
290 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());290 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
477477
478 async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {478 async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
479 const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {479 const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
480 tokenPropertyPermissions: constitution.map(({permission}, i) => {return {key: `${i+1}`, permission};}),480 tokenPropertyPermissions: constitution.map(({permission}, i) => ({key: `${i+1}`, permission})),
481 });481 });
482 return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];482 return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
483 }483 }
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
6464
65 itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {65 itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {
66 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};66 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
67 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});67 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
6868
69 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});69 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
7070
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
40 // Set-up a few token owners of all stripes40 // Set-up a few token owners of all stripes
41 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};41 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
42 const facelessCrowd = (await helper.arrange.createAccounts([0n, 0n, 0n, 0n, 0n, 0n, 0n], donor))42 const facelessCrowd = (await helper.arrange.createAccounts([0n, 0n, 0n, 0n, 0n, 0n, 0n], donor))
43 .map(i => {return {Substrate: i.address};});43 .map(i => ({Substrate: i.address}));
4444
45 const collection = await helper.ft.mintCollection(alice, {name: 'RPC-2', tokenPrefix: 'RPC'});45 const collection = await helper.ft.mintCollection(alice, {name: 'RPC-2', tokenPrefix: 'RPC'});
46 // mint some maximum (u128) amounts of tokens possible46 // mint some maximum (u128) amounts of tokens possible
modifiedtests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
357 const stakers = await getAccounts(3);357 const stakers = await getAccounts(3);
358358
359 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));359 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
360 await Promise.all(stakers.map(staker => {360 await Promise.all(stakers.map(staker => testCase.method === 'unstakeAll'
361 return testCase.method === 'unstakeAll'
362 ? helper.staking.unstakeAll(staker)361 ? helper.staking.unstakeAll(staker)
363 : helper.staking.unstakePartial(staker, 100n * nominal);362 : helper.staking.unstakePartial(staker, 100n * nominal)));
364 }));
365363
366 await Promise.all(stakers.map(async (staker) => {364 await Promise.all(stakers.map(async (staker) => {
367 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(100n * nominal);365 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(100n * nominal);
375 const stakers = await getAccounts(10);373 const stakers = await getAccounts(10);
376374
377 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));375 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
378 const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => {376 const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => i % 2 === 0
379 return i % 2 === 0
380 ? helper.staking.unstakeAll(staker)377 ? helper.staking.unstakeAll(staker)
381 : helper.staking.unstakePartial(staker, 100n * nominal);378 : helper.staking.unstakePartial(staker, 100n * nominal)));
382 }));
383379
384 const successfulUnstakes = unstakingResults.filter(result => result.status === 'fulfilled');380 const successfulUnstakes = unstakingResults.filter(result => result.status === 'fulfilled');
385 expect(successfulUnstakes).to.have.length(3);381 expect(successfulUnstakes).to.have.length(3);
modifiedtests/src/util/index.tsdiffbeforeafterboth
19chai.use(chaiSubset);19chai.use(chaiSubset);
20export const expect = chai.expect;20export const expect = chai.expect;
2121
22const getTestHash = (filename: string) => {22const getTestHash = (filename: string) => crypto.createHash('md5').update(filename).digest('hex');
23 return crypto.createHash('md5').update(filename).digest('hex');
24};
2523
26export const getTestSeed = (filename: string) => {24export const getTestSeed = (filename: string) => `//Alice+${getTestHash(filename)}`;
27 return `//Alice+${getTestHash(filename)}`;
28};
2925
30async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {26async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {
31 const silentConsole = new SilentConsole();27 const silentConsole = new SilentConsole();
65 }61 }
66}62}
6763
68export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {64export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
69 return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
70};
7165
72export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {66export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
73 return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
74};
7567
76export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {68export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
77 return usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
78};
7969
80export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {70export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
81 return usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
82};
8371
84export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {72export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
85 return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
86};
8773
88export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {74export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
89 return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
90};
9175
92export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {76export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
93 return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
94};
9577
96export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {78export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
97 return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
98};
9979
100export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {80export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
101 return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
102};
10381
104export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {82export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
105 return usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
106};
10783
108export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {84export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
109 return usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
110};
11185
112export const MINIMUM_DONOR_FUND = 100_000n;86export const MINIMUM_DONOR_FUND = 100_000n;
113export const DONOR_FUNDING = 2_000_000n;87export const DONOR_FUNDING = 2_000_000n;
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
771 // <<< Referendum voting <<<771 // <<< Referendum voting <<<
772772
773 // Wait the proposal to pass773 // Wait the proposal to pass
774 await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => {774 await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => event.referendumIndex() == referendumIndex);
775 return event.referendumIndex() == referendumIndex;
776 });
777775
778 await this.helper.wait.newBlocks(1);776 await this.helper.wait.newBlocks(1);
779777
924 event<T extends IEventHelper>(922 event<T extends IEventHelper>(
925 maxBlocksToWait: number,923 maxBlocksToWait: number,
926 eventHelperType: new () => T,924 eventHelperType: new () => T,
927 filter: (_: T) => boolean = () => { return true; },925 filter: (_: T) => boolean = () => true,
928 ) {926 ) {
929 // eslint-disable-next-line no-async-promise-executor927 // eslint-disable-next-line no-async-promise-executor
930 const promise = new Promise<T | null>(async (resolve) => {928 const promise = new Promise<T | null>(async (resolve) => {
970 async expectEvent<T extends IEventHelper>(968 async expectEvent<T extends IEventHelper>(
971 maxBlocksToWait: number,969 maxBlocksToWait: number,
972 eventHelperType: new () => T,970 eventHelperType: new () => T,
973 filter: (e: T) => boolean = () => { return true; },971 filter: (e: T) => boolean = () => true,
974 ) {972 ) {
975 const e = await this.event(maxBlocksToWait, eventHelperType, filter);973 const e = await this.event(maxBlocksToWait, eventHelperType, filter);
976 if (e == null) {974 if (e == null) {
1077 async startCapture() {1075 async startCapture() {
1078 this.stopCapture();1076 this.stopCapture();
1079 this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {1077 this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {
1080 const newEvents = eventRecords.filter(r => {1078 const newEvents = eventRecords.filter(r => r.event.section == this.eventSection && r.event.method == this.eventMethod);
1081 return r.event.section == this.eventSection && r.event.method == this.eventMethod;
1082 });
10831079
1084 this.events.push(...newEvents);1080 this.events.push(...newEvents);
1085 })) as any;1081 })) as any;
11051101
1106 async payoutStakers(signer: IKeyringPair, stakersToPayout: number): Promise<{staker: string, stake: bigint, payout: bigint}[]> {1102 async payoutStakers(signer: IKeyringPair, stakersToPayout: number): Promise<{staker: string, stake: bigint, payout: bigint}[]> {
1107 const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);1103 const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);
1108 return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {1104 return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => ({
1109 return {
1110 staker: e.event.data[0].toString(),1105 staker: e.event.data[0].toString(),
1111 stake: e.event.data[1].toBigInt(),1106 stake: e.event.data[1].toBigInt(),
1112 payout: e.event.data[2].toBigInt(),1107 payout: e.event.data[2].toBigInt(),
1113 };
1114 });1108 }));
1115 }1109 }
1116}1110}
11171111
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
2395 return total.toBigInt();2395 return total.toBigInt();
2396 }2396 }
23972397
2398 async getLocked(address: TSubstrateAccount): Promise<[{ id: string, amount: bigint, reason: string }]> {2398 async getLocked(address: TSubstrateAccount): Promise<{ id: string, amount: bigint, reason: string }[]> {
2399 const locks = (await this.helper.callRpc('api.query.balances.locks', [address])).toHuman();2399 const locks = (await this.helper.callRpc('api.query.balances.locks', [address])).toHuman();
2400 return locks.map((lock: any) => ({id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}));2400 return locks.map((lock: any) => ({id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}));
2401 }2401 }
2581 */2581 */
2582 async getVestingSchedules(address: TSubstrateAccount): Promise<{ start: bigint, period: bigint, periodCount: bigint, perPeriod: bigint }[]> {2582 async getVestingSchedules(address: TSubstrateAccount): Promise<{ start: bigint, period: bigint, periodCount: bigint, perPeriod: bigint }[]> {
2583 const schedule = (await this.helper.callRpc('api.query.vesting.vestingSchedules', [address])).toJSON();2583 const schedule = (await this.helper.callRpc('api.query.vesting.vestingSchedules', [address])).toJSON();
2584 return schedule.map((schedule: any) => {2584 return schedule.map((schedule: any) => ({
2585 return {
2586 start: BigInt(schedule.start),2585 start: BigInt(schedule.start),
2587 period: BigInt(schedule.period),2586 period: BigInt(schedule.period),
2588 periodCount: BigInt(schedule.periodCount),2587 periodCount: BigInt(schedule.periodCount),
2589 perPeriod: BigInt(schedule.perPeriod),2588 perPeriod: BigInt(schedule.perPeriod),
2590 };
2591 });2589 }));
2592 }2590 }
25932591
2594 /**2592 /**
2804 */2802 */
2805 async getTotalStakedPerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {2803 async getTotalStakedPerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
2806 const rawTotalStakerdPerBlock = await this.helper.callRpc('api.rpc.appPromotion.totalStakedPerBlock', [address]);2804 const rawTotalStakerdPerBlock = await this.helper.callRpc('api.rpc.appPromotion.totalStakedPerBlock', [address]);
2807 return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => {2805 return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => ({
2808 return {
2809 block: block.toBigInt(),2806 block: block.toBigInt(),
2810 amount: amount.toBigInt(),2807 amount: amount.toBigInt(),
2811 };
2812 });2808 }));
2813 }2809 }
28142810
2815 /**2811 /**
2828 */2824 */
2829 async getPendingUnstakePerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {2825 async getPendingUnstakePerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
2830 const rawUnstakedPerBlock = await this.helper.callRpc('api.rpc.appPromotion.pendingUnstakePerBlock', [address]);2826 const rawUnstakedPerBlock = await this.helper.callRpc('api.rpc.appPromotion.pendingUnstakePerBlock', [address]);
2831 const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => {2827 const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => ({
2832 return {
2833 block: block.toBigInt(),2828 block: block.toBigInt(),
2834 amount: amount.toBigInt(),2829 amount: amount.toBigInt(),
2835 };
2836 });2830 }));
2837 return result;2831 return result;
2838 }2832 }
2839}2833}
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
682 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);682 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
683 });683 });
684684
685 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {685 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
686 return event.messageHash() == maliciousXcmProgramSent.messageHash()
687 && event.outcome().isFailedToTransactAsset;686 && event.outcome().isFailedToTransactAsset);
688 });
689687
690 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);688 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
691 expect(targetAccountBalance).to.be.equal(0n);689 expect(targetAccountBalance).to.be.equal(0n);
765 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);763 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
766 });764 });
767765
768 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {766 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
769 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
770 && event.outcome().isUntrustedReserveLocation;767 && event.outcome().isUntrustedReserveLocation);
771 });
772768
773 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);769 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
774 expect(accountBalance).to.be.equal(0n);770 expect(accountBalance).to.be.equal(0n);
780 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);776 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
781 });777 });
782778
783 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {779 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
784 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
785 && event.outcome().isUntrustedReserveLocation;780 && event.outcome().isUntrustedReserveLocation);
786 });
787781
788 accountBalance = await helper.balance.getSubstrate(targetAccount.address);782 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
789 expect(accountBalance).to.be.equal(0n);783 expect(accountBalance).to.be.equal(0n);
858 });852 });
859853
860 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {854 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
861 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {855 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
862 return event.messageHash() == messageSent.messageHash()
863 && event.outcome().isFailedToTransactAsset;856 && event.outcome().isFailedToTransactAsset);
864 });
865 };857 };
866858
867 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {859 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
1172 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1164 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1173 });1165 });
11741166
1175 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1167 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
1176 return event.messageHash() == maliciousXcmProgramSent.messageHash()
1177 && event.outcome().isFailedToTransactAsset;1168 && event.outcome().isFailedToTransactAsset);
1178 });
11791169
1180 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1170 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1181 expect(targetAccountBalance).to.be.equal(0n);1171 expect(targetAccountBalance).to.be.equal(0n);
1263 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1253 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1264 });1254 });
12651255
1266 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1256 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1267 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1268 && event.outcome().isUntrustedReserveLocation;1257 && event.outcome().isUntrustedReserveLocation);
1269 });
12701258
1271 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1259 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1272 expect(accountBalance).to.be.equal(0n);1260 expect(accountBalance).to.be.equal(0n);
1282 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1270 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1283 });1271 });
12841272
1285 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1273 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1286 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1287 && event.outcome().isUntrustedReserveLocation;1274 && event.outcome().isUntrustedReserveLocation);
1288 });
12891275
1290 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1276 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1291 expect(accountBalance).to.be.equal(0n);1277 expect(accountBalance).to.be.equal(0n);
1544 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1530 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1545 });1531 });
15461532
1547 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1533 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
1548 return event.messageHash() == maliciousXcmProgramSent.messageHash()
1549 && event.outcome().isFailedToTransactAsset;1534 && event.outcome().isFailedToTransactAsset);
1550 });
15511535
1552 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1536 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1553 expect(targetAccountBalance).to.be.equal(0n);1537 expect(targetAccountBalance).to.be.equal(0n);
1627 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1611 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1628 });1612 });
16291613
1630 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1614 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1631 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1632 && event.outcome().isUntrustedReserveLocation;1615 && event.outcome().isUntrustedReserveLocation);
1633 });
16341616
1635 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1617 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1636 expect(accountBalance).to.be.equal(0n);1618 expect(accountBalance).to.be.equal(0n);
1642 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1624 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1643 });1625 });
16441626
1645 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1627 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1646 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1647 && event.outcome().isUntrustedReserveLocation;1628 && event.outcome().isUntrustedReserveLocation);
1648 });
16491629
1650 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1630 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1651 expect(accountBalance).to.be.equal(0n);1631 expect(accountBalance).to.be.equal(0n);
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
684 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);684 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
685 });685 });
686686
687 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {687 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
688 return event.messageHash() == maliciousXcmProgramSent.messageHash()
689 && event.outcome().isFailedToTransactAsset;688 && event.outcome().isFailedToTransactAsset);
690 });
691689
692 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);690 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
693 expect(targetAccountBalance).to.be.equal(0n);691 expect(targetAccountBalance).to.be.equal(0n);
767 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);765 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
768 });766 });
769767
770 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {768 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
771 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
772 && event.outcome().isUntrustedReserveLocation;769 && event.outcome().isUntrustedReserveLocation);
773 });
774770
775 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);771 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
776 expect(accountBalance).to.be.equal(0n);772 expect(accountBalance).to.be.equal(0n);
782 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);778 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
783 });779 });
784780
785 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {781 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
786 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
787 && event.outcome().isUntrustedReserveLocation;782 && event.outcome().isUntrustedReserveLocation);
788 });
789783
790 accountBalance = await helper.balance.getSubstrate(targetAccount.address);784 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
791 expect(accountBalance).to.be.equal(0n);785 expect(accountBalance).to.be.equal(0n);
860 });854 });
861855
862 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {856 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
863 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {857 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
864 return event.messageHash() == messageSent.messageHash()
865 && event.outcome().isFailedToTransactAsset;858 && event.outcome().isFailedToTransactAsset);
866 });
867 };859 };
868860
869 itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {861 itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {
1175 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1167 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1176 });1168 });
11771169
1178 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1170 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
1179 return event.messageHash() == maliciousXcmProgramSent.messageHash()
1180 && event.outcome().isFailedToTransactAsset;1171 && event.outcome().isFailedToTransactAsset);
1181 });
11821172
1183 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1173 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1184 expect(targetAccountBalance).to.be.equal(0n);1174 expect(targetAccountBalance).to.be.equal(0n);
1266 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1256 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1267 });1257 });
12681258
1269 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1259 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1270 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1271 && event.outcome().isUntrustedReserveLocation;1260 && event.outcome().isUntrustedReserveLocation);
1272 });
12731261
1274 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1262 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1275 expect(accountBalance).to.be.equal(0n);1263 expect(accountBalance).to.be.equal(0n);
1285 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1273 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1286 });1274 });
12871275
1288 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1276 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1289 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1290 && event.outcome().isUntrustedReserveLocation;1277 && event.outcome().isUntrustedReserveLocation);
1291 });
12921278
1293 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1279 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1294 expect(accountBalance).to.be.equal(0n);1280 expect(accountBalance).to.be.equal(0n);
1546 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1532 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1547 });1533 });
15481534
1549 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1535 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
1550 return event.messageHash() == maliciousXcmProgramSent.messageHash()
1551 && event.outcome().isFailedToTransactAsset;1536 && event.outcome().isFailedToTransactAsset);
1552 });
15531537
1554 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1538 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1555 expect(targetAccountBalance).to.be.equal(0n);1539 expect(targetAccountBalance).to.be.equal(0n);
1629 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1613 maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1630 });1614 });
16311615
1632 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1616 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1633 return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
1634 && event.outcome().isUntrustedReserveLocation;1617 && event.outcome().isUntrustedReserveLocation);
1635 });
16361618
1637 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1619 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1638 expect(accountBalance).to.be.equal(0n);1620 expect(accountBalance).to.be.equal(0n);
1644 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);1626 maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
1645 });1627 });
16461628
1647 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {1629 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1648 return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
1649 && event.outcome().isUntrustedReserveLocation;1630 && event.outcome().isUntrustedReserveLocation);
1650 });
16511631
1652 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1632 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1653 expect(accountBalance).to.be.equal(0n);1633 expect(accountBalance).to.be.equal(0n);