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

difftreelog

Add permition tests

Max Andreev2022-12-13parent: #0c73e0a.patch.diff
in: master

1 file changed

modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
120 .setCollectionLimit(CollectionLimits.SponsoredDataSize, true, -1).send()).to.throw('value out-of-bounds');120 .setCollectionLimit(CollectionLimits.SponsoredDataSize, true, -1).send()).to.throw('value out-of-bounds');
121 }));121 }));
122
123 [
124 {case: 'nft' as const, method: 'createNFTCollection' as const},
125 {case: 'rft' as const, method: 'createRFTCollection' as const, requiredPallets: [Pallets.ReFungible]},
126 {case: 'ft' as const, method: 'createFTCollection' as const},
127 ].map(testCase =>
128 itEth.ifWithPallets(`Non-owner and non-admin cannot set collection limits for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
129 const owner = await helper.eth.createAccountWithBalance(donor);
130 const nonOwner = await helper.eth.createAccountWithBalance(donor);
131 const {collectionAddress} = await helper.eth.createCollecion(testCase.method, owner, 'Limits', 'absolutely anything', 'FLO', 18);
132
133 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
134 await expect(collectionEvm.methods
135 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
136 .call({from: nonOwner}))
137 .to.be.rejectedWith('NoPermission');
138
139 await expect(collectionEvm.methods
140 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
141 .send({from: nonOwner}))
142 .to.be.rejected;
143 }));
122});144});
123145