git.delta.rocks / unique-network / refs/commits / 3833b2da5ea7

difftreelog

Tests app-promotion: cleanup before scripts

Maksandre2022-10-10parent: #6c62f5a.patch.diff
in: master

2 files changed

modifiedtests/src/app-promotion.seqtest.tsdiffbeforeafterboth
after · tests/src/app-promotion.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 {itSub, usingPlaygrounds, Pallets, requirePalletsOrSkip} from './util/playgrounds';19import {expect} from './eth/util/playgrounds';2021let superuser: IKeyringPair;22let donor: IKeyringPair;23let palletAdmin: IKeyringPair;2425describe('App promotion', () => {26  before(async function () {27    await usingPlaygrounds(async (helper, privateKey) => {28      requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);29      superuser = await privateKey('//Alice');30      donor = await privateKey({filename: __filename});31      palletAdmin = await privateKey('//PromotionAdmin');32      const api = helper.getApi();33      await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));34    });35  });3637  describe('admin adress', () => {38    itSub('can be set by sudo only', async ({helper}) => {39      const api = helper.getApi();40      const [nonAdmin] = await helper.arrange.createAccounts([10n], donor);41      // nonAdmin can not set admin not from himself nor as a sudo42      await expect(helper.signTransaction(nonAdmin, api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address}))).to.be.rejected;43      await expect(helper.signTransaction(nonAdmin, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address})))).to.be.rejected;44    });45    46    itSub('can be any valid CrossAccountId', async ({helper}) => {47      // We are not going to set an eth address as a sponsor,48      // but we do want to check, it doesn't break anything;49      const api = helper.getApi();50      const [account] = await helper.arrange.createAccounts([10n], donor);51      const ethAccount = helper.address.substrateToEth(account.address); 52      // Alice sets Ethereum address as a sudo. Then Substrate address back...53      await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Ethereum: ethAccount})))).to.be.fulfilled;54      await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;55        56      // ...It doesn't break anything;57      const collection = await helper.nft.mintCollection(account, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});58      await expect(helper.signTransaction(account, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;59    });60  61    itSub('can be reassigned', async ({helper}) => {62      const api = helper.getApi();63      const [oldAdmin, newAdmin, collectionOwner] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);64      const collection  = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});65        66      await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: oldAdmin.address})))).to.be.fulfilled;67      await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: newAdmin.address})))).to.be.fulfilled;68      await expect(helper.signTransaction(oldAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;69        70      await expect(helper.signTransaction(newAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;71    });72  });73});74
modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
--- a/tests/src/app-promotion.test.ts
+++ b/tests/src/app-promotion.test.ts
@@ -39,8 +39,6 @@
       palletAddress = helper.arrange.calculatePalleteAddress('appstake');
       palletAdmin = await privateKey('//PromotionAdmin');
       nominal = helper.balance.getOneTokenNominal();
-      await helper.balance.transferToSubstrate(donor, palletAdmin.address, 1000n * nominal);
-      await helper.balance.transferToSubstrate(donor, palletAddress, 1000n * nominal);
       accounts = await helper.arrange.createCrowd(100, 1000n, donor); // create accounts-pool to speed up tests
     });
   });