git.delta.rocks / unique-network / refs/commits / 6954756c5370

difftreelog

fix maintenance tests

Daniel Shiposha2022-11-07parent: #4a26571.patch.diff
in: master

1 file changed

modifiedtests/src/maintenanceMode.seqtest.tsdiffbeforeafterboth
4343
44 itSub('Allows superuser to enable and disable maintenance mode - and disallows anyone else', async ({helper}) => {44 itSub('Allows superuser to enable and disable maintenance mode - and disallows anyone else', async ({helper}) => {
45 // Make sure non-sudo can't enable maintenance mode45 // Make sure non-sudo can't enable maintenance mode
46 await expect(helper.executeExtrinsic(superuser, 'api.tx.maintenance.enable', []), 'on commoner enabling MM').to.be.rejected; //With(/NoPermission/);46 await expect(helper.executeExtrinsic(superuser, 'api.tx.maintenance.enable', []), 'on commoner enabling MM')
47 .to.be.rejectedWith(/BadOrigin/);
4748
48 // Set maintenance mode49 // Set maintenance mode
49 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);50 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);
50 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;51 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;
5152
52 // Make sure non-sudo can't disable maintenance mode53 // Make sure non-sudo can't disable maintenance mode
53 await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.disable', []), 'on commoner disabling MM').to.be.rejected; //With(/NoPermission/);54 await expect(helper.executeExtrinsic(bob, 'api.tx.maintenance.disable', []), 'on commoner disabling MM')
55 .to.be.rejectedWith(/BadOrigin/);
5456
55 // Disable maintenance mode57 // Disable maintenance mode
56 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);58 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);
80 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;82 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;
8183
82 // Unable to create a collection when the MM is enabled84 // Unable to create a collection when the MM is enabled
83 await expect(helper.nft.mintCollection(superuser), 'cudo forbidden stuff').to.be.rejected;85 await expect(helper.nft.mintCollection(superuser), 'cudo forbidden stuff')
86 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
8487
85 // Unable to set token properties when the MM is enabled88 // Unable to set token properties when the MM is enabled
86 await expect(nft.setProperties(89 await expect(nft.setProperties(
87 bob,90 bob,
88 [{key: 'test', value: 'test-val'}],91 [{key: 'test', value: 'test-val'}],
89 )).to.be.rejected;92 )).to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
9093
91 // Unable to mint an NFT when the MM is enabled94 // Unable to mint an NFT when the MM is enabled
92 await expect(nftCollection.mintToken(superuser)).to.be.rejected;95 await expect(nftCollection.mintToken(superuser))
96 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
9397
94 // Unable to mint an FT when the MM is enabled98 // Unable to mint an FT when the MM is enabled
95 await expect(ftCollection.mint(superuser)).to.be.rejected;99 await expect(ftCollection.mint(superuser))
100 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
96101
97 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);102 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);
98 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;103 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;
121 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;126 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;
122127
123 // Unable to mint an RFT when the MM is enabled128 // Unable to mint an RFT when the MM is enabled
124 await expect(rftCollection.mintToken(superuser)).to.be.rejected;129 await expect(rftCollection.mintToken(superuser))
125 130 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
131
126 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);132 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);
127 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;133 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;
195201
196 // Any attempts to schedule a tx during the MM should be rejected202 // Any attempts to schedule a tx during the MM should be rejected
197 await expect(nftDuringMM.scheduleAfter(scheduledIdAttemptDuringMM, blocksToWait)203 await expect(nftDuringMM.scheduleAfter(scheduledIdAttemptDuringMM, blocksToWait)
198 .transfer(bob, {Substrate: superuser.address})).to.be.rejected;204 .transfer(bob, {Substrate: superuser.address}))
205 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
199206
200 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);207 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);
201 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;208 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;
225 const tokenId = await contract.methods.nextTokenId().call();232 const tokenId = await contract.methods.nextTokenId().call();
226 expect(tokenId).to.be.equal('1');233 expect(tokenId).to.be.equal('1');
227234
228 /*const result = */
229 await contract.methods.mintWithTokenURI(235 await expect(contract.methods.mintWithTokenURI(receiver, 'Test URI').send())
230 receiver,
231 'Test URI',
232 ).send();236 .to.be.rejectedWith(/submit transaction to pool failed: Pool\(InvalidTransaction\(InvalidTransaction::Call\)\)/);
233 /*const expectedTokenId = result.events.Transfer.returnValues.tokenId;
234 expect(expectedTokenId).to.be.equal(tokenId);*/
235237
236 await expect(contract.methods.ownerOf(tokenId).call()).rejectedWith(/token not found/);238 await expect(contract.methods.ownerOf(tokenId).call()).rejectedWith(/token not found/);
237239