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

difftreelog

Move maintenance tests to seqtest

Max Andreev2023-06-14parent: #6c9848e.patch.diff
in: master

6 files changed

modifiedtests/src/maintenance.seqtest.tsdiffbeforeafterboth
19import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';19import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';
20import {itEth} from './eth/util';20import {itEth} from './eth/util';
21import {UniqueHelper} from './util/playgrounds/unique';21import {UniqueHelper} from './util/playgrounds/unique';
22import {main as correctState} from './migrations/correctStateAfterMaintenance';
2223
23async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {24async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {
24 return (await api.query.maintenance.enabled()).toJSON() as boolean;25 return (await api.query.maintenance.enabled()).toJSON() as boolean;
368 });369 });
369 });370 });
371
372 describe('Integration Test: Maintenance mode & App Promo', () => {
373 let superuser: IKeyringPair;
374
375 before(async function() {
376 await usingPlaygrounds(async (helper, privateKey) => {
377 requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);
378 superuser = await privateKey('//Alice');
379 });
380 });
381
382 describe('Test AppPromo script for check state after Maintenance mode', () => {
383 before(async function () {
384 await usingPlaygrounds(async (helper) => {
385 if(await maintenanceEnabled(helper.getApi())) {
386 console.warn('\tMaintenance mode was left enabled BEFORE the test suite! Disabling it now.');
387 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;
388 }
389 });
390 });
391 itSub('Can find and fix inconsistent state', async({helper}) => {
392 const api = helper.getApi();
393
394 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.system.setStorage([
395 ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f5153cb1f00942ff401000000',
396 '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],
397 ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f9eb2dcce60f37a2702000000',
398 '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],
399 ['0xc2261276cc9d1f8598ea4b6a74b15c2fb1c0eb12e038e5c7f91e120ed4b7ebf1de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
400 '0x046170707374616b656170707374616b65000020c65abc8ed70a00000000000000'],
401 ])]);
402
403 // const pendingUnstaked = await helper.staking.getPendingUnstakePerBlock()
404 expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([[helper.address.normalizeSubstrateToChainFormat('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'), '0x00000000000000056bc75e2d63100000']]);
405 expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([[helper.address.normalizeSubstrateToChainFormat('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'), '0x00000000000000056bc75e2d63100000']]);
406 await correctState();
407
408 expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([]);
409 expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([]);
410
411 });
412
413 itSub('(!negative test!) Only works when Maintenance mode is disabled', async({helper}) => {
414 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', [])).to.be.fulfilled;
415 await expect(correctState()).to.be.rejectedWith('The network is still in maintenance mode');
416 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;
417 });
418 });
419 });
370});420});
371421
deletedtests/src/migrations/942057-appPromotion/afterMaintenance.test.tsdiffbeforeafterboth

no changes

deletedtests/src/migrations/942057-appPromotion/correctStateAfterMaintenance.tsdiffbeforeafterboth

no changes

deletedtests/src/migrations/942057-appPromotion/runCheckState.tsdiffbeforeafterboth

no changes

addedtests/src/migrations/correctStateAfterMaintenance.tsdiffbeforeafterboth

no changes

addedtests/src/migrations/runCheckState.tsdiffbeforeafterboth

no changes