git.delta.rocks / unique-network / refs/commits / 3050b513cda0

difftreelog

test add event asserts (#982)

Max Andreev2023-09-06parent: #ec8104e.patch.diff
in: master
* add events asserts

* fix eslint

* eslint fix - unused vars

7 files changed

modifiedtests/src/benchmarks/nesting/index.tsdiffbeforeafterboth
--- a/tests/src/benchmarks/nesting/index.ts
+++ b/tests/src/benchmarks/nesting/index.ts
@@ -1,17 +1,11 @@
 import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';
 import {readFile} from 'fs/promises';
-import {
-  ICrossAccountId,
-} from '../../util/playgrounds/types';
 import {IKeyringPair} from '@polkadot/types/types';
-import {UniqueNFTCollection} from '../../util/playgrounds/unique';
 import {Contract} from 'web3-eth-contract';
-import {createObjectCsvWriter} from 'csv-writer';
-import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES} from '../utils/common';
+import {convertToTokens} from '../utils/common';
 import {makeNames} from '../../util';
 import {ContractImports} from '../../eth/util/playgrounds/types';
 import {RMRKNestableMintable} from './ABIGEN';
-import {rm} from 'fs';
 
 const {dirname} = makeNames(import.meta.url);
 
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -162,7 +162,7 @@
       const malignant = await helper.eth.createAccountWithBalance(donor);
 
       const {collectionId: collectionIdA, contract: contractA} = await createNestingCollection(helper, owner);
-      const {collectionId: collectionIdB, contract: contractB} = await createNestingCollection(helper, owner);
+      const {contract: contractB} = await createNestingCollection(helper, owner);
 
       await contractA.methods.setCollectionNesting([true, false, [contractA.options.address, contractB.options.address]]).send({from: owner});
 
modifiedtests/src/fetchMetadata.tsdiffbeforeafterboth
--- a/tests/src/fetchMetadata.ts
+++ b/tests/src/fetchMetadata.ts
@@ -1,16 +1,16 @@
-import { writeFile } from "fs/promises";
-import { join } from "path";
-import { exit } from "process";
-import { fileURLToPath } from "url";
+import {writeFile} from 'fs/promises';
+import {join} from 'path';
+import {exit} from 'process';
+import {fileURLToPath} from 'url';
 
 const url = process.env.RPC_URL;
-if (!url) throw new Error('RPC_URL is not set');
+if(!url) throw new Error('RPC_URL is not set');
 
 const srcDir = fileURLToPath(new URL('.', import.meta.url));
 
