difftreelog
Tests app-promotion: cleanup before scripts
in: master
2 files changed
tests/src/app-promotion.seqtest.tsdiffbeforeafterboth1// 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;24let nominal: bigint;25let palletAddress;26let accounts: IKeyringPair[];272829describe('App promotion', () => {30 before(async function () {31 await usingPlaygrounds(async (helper, privateKey) => {32 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);33 superuser = await privateKey('//Alice');34 donor = await privateKey({filename: __filename});35 palletAddress = helper.arrange.calculatePalleteAddress('appstake');36 palletAdmin = await privateKey('//PromotionAdmin');37 const api = helper.getApi();38 await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));39 nominal = helper.balance.getOneTokenNominal();40 await helper.balance.transferToSubstrate(donor, palletAdmin.address, 1000n * nominal);41 await helper.balance.transferToSubstrate(donor, palletAddress, 1000n * nominal);42 accounts = await helper.arrange.createCrowd(100, 1000n, donor); // create accounts-pool to speed up tests43 });44 });4546 describe('admin adress', () => {47 itSub('can be set by sudo only', async ({helper}) => {48 const api = helper.getApi();49 const nonAdmin = accounts.pop()!;50 // nonAdmin can not set admin not from himself nor as a sudo51 await expect(helper.signTransaction(nonAdmin, api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address}))).to.be.rejected;52 await expect(helper.signTransaction(nonAdmin, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address})))).to.be.rejected;53 });54 55 itSub('can be any valid CrossAccountId', async ({helper}) => {56 // We are not going to set an eth address as a sponsor,57 // but we do want to check, it doesn't break anything;58 const api = helper.getApi();59 const account = accounts.pop()!;60 const ethAccount = helper.address.substrateToEth(account.address); 61 // Alice sets Ethereum address as a sudo. Then Substrate address back...62 await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Ethereum: ethAccount})))).to.be.fulfilled;63 await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;64 65 // ...It doesn't break anything;66 const collection = await helper.nft.mintCollection(account, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});67 await expect(helper.signTransaction(account, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;68 });69 70 itSub('can be reassigned', async ({helper}) => {71 const api = helper.getApi();72 const [oldAdmin, newAdmin, collectionOwner] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];73 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});74 75 await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: oldAdmin.address})))).to.be.fulfilled;76 await expect(helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: newAdmin.address})))).to.be.fulfilled;77 await expect(helper.signTransaction(oldAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;78 79 await expect(helper.signTransaction(newAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;80 });81 });82});83tests/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
});
});