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