difftreelog
Merge pull request #950 from UniqueNetwork/tests/move-maintenance-to-seq
in: master
Move maintenance tests to seqtest
6 files changed
tests/src/maintenance.seqtest.tsdiffbeforeafterboth19import {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';222323async 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 });371372 describe('Integration Test: Maintenance mode & App Promo', () => {373 let superuser: IKeyringPair;374375 before(async function() {376 await usingPlaygrounds(async (helper, privateKey) => {377 requirePalletsOrSkip(this, helper, [Pallets.Maintenance]);378 superuser = await privateKey('//Alice');379 });380 });381382 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();393394 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.system.setStorage([395 // pendingUnstake(1 -> [superuser.address, 100UNQ])396 ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f5153cb1f00942ff401000000',397 '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],398 // pendingUnstake(2 -> [superuser.address, 100UNQ])399 ['0x42b67acb8bd223c60d0c8f621ffefc0ae280fa2db99bd3827aac976de75af95f9eb2dcce60f37a2702000000',400 '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000010632d5ec76b0500000000000000'],401 // Balances.freezes(superuser.address -> freeze with app promo id and 200 UNQ )402 ['0xc2261276cc9d1f8598ea4b6a74b15c2fb1c0eb12e038e5c7f91e120ed4b7ebf1de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',403 '0x046170707374616b656170707374616b65000020c65abc8ed70a00000000000000'],404 ])]);405406 expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);407 expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([[superuser.address, '0x00000000000000056bc75e2d63100000']]);408 expect((await api.query.balances.freezes(superuser.address))409 .map(lock => ({id: lock.id.toUtf8(), amount: lock.amount.toBigInt()})))410 .to.be.deep.equal([{id: 'appstakeappstake', amount: 200000000000000000000n}]);411 await correctState();412413 expect((await api.query.appPromotion.pendingUnstake(1)).toJSON()).to.be.deep.equal([]);414 expect((await api.query.appPromotion.pendingUnstake(2)).toJSON()).to.be.deep.equal([]);415 expect((await api.query.balances.freezes(superuser.address)).toJSON()).to.be.deep.equal([]);416417 });418419 itSub('(!negative test!) Only works when Maintenance mode is disabled', async({helper}) => {420 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', [])).to.be.fulfilled;421 await expect(correctState()).to.be.rejectedWith('The network is still in maintenance mode');422 await expect(helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', [])).to.be.fulfilled;423 });424 });425 });370});426});371427tests/src/migrations/942057-appPromotion/afterMaintenance.test.tsdiffbeforeafterbothno changes
tests/src/migrations/942057-appPromotion/correctStateAfterMaintenance.tsdiffbeforeafterbothno changes
tests/src/migrations/942057-appPromotion/runCheckState.tsdiffbeforeafterbothno changes
tests/src/migrations/correctStateAfterMaintenance.tsdiffbeforeafterbothno changes
tests/src/migrations/runCheckState.tsdiffbeforeafterbothno changes