-for (let i = 0; i < 10; i++) {
+for(let i = 0; i < 10; i++) {
   try {
-    console.log(`Trying to fetch metadata, retry ${i + 1}/${10}`)
+    console.log(`Trying to fetch metadata, retry ${i + 1}/${10}`);
     const response = await fetch(url, {
       method: 'POST',
       headers: {
modifiedtests/src/governance/technicalCommittee.test.tsdiffbeforeafterboth
--- a/tests/src/governance/technicalCommittee.test.ts
+++ b/tests/src/governance/technicalCommittee.test.ts
@@ -36,8 +36,8 @@
     });
   });
 
-  async function proposalFromAllCommittee(proposal: any) {
-    return await usingPlaygrounds(async (helper) => {
+  function proposalFromAllCommittee(proposal: any) {
+    return usingPlaygrounds(async (helper) => {
       expect((await helper.callRpc('api.query.technicalCommitteeMembership.members')).toJSON().length).to.be.equal(allTechCommitteeThreshold);
       const proposeResult = await helper.technicalCommittee.collective.propose(
         techcomms.andy,
@@ -54,7 +54,13 @@
       await helper.technicalCommittee.collective.vote(techcomms.constantine, proposalHash, proposalIndex, true);
       await helper.technicalCommittee.collective.vote(techcomms.greg, proposalHash, proposalIndex, true);
 
-      return await helper.technicalCommittee.collective.close(techcomms.andy, proposalHash, proposalIndex);
+      const closeResult = await helper.technicalCommittee.collective.close(techcomms.andy, proposalHash, proposalIndex);
+      Event.TechnicalCommittee.Closed.expect(closeResult);
+      Event.TechnicalCommittee.Approved.expect(closeResult);
+      const {result} = Event.TechnicalCommittee.Executed.expect(closeResult);
+      expect(result).to.eq('Ok');
+
+      return closeResult;
     });
   }
 
@@ -64,16 +70,16 @@
 
     await helper.getSudo().democracy.externalProposeDefaultWithPreimage(sudoer, preimageHash);
 
-    await expect(proposalFromAllCommittee(helper.democracy.fastTrackCall(preimageHash, democracyFastTrackVotingPeriod, 0)))
-      .to.be.fulfilled;
+    const fastTrackProposal = await proposalFromAllCommittee(helper.democracy.fastTrackCall(preimageHash, democracyFastTrackVotingPeriod, 0));
+    Event.Democracy.Started.expect(fastTrackProposal);
   });
 
   itSub('TechComm can cancel Democracy proposals', async ({helper}) => {
     const proposeResult = await helper.getSudo().democracy.propose(sudoer, dummyProposalCall(helper), 0n);
     const proposalIndex = Event.Democracy.Proposed.expect(proposeResult).proposalIndex;
 
-    await expect(proposalFromAllCommittee(helper.democracy.cancelProposalCall(proposalIndex)))
-      .to.be.fulfilled;
+    const cancelProposal = await proposalFromAllCommittee(helper.democracy.cancelProposalCall(proposalIndex));
+    Event.Democracy.ProposalCanceled.expect(cancelProposal);
   });
 
   itSub('TechComm can cancel ongoing Democracy referendums', async ({helper}) => {
@@ -81,19 +87,19 @@
     const startedEvent = await helper.wait.expectEvent(democracyLaunchPeriod, Event.Democracy.Started);
     const referendumIndex = startedEvent.referendumIndex;
 
-    await expect(proposalFromAllCommittee(helper.democracy.emergencyCancelCall(referendumIndex)))
-      .to.be.fulfilled;
+    const emergencyCancelProposal = await proposalFromAllCommittee(helper.democracy.emergencyCancelCall(referendumIndex));
+    Event.Democracy.Cancelled.expect(emergencyCancelProposal);
   });
-
 
   itSub('TechComm member can veto Democracy proposals', async ({helper}) => {
     const preimageHash = await helper.preimage.notePreimageFromCall(sudoer, dummyProposalCall(helper), true);
     await helper.getSudo().democracy.externalProposeDefaultWithPreimage(sudoer, preimageHash);
 
-    await expect(helper.technicalCommittee.collective.execute(
+    const vetoExternalCall = await helper.technicalCommittee.collective.execute(
       techcomms.andy,
       helper.democracy.vetoExternalCall(preimageHash),
-    )).to.be.fulfilled;
+    );
+    Event.Democracy.Vetoed.expect(vetoExternalCall);
   });
 
   itSub('TechComm can cancel Fellowship referendums', async ({helper}) => {
@@ -108,7 +114,8 @@
       defaultEnactmentMoment,
     );
     const referendumIndex = Event.FellowshipReferenda.Submitted.expect(submitResult).referendumIndex;
-    await expect(proposalFromAllCommittee(helper.fellowship.referenda.cancelCall(referendumIndex))).to.be.fulfilled;
+    const cancelProposal = await proposalFromAllCommittee(helper.fellowship.referenda.cancelCall(referendumIndex));
+    Event.FellowshipReferenda.Cancelled.expect(cancelProposal);
   });
 
   itSub.skip('TechComm member can add a Fellowship member', async ({helper}) => {
modifiedtests/src/maintenance.seqtest.tsdiffbeforeafterboth
before · tests/src/maintenance.seqtest.ts
1// 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 {ApiPromise} from '@polkadot/api';19import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';20import {itEth} from './eth/util';21import {UniqueHelper} from './util/playgrounds/unique';22import {main as correctState} from './migrations/correctStateAfterMaintenance';2324async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {25  return (await api.query.maintenance.enabled()).toJSON() as boolean;26}2728describe('Integration Test: Maintenance Functionality', () => {29  let superuser: IKeyringPair;30  let donor: IKeyringPair;31  let bob: IKeyringPair;3233  before(async function() {34    await usingPlaygrounds(async (helper, privateKey) => {35      requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);36      superuser = await privateKey('//Alice');37      donor = await privateKey({url: import.meta.url});38      [bob] = await helper.arrange.createAccounts([10000n], donor);3940    });41  });4243  describe('Maintenance Mode', () => {44    before(async function() {45      await usingPlaygrounds(async (helper) => {46        if(await maintenanceEnabled(helper.getApi())) {47          console.warn('\tMaintenance mode was left enabled BEFORE the test suite! Disabling it now.');48          await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;49        }50      });51    });5253    itSub('Allows superuser to enable and disable maintenance mode - and disallows anyone else', async ({helper}) => {54      // Make sure non-sudo can't enable maintenance mode55      await expect(helper.executeExtrinsic(superuser, 'api.tx.maintenance.enable', []), 'on commoner enabling MM')56        .to.be.rejectedWith(/BadOrigin/);5758      // Set maintenance mode59      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);60      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;6162      // Make sure non-sudo can't disable maintenance mode63      await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.disable', []), 'on commoner disabling MM')64        .to.be.rejectedWith(/BadOrigin/);6566      // Disable maintenance mode67      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);68      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;69    });7071    itSub('MM blocks unique pallet calls', async ({helper}) => {72      // Can create an NFT collection before enabling the MM73      const nftCollection = await helper.nft.mintCollection(bob, {74        tokenPropertyPermissions: [{75          key: 'test', permission: {76            collectionAdmin: true,77            tokenOwner: true,78            mutable: true,79          },80        }],81      });8283      // Can mint an NFT before enabling the MM84      const nft = await nftCollection.mintToken(bob);8586      // Can create an FT collection before enabling the MM87      const ftCollection = await helper.ft.mintCollection(superuser);8889      // Can mint an FT before enabling the MM90      await expect(ftCollection.mint(superuser)).to.be.fulfilled;9192      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);93      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;9495      // Unable to create a collection when the MM is enabled96      await expect(helper.nft.mintCollection(superuser), 'cudo forbidden stuff')97        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);9899      // Unable to set token properties when the MM is enabled100      await expect(nft.setProperties(101        bob,102        [{key: 'test', value: 'test-val'}],103      )).to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);104105      // Unable to mint an NFT when the MM is enabled106      await expect(nftCollection.mintToken(superuser))107        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);108109      // Unable to mint an FT when the MM is enabled110      await expect(ftCollection.mint(superuser))111        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);112113      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);114      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;115116      // Can create a collection after disabling the MM117      await expect(helper.nft.mintCollection(bob), 'MM is disabled, the collection should be created').to.be.fulfilled;118119      // Can set token properties after disabling the MM120      await nft.setProperties(bob, [{key: 'test', value: 'test-val'}]);121122      // Can mint an NFT after disabling the MM123      await nftCollection.mintToken(bob);124125      // Can mint an FT after disabling the MM126      await ftCollection.mint(superuser);127    });128129    itSub.ifWithPallets('MM blocks unique pallet calls (Re-Fungible)', [Pallets.ReFungible], async ({helper}) => {130      // Can create an RFT collection before enabling the MM131      const rftCollection = await helper.rft.mintCollection(superuser);132133      // Can mint an RFT before enabling the MM134      await expect(rftCollection.mintToken(superuser)).to.be.fulfilled;135136      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);137      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;138139      // Unable to mint an RFT when the MM is enabled140      await expect(rftCollection.mintToken(superuser))141        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);142143      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);144      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;145146      // Can mint an RFT after disabling the MM147      await rftCollection.mintToken(superuser);148    });149150    itSub('MM allows native token transfers and RPC calls', async ({helper}) => {151      // We can use RPC before the MM is enabled152      const totalCount = await helper.collection.getTotalCount();153154      // We can transfer funds before the MM is enabled155      await expect(helper.balance.transferToSubstrate(superuser, bob.address, 2n)).to.be.fulfilled;156157      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);158      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;159160      // RPCs work while in maintenance161      expect(await helper.collection.getTotalCount()).to.be.deep.equal(totalCount);162163      // We still able to transfer funds164      await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;165166      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);167      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;168169      // RPCs work after maintenance170      expect(await helper.collection.getTotalCount()).to.be.deep.equal(totalCount);171172      // Transfers work after maintenance173      await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;174    });175176    itSched.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.UniqueScheduler], async (scheduleKind, {helper}) => {177      const collection = await helper.nft.mintCollection(bob);178179      const nftBeforeMM = await collection.mintToken(bob);180      const nftDuringMM = await collection.mintToken(bob);181      const nftAfterMM = await collection.mintToken(bob);182183      const [184        scheduledIdBeforeMM,185        scheduledIdDuringMM,186        scheduledIdBunkerThroughMM,187        scheduledIdAttemptDuringMM,188        scheduledIdAfterMM,189      ] = scheduleKind == 'named'190        ? helper.arrange.makeScheduledIds(5)191        : new Array(5);192193      const blocksToWait = 6;194195      // Scheduling works before the maintenance196      await nftBeforeMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdBeforeMM})197        .transfer(bob, {Substrate: superuser.address});198199      await helper.wait.newBlocks(blocksToWait + 1);200      expect(await nftBeforeMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});201202      // Schedule a transaction that should occur *during* the maintenance203      await nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdDuringMM})204        .transfer(bob, {Substrate: superuser.address});205206      // Schedule a transaction that should occur *after* the maintenance207      await nftDuringMM.scheduleAfter(blocksToWait * 2, {scheduledId: scheduledIdBunkerThroughMM})208        .transfer(bob, {Substrate: superuser.address});209210      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);211      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;212213      await helper.wait.newBlocks(blocksToWait + 1);214      // The owner should NOT change since the scheduled transaction should be rejected215      expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: bob.address});216217      // Any attempts to schedule a tx during the MM should be rejected218      await expect(nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAttemptDuringMM})219        .transfer(bob, {Substrate: superuser.address}))220        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);221222      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);223      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;224225      // Scheduling works after the maintenance226      await nftAfterMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAfterMM})227        .transfer(bob, {Substrate: superuser.address});228229      await helper.wait.newBlocks(blocksToWait + 1);230231      expect(await nftAfterMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});232      // The owner of the token scheduled for transaction *before* maintenance should now change *after* maintenance233      expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});234    });235236    itEth('Disallows Ethereum transactions to execute while in maintenance', async ({helper}) => {237      const owner = await helper.eth.createAccountWithBalance(donor);238      const receiver = helper.eth.createAccount();239240      const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'B', 'C', '');241242      // Set maintenance mode243      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);244      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;245246      const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);247      const tokenId = await contract.methods.nextTokenId().call();248      expect(tokenId).to.be.equal('1');249250      await expect(contract.methods.mintWithTokenURI(receiver, 'Test URI').send())251        .to.be.rejectedWith(/Returned error: unknown error/);252253      await expect(contract.methods.ownerOf(tokenId).call()).rejectedWith(/token not found/);254255      // Disable maintenance mode256      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);257      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;258    });259260    itSub('Allows to enable and disable MM repeatedly', async ({helper}) => {261      // Set maintenance mode262      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);263      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);264      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;265266      // Disable maintenance mode267      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);268      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);269      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;270    });271272    afterEach(async () => {273      await usingPlaygrounds(async helper => {274        if(helper.fetchMissingPalletNames([Pallets.Maintenance]).length != 0) return;275        if(await maintenanceEnabled(helper.getApi())) {276          console.warn('\tMaintenance mode was left enabled AFTER a test has finished! Be careful. Disabling it now.');277          await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);278        }279        expect(await maintenanceEnabled(helper.getApi()), 'Disastrous! Exited the test suite with maintenance mode on.').to.be.false;280      });281    });282  });283284  describe('Preimage Execution', () => {285    const preimageHashes: string[] = [];286287    before(async function() {288      await usingPlaygrounds(async (helper) => {289        requirePalletsOrSkip(this, helper, [Pallets.Preimage, Pallets.Maintenance]);290291        // create a preimage to be operated with in the tests292        const randomAccounts = await helper.arrange.createCrowd(10, 0n, superuser);293        const randomIdentities = randomAccounts.map((acc, i) => [294          acc.address, {295            deposit: 0n,296            judgements: [],297            info: {298              display: {299                raw: `Random Account #${i}`,300              },301            },302          },303        ]);304        const preimage = helper.constructApiCall('api.tx.identity.forceInsertIdentities', [randomIdentities]).method.toHex();305        preimageHashes.push(await helper.preimage.notePreimage(bob, preimage, true));306      });307    });308309    itSub('Successfully executes call in a preimage', async ({helper}) => {310      const result = await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [311        preimageHashes[0], {refTime: 10000000000, proofSize: 10000},312      ])).to.be.fulfilled;313314      // preimage is executed, and an appropriate event is present315      const events = result.result.events.filter((x: any) => x.event.method === 'IdentitiesInserted' && x.event.section === 'identity');316      expect(events.length).to.be.equal(1);317318      // the preimage goes back to being unrequested319      expect(await helper.preimage.getPreimageInfo(preimageHashes[0])).to.have.property('unrequested');320    });321322    itSub('Does not allow execution of a preimage that would fail', async ({helper}) => {323      const [zeroAccount] = await helper.arrange.createAccounts([0n], superuser);324325      const preimage = helper.constructApiCall('api.tx.balances.forceTransfer', [326        {Id: zeroAccount.address}, {Id: superuser.address}, 1000n,327      ]).method.toHex();328      const preimageHash = await helper.preimage.notePreimage(bob, preimage, true);329      preimageHashes.push(preimageHash);330331      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [332        preimageHash, {refTime: 10000000000, proofSize: 10000},333      ])).to.be.rejectedWith(/^Token: FundsUnavailable$/);334    });335336    itSub('Does not allow preimage execution with non-root', async ({helper}) => {337      await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.executePreimage', [338        preimageHashes[0], {refTime: 10000000000, proofSize: 10000},339      ])).to.be.rejectedWith(/^Misc: BadOrigin$/);340    });341342    itSub('Does not allow execution of non-existent preimages', async ({helper}) => {343      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [344        '0x1010101010101010101010101010101010101010101010101010101010101010', {refTime: 10000000000, proofSize: 10000},345      ])).to.be.rejectedWith(/^Misc: Unavailable$/);346    });347348    itSub('Does not allow preimage execution with less than minimum weights', async ({helper}) => {349      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [350        preimageHashes[0], {refTime: 1000, proofSize: 100},351      ])).to.be.rejectedWith(/^Misc: Exhausted$/);352    });353354    after(async function() {355      await usingPlaygrounds(async (helper) => {356        if(helper.fetchMissingPalletNames([Pallets.Preimage, Pallets.Maintenance]).length != 0) return;357358        for(const hash of preimageHashes) {359          await helper.preimage.unnotePreimage(bob, hash);360        }361      });362    });363  });364365  describe('Integration Test: Maintenance mode & App Promo', () => {366    let superuser: IKeyringPair;367368    before(async function() {369      await usingPlaygrounds(async (helper, privateKey) => {370        requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);371        superuser = await privateKey('//Alice');372      });373    });374375    describe('Test AppPromo script for check state after Maintenance mode', () => {376      before(async function () {377        await usingPlaygrounds(async (helper) => {378          if(await maintenanceEnabled(helper.getApi())) {379            console.warn('\tMaintenance mode was left enabled BEFORE the test suite! Disabling it now.');380            await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;381          }382        });383      });384      itSub('Can find and fix inconsistent state', async ({helper}) => {385        const api = helper.getApi();386387        await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.system.setStorage([388          // pendingUnstake(1 -> [superuser.address, 100UNQ])389          ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f5153cb1f00942ff401000000',390            '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],391          // pendingUnstake(2 -> [superuser.address, 100UNQ])392          ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f9eb2dcce60f37a2702000000',393            '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],394          // Balances.freezes(superuser.address -> freeze with app promo id and 200 UNQ )395          ['0xc2261276cc9d1f8598ea4b6a74b15c2fb1c0eb12e038e5c7f91e120ed4b7ebf1de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',396            '0x046170707374616b656170707374616b65000020c65abc8ed70a00000000000000'],397        ])]);398399        expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);400        expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);401        expect((await api.query.balances.freezes(superuser.address))402          .map(lock => ({id: lock.id.toUtf8(), amount: lock.amount.toBigInt()})))403          .to.be.deep.equal([{id: 'appstakeappstake', amount: 200000000000000000000n}]);404        await correctState();405406        expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([]);407        expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([]);408        expect((await api.query.balances.freezes(superuser.address)).toJSON()).to.be.deep.equal([]);409410      });411412      itSub('(!negative test!) Only works when Maintenance mode is disabled', async({helper}) => {413        await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', [])).to.be.fulfilled;414        await expect(correctState()).to.be.rejectedWith('The network is still in maintenance mode');415        await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;416      });417    });418  });419});
after · tests/src/maintenance.seqtest.ts
1// 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 {ApiPromise} from '@polkadot/api';19import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';20import {itEth} from './eth/util';21import {main as correctState} from './migrations/correctStateAfterMaintenance';2223async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {24  return (await api.query.maintenance.enabled()).toJSON() as boolean;25}2627describe('Integration Test: Maintenance Functionality', () => {28  let superuser: IKeyringPair;29  let donor: IKeyringPair;30  let bob: IKeyringPair;3132  before(async function() {33    await usingPlaygrounds(async (helper, privateKey) => {34      requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);35      superuser = await privateKey('//Alice');36      donor = await privateKey({url: import.meta.url});37      [bob] = await helper.arrange.createAccounts([10000n], donor);3839    });40  });4142  describe('Maintenance Mode', () => {43    before(async function() {44      await usingPlaygrounds(async (helper) => {45        if(await maintenanceEnabled(helper.getApi())) {46          console.warn('\tMaintenance mode was left enabled BEFORE the test suite! Disabling it now.');47          await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;48        }49      });50    });5152    itSub('Allows superuser to enable and disable maintenance mode - and disallows anyone else', async ({helper}) => {53      // Make sure non-sudo can't enable maintenance mode54      await expect(helper.executeExtrinsic(superuser, 'api.tx.maintenance.enable', []), 'on commoner enabling MM')55        .to.be.rejectedWith(/BadOrigin/);5657      // Set maintenance mode58      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);59      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;6061      // Make sure non-sudo can't disable maintenance mode62      await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.disable', []), 'on commoner disabling MM')63        .to.be.rejectedWith(/BadOrigin/);6465      // Disable maintenance mode66      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);67      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;68    });6970    itSub('MM blocks unique pallet calls', async ({helper}) => {71      // Can create an NFT collection before enabling the MM72      const nftCollection = await helper.nft.mintCollection(bob, {73        tokenPropertyPermissions: [{74          key: 'test', permission: {75            collectionAdmin: true,76            tokenOwner: true,77            mutable: true,78          },79        }],80      });8182      // Can mint an NFT before enabling the MM83      const nft = await nftCollection.mintToken(bob);8485      // Can create an FT collection before enabling the MM86      const ftCollection = await helper.ft.mintCollection(superuser);8788      // Can mint an FT before enabling the MM89      await expect(ftCollection.mint(superuser)).to.be.fulfilled;9091      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);92      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;9394      // Unable to create a collection when the MM is enabled95      await expect(helper.nft.mintCollection(superuser), 'cudo forbidden stuff')96        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);9798      // Unable to set token properties when the MM is enabled99      await expect(nft.setProperties(100        bob,101        [{key: 'test', value: 'test-val'}],102      )).to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);103104      // Unable to mint an NFT when the MM is enabled105      await expect(nftCollection.mintToken(superuser))106        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);107108      // Unable to mint an FT when the MM is enabled109      await expect(ftCollection.mint(superuser))110        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);111112      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);113      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;114115      // Can create a collection after disabling the MM116      await expect(helper.nft.mintCollection(bob), 'MM is disabled, the collection should be created').to.be.fulfilled;117118      // Can set token properties after disabling the MM119      await nft.setProperties(bob, [{key: 'test', value: 'test-val'}]);120121      // Can mint an NFT after disabling the MM122      await nftCollection.mintToken(bob);123124      // Can mint an FT after disabling the MM125      await ftCollection.mint(superuser);126    });127128    itSub.ifWithPallets('MM blocks unique pallet calls (Re-Fungible)', [Pallets.ReFungible], async ({helper}) => {129      // Can create an RFT collection before enabling the MM130      const rftCollection = await helper.rft.mintCollection(superuser);131132      // Can mint an RFT before enabling the MM133      await expect(rftCollection.mintToken(superuser)).to.be.fulfilled;134135      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);136      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;137138      // Unable to mint an RFT when the MM is enabled139      await expect(rftCollection.mintToken(superuser))140        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);141142      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);143      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;144145      // Can mint an RFT after disabling the MM146      await rftCollection.mintToken(superuser);147    });148149    itSub('MM allows native token transfers and RPC calls', async ({helper}) => {150      // We can use RPC before the MM is enabled151      const totalCount = await helper.collection.getTotalCount();152153      // We can transfer funds before the MM is enabled154      await expect(helper.balance.transferToSubstrate(superuser, bob.address, 2n)).to.be.fulfilled;155156      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);157      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;158159      // RPCs work while in maintenance160      expect(await helper.collection.getTotalCount()).to.be.deep.equal(totalCount);161162      // We still able to transfer funds163      await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;164165      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);166      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;167168      // RPCs work after maintenance169      expect(await helper.collection.getTotalCount()).to.be.deep.equal(totalCount);170171      // Transfers work after maintenance172      await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;173    });174175    itSched.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.UniqueScheduler], async (scheduleKind, {helper}) => {176      const collection = await helper.nft.mintCollection(bob);177178      const nftBeforeMM = await collection.mintToken(bob);179      const nftDuringMM = await collection.mintToken(bob);180      const nftAfterMM = await collection.mintToken(bob);181182      const [183        scheduledIdBeforeMM,184        scheduledIdDuringMM,185        scheduledIdBunkerThroughMM,186        scheduledIdAttemptDuringMM,187        scheduledIdAfterMM,188      ] = scheduleKind == 'named'189        ? helper.arrange.makeScheduledIds(5)190        : new Array(5);191192      const blocksToWait = 6;193194      // Scheduling works before the maintenance195      await nftBeforeMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdBeforeMM})196        .transfer(bob, {Substrate: superuser.address});197198      await helper.wait.newBlocks(blocksToWait + 1);199      expect(await nftBeforeMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});200201      // Schedule a transaction that should occur *during* the maintenance202      await nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdDuringMM})203        .transfer(bob, {Substrate: superuser.address});204205      // Schedule a transaction that should occur *after* the maintenance206      await nftDuringMM.scheduleAfter(blocksToWait * 2, {scheduledId: scheduledIdBunkerThroughMM})207        .transfer(bob, {Substrate: superuser.address});208209      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);210      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;211212      await helper.wait.newBlocks(blocksToWait + 1);213      // The owner should NOT change since the scheduled transaction should be rejected214      expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: bob.address});215216      // Any attempts to schedule a tx during the MM should be rejected217      await expect(nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAttemptDuringMM})218        .transfer(bob, {Substrate: superuser.address}))219        .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);220221      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);222      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;223224      // Scheduling works after the maintenance225      await nftAfterMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAfterMM})226        .transfer(bob, {Substrate: superuser.address});227228      await helper.wait.newBlocks(blocksToWait + 1);229230      expect(await nftAfterMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});231      // The owner of the token scheduled for transaction *before* maintenance should now change *after* maintenance232      expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});233    });234235    itEth('Disallows Ethereum transactions to execute while in maintenance', async ({helper}) => {236      const owner = await helper.eth.createAccountWithBalance(donor);237      const receiver = helper.eth.createAccount();238239      const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'B', 'C', '');240241      // Set maintenance mode242      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);243      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;244245      const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);246      const tokenId = await contract.methods.nextTokenId().call();247      expect(tokenId).to.be.equal('1');248249      await expect(contract.methods.mintWithTokenURI(receiver, 'Test URI').send())250        .to.be.rejectedWith(/Returned error: unknown error/);251252      await expect(contract.methods.ownerOf(tokenId).call()).rejectedWith(/token not found/);253254      // Disable maintenance mode255      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);256      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;257    });258259    itSub('Allows to enable and disable MM repeatedly', async ({helper}) => {260      // Set maintenance mode261      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);262      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);263      expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;264265      // Disable maintenance mode266      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);267      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);268      expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;269    });270271    afterEach(async () => {272      await usingPlaygrounds(async helper => {273        if(helper.fetchMissingPalletNames([Pallets.Maintenance]).length != 0) return;274        if(await maintenanceEnabled(helper.getApi())) {275          console.warn('\tMaintenance mode was left enabled AFTER a test has finished! Be careful. Disabling it now.');276          await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);277        }278        expect(await maintenanceEnabled(helper.getApi()), 'Disastrous! Exited the test suite with maintenance mode on.').to.be.false;279      });280    });281  });282283  describe('Preimage Execution', () => {284    const preimageHashes: string[] = [];285286    before(async function() {287      await usingPlaygrounds(async (helper) => {288        requirePalletsOrSkip(this, helper, [Pallets.Preimage, Pallets.Maintenance]);289290        // create a preimage to be operated with in the tests291        const randomAccounts = await helper.arrange.createCrowd(10, 0n, superuser);292        const randomIdentities = randomAccounts.map((acc, i) => [293          acc.address, {294            deposit: 0n,295            judgements: [],296            info: {297              display: {298                raw: `Random Account #${i}`,299              },300            },301          },302        ]);303        const preimage = helper.constructApiCall('api.tx.identity.forceInsertIdentities', [randomIdentities]).method.toHex();304        preimageHashes.push(await helper.preimage.notePreimage(bob, preimage, true));305      });306    });307308    itSub('Successfully executes call in a preimage', async ({helper}) => {309      const result = await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [310        preimageHashes[0], {refTime: 10000000000, proofSize: 10000},311      ])).to.be.fulfilled;312313      // preimage is executed, and an appropriate event is present314      const events = result.result.events.filter((x: any) => x.event.method === 'IdentitiesInserted' && x.event.section === 'identity');315      expect(events.length).to.be.equal(1);316317      // the preimage goes back to being unrequested318      expect(await helper.preimage.getPreimageInfo(preimageHashes[0])).to.have.property('unrequested');319    });320321    itSub('Does not allow execution of a preimage that would fail', async ({helper}) => {322      const [zeroAccount] = await helper.arrange.createAccounts([0n], superuser);323324      const preimage = helper.constructApiCall('api.tx.balances.forceTransfer', [325        {Id: zeroAccount.address}, {Id: superuser.address}, 1000n,326      ]).method.toHex();327      const preimageHash = await helper.preimage.notePreimage(bob, preimage, true);328      preimageHashes.push(preimageHash);329330      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [331        preimageHash, {refTime: 10000000000, proofSize: 10000},332      ])).to.be.rejectedWith(/^Token: FundsUnavailable$/);333    });334335    itSub('Does not allow preimage execution with non-root', async ({helper}) => {336      await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.executePreimage', [337        preimageHashes[0], {refTime: 10000000000, proofSize: 10000},338      ])).to.be.rejectedWith(/^Misc: BadOrigin$/);339    });340341    itSub('Does not allow execution of non-existent preimages', async ({helper}) => {342      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [343        '0x1010101010101010101010101010101010101010101010101010101010101010', {refTime: 10000000000, proofSize: 10000},344      ])).to.be.rejectedWith(/^Misc: Unavailable$/);345    });346347    itSub('Does not allow preimage execution with less than minimum weights', async ({helper}) => {348      await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.executePreimage', [349        preimageHashes[0], {refTime: 1000, proofSize: 100},350      ])).to.be.rejectedWith(/^Misc: Exhausted$/);351    });352353    after(async function() {354      await usingPlaygrounds(async (helper) => {355        if(helper.fetchMissingPalletNames([Pallets.Preimage, Pallets.Maintenance]).length != 0) return;356357        for(const hash of preimageHashes) {358          await helper.preimage.unnotePreimage(bob, hash);359        }360      });361    });362  });363364  describe('Integration Test: Maintenance mode & App Promo', () => {365    let superuser: IKeyringPair;366367    before(async function() {368      await usingPlaygrounds(async (helper, privateKey) => {369        requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);370        superuser = await privateKey('//Alice');371      });372    });373374    describe('Test AppPromo script for check state after Maintenance mode', () => {375      before(async function () {376        await usingPlaygrounds(async (helper) => {377          if(await maintenanceEnabled(helper.getApi())) {378            console.warn('\tMaintenance mode was left enabled BEFORE the test suite! Disabling it now.');379            await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;380          }381        });382      });383      itSub('Can find and fix inconsistent state', async ({helper}) => {384        const api = helper.getApi();385386        await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.system.setStorage([387          // pendingUnstake(1 -> [superuser.address, 100UNQ])388          ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f5153cb1f00942ff401000000',389            '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],390          // pendingUnstake(2 -> [superuser.address, 100UNQ])391          ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f9eb2dcce60f37a2702000000',392            '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],393          // Balances.freezes(superuser.address -> freeze with app promo id and 200 UNQ )394          ['0xc2261276cc9d1f8598ea4b6a74b15c2fb1c0eb12e038e5c7f91e120ed4b7ebf1de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',395            '0x046170707374616b656170707374616b65000020c65abc8ed70a00000000000000'],396        ])]);397398        expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);399        expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);400        expect((await api.query.balances.freezes(superuser.address))401          .map(lock => ({id: lock.id.toUtf8(), amount: lock.amount.toBigInt()})))402          .to.be.deep.equal([{id: 'appstakeappstake', amount: 200000000000000000000n}]);403        await correctState();404405        expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([]);406        expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([]);407        expect((await api.query.balances.freezes(superuser.address)).toJSON()).to.be.deep.equal([]);408409      });410411      itSub('(!negative test!) Only works when Maintenance mode is disabled', async({helper}) => {412        await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', [])).to.be.fulfilled;413        await expect(correctState()).to.be.rejectedWith('The network is still in maintenance mode');414        await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;415      });416    });417  });418});
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -174,6 +174,20 @@
     static Passed = this.Method('Passed', data => ({
       referendumIndex: eventJsonData<number>(data, 0),
     }));
+
+    static ProposalCanceled = this.Method('ProposalCanceled', data => ({
+      propIndex: eventJsonData<number>(data, 0),
+    }));
+
+    static Cancelled = this.Method('Cancelled', data => ({
+      propIndex: eventJsonData<number>(data, 0),
+    }));
+
+    static Vetoed = this.Method('Vetoed', data => ({
+      who: eventHumanData(data, 0),
+      proposalHash: eventHumanData(data, 1),
+      until: eventJsonData<number>(data, 1),
+    }));
   };
 
   static Council = class extends EventSection('council') {
@@ -188,6 +202,9 @@
       yes: eventJsonData<number>(data, 1),
       no: eventJsonData<number>(data, 2),
     }));
+    static Executed = this.Method('Executed', data => ({
+      proposalHash: eventHumanData(data, 0),
+    }));
   };
 
   static TechnicalCommittee = class extends EventSection('technicalCommittee') {
@@ -202,6 +219,13 @@
       yes: eventJsonData<number>(data, 1),
       no: eventJsonData<number>(data, 2),
     }));
