git.delta.rocks / unique-network / refs/commits / 7f26d6928c9d

difftreelog

fix tests

Trubnikov Sergey2022-12-09parent: #5811ea8.patch.diff
in: master

2 files changed

modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
31 const owner = await helper.eth.createAccountWithBalance(donor);31 const owner = await helper.eth.createAccountWithBalance(donor);
32 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);32 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionCreated', 'CollectionDestroyed']}]);
33 const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');33 const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
34 await helper.wait.newBlocks(1);
34 {35 {
35 expect(ethEvents).to.be.like([36 expect(ethEvents).to.be.like([
36 {37 {
48 {49 {
49 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);50 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
50 const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});51 const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
52 await helper.wait.newBlocks(1);
51 expect(result.events).to.be.like({53 expect(result.events).to.be.like({
52 CollectionDestroyed: {54 CollectionDestroyed: {
53 returnValues: {55 returnValues: {
73 ethEvents.push(event);75 ethEvents.push(event);
74 });76 });
75 await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});77 await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
78 await helper.wait.newBlocks(1);
76 expect(ethEvents).to.be.like([79 expect(ethEvents).to.be.like([
77 {80 {
78 event: 'CollectionChanged',81 event: 'CollectionChanged',
90 ethEvents.push(event);93 ethEvents.push(event);
91 });94 });
92 await collection.methods.deleteCollectionProperties(['A']).send({from:owner});95 await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
96 await helper.wait.newBlocks(1);
93 expect(ethEvents).to.be.like([97 expect(ethEvents).to.be.like([
94 {98 {
95 event: 'CollectionChanged',99 event: 'CollectionChanged',
114 });118 });
115 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);119 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
116 await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});120 await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
121 await helper.wait.newBlocks(1);
117 expect(eethEvents).to.be.like([122 expect(eethEvents).to.be.like([
118 {123 {
119 event: 'CollectionChanged',124 event: 'CollectionChanged',
140 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);145 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['AllowListAddressAdded', 'AllowListAddressRemoved']}]);
141 {146 {
142 await collection.methods.addToCollectionAllowListCross(user).send({from: owner});147 await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
148 await helper.wait.newBlocks(1);
143 expect(ethEvents).to.be.like([149 expect(ethEvents).to.be.like([
144 {150 {
145 event: 'CollectionChanged',151 event: 'CollectionChanged',
154 }160 }
155 {161 {
156 await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});162 await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
163 await helper.wait.newBlocks(1);
157 expect(ethEvents.length).to.be.eq(1);164 expect(ethEvents.length).to.be.eq(1);
158 expect(ethEvents).to.be.like([165 expect(ethEvents).to.be.like([
159 {166 {
181 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);188 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionAdminAdded', 'CollectionAdminRemoved']}]);
182 {189 {
183 await collection.methods.addCollectionAdminCross(user).send({from: owner});190 await collection.methods.addCollectionAdminCross(user).send({from: owner});
191 await helper.wait.newBlocks(1);
184 expect(ethEvents).to.be.like([192 expect(ethEvents).to.be.like([
185 {193 {
186 event: 'CollectionChanged',194 event: 'CollectionChanged',
195 }203 }
196 {204 {
197 await collection.methods.removeCollectionAdminCross(user).send({from: owner});205 await collection.methods.removeCollectionAdminCross(user).send({from: owner});
206 await helper.wait.newBlocks(1);
198 expect(ethEvents).to.be.like([207 expect(ethEvents).to.be.like([
199 {208 {
200 event: 'CollectionChanged',209 event: 'CollectionChanged',
220 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);229 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
221 {230 {
222 await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});231 await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
232 await helper.wait.newBlocks(1);
223 expect(ethEvents).to.be.like([233 expect(ethEvents).to.be.like([
224 {234 {
225 event: 'CollectionChanged',235 event: 'CollectionChanged',
246 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);256 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionOwnedChanged']}]);
247 {257 {
248 await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});258 await collection.methods.changeCollectionOwnerCross(new_owner).send({from: owner});
259 await helper.wait.newBlocks(1);
249 expect(ethEvents).to.be.like([260 expect(ethEvents).to.be.like([
250 {261 {
251 event: 'CollectionChanged',262 event: 'CollectionChanged',
271 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);282 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionPermissionSet']}]);
272 {283 {
273 await collection.methods.setCollectionMintMode(true).send({from: owner});284 await collection.methods.setCollectionMintMode(true).send({from: owner});
285 await helper.wait.newBlocks(1);
274 expect(ethEvents).to.be.like([286 expect(ethEvents).to.be.like([
275 {287 {
276 event: 'CollectionChanged',288 event: 'CollectionChanged',
285 }297 }
286 {298 {
287 await collection.methods.setCollectionAccess(1).send({from: owner});299 await collection.methods.setCollectionAccess(1).send({from: owner});
300 await helper.wait.newBlocks(1);
288 expect(ethEvents).to.be.like([301 expect(ethEvents).to.be.like([
289 {302 {
290 event: 'CollectionChanged',303 event: 'CollectionChanged',
313 ]}]);326 ]}]);
314 {327 {
315 await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});328 await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
329 await helper.wait.newBlocks(1);
316 expect(ethEvents).to.be.like([330 expect(ethEvents).to.be.like([
317 {331 {
318 event: 'CollectionChanged',332 event: 'CollectionChanged',
327 }341 }
328 {342 {
329 await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});343 await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
344 await helper.wait.newBlocks(1);
330 expect(ethEvents).to.be.like([345 expect(ethEvents).to.be.like([
331 {346 {
332 event: 'CollectionChanged',347 event: 'CollectionChanged',
371 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);386 const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
372 {387 {
373 await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});388 await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
389 await helper.wait.newBlocks(1);
374 expect(ethEvents).to.be.like([390 expect(ethEvents).to.be.like([
375 {391 {
376 event: 'TokenChanged',392 event: 'TokenChanged',
398 unsubscribe();414 unsubscribe();
399}415}
400416
401describe('[FT] Sync sub & eth events', () => {417describe.only('[FT] Sync sub & eth events', () => {
402 const mode: TCollectionMode = 'ft';418 const mode: TCollectionMode = 'ft';
403419
404 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {420 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
434 });450 });
435});451});
436452
437describe('[NFT] Sync sub & eth events', () => {453describe.only('[NFT] Sync sub & eth events', () => {
438 const mode: TCollectionMode = 'nft';454 const mode: TCollectionMode = 'nft';
439455
440 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {456 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
478 });494 });
479});495});
480496
481describe('[RFT] Sync sub & eth events', () => {497describe.only('[RFT] Sync sub & eth events', () => {
482 const mode: TCollectionMode = 'rft';498 const mode: TCollectionMode = 'rft';
483499
484 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {500 itEth('CollectionCreated and CollectionDestroyed events', async ({helper}) => {
modifiedtests/src/util/index.tsdiffbeforeafterboth
33
4import * as path from 'path';4import * as path from 'path';
5import * as crypto from 'crypto';5import * as crypto from 'crypto';
6import {IKeyringPair} from '@polkadot/types/types';6import {IKeyringPair} from '@polkadot/types/types/interfaces';
7import chai from 'chai';7import chai from 'chai';
8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';
9import {Context} from 'mocha';9import {Context} from 'mocha';