+    static Approved = this.Method('Approved', data => ({
+      proposalHash: eventHumanData(data, 0),
+    }));
+    static Executed = this.Method('Executed', data => ({
+      proposalHash: eventHumanData(data, 0),
+      result: eventHumanData(data, 1),
+    }));
   };
 
   static FellowshipReferenda = class extends EventSection('fellowshipReferenda') {
@@ -210,6 +234,11 @@
       trackId: eventJsonData<number>(data, 1),
       proposal: eventJsonData(data, 2),
     }));
+
+    static Cancelled = this.Method('Cancelled', data => ({
+      index: eventJsonData<number>(data, 0),
+      tally: eventJsonData(data, 1),
+    }));
   };
 
   static UniqueScheduler = schedulerSection('uniqueScheduler');
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -44,15 +44,11 @@
   MoonbeamAssetInfo,
   DemocracyStandardAccountVote,
   IEthCrossAccountId,
-  CollectionFlag,
   IPhasicEvent,
-  DemocracySplitAccount,
 } from './types';
 import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';
 import type {Vec} from '@polkadot/types-codec';
-import {FrameSupportPreimagesBounded, FrameSupportScheduleDispatchTime, FrameSystemEventRecord, PalletBalancesIdAmount, PalletDemocracyConviction, PalletDemocracyVoteAccountVote} from '@polkadot/types/lookup';
-import {arrayUnzip} from '@polkadot/util';
-import {Event} from './unique.dev';
+import {FrameSystemEventRecord, PalletDemocracyConviction} from '@polkadot/types/lookup';
 
 export class CrossAccountId {
   Substrate!: TSubstrateAccount;