git.delta.rocks / unique-network / refs/commits / 6da085670d5d

difftreelog

Skip rft tests

Max Andreev2022-12-07parent: #c19d240.patch.diff
in: master

2 files changed

modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -1,4 +1,5 @@
 import {IKeyringPair} from '@polkadot/types/types';
+import {Pallets} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
 
 
@@ -13,10 +14,10 @@
 
   [
     {case: 'nft' as const, method: 'createNFTCollection' as const},
-    {case: 'rft' as const, method: 'createRFTCollection' as const},
+    {case: 'rft' as const, method: 'createRFTCollection' as const, requiredPallets: [Pallets.ReFungible]},
     {case: 'ft' as const, method: 'createFTCollection' as const},
   ].map(testCase =>
-    itEth(`for ${testCase.case}`, async ({helper}) => {
+    itEth.ifWithPallets(`for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
       const {collectionId, collectionAddress} = await helper.eth.createCollecion(testCase.method, owner, 'Limits', 'absolutely anything', 'FLO', 18);
       const limits = {
@@ -71,10 +72,10 @@
 
   [
     {case: 'nft' as const, method: 'createNFTCollection' as const},
-    {case: 'rft' as const, method: 'createRFTCollection' as const},
+    {case: 'rft' as const, method: 'createRFTCollection' as const, requiredPallets: [Pallets.ReFungible]},
     {case: 'ft' as const, method: 'createFTCollection' as const},
   ].map(testCase =>
-    itEth(`for ${testCase.case}`, async ({helper}) => {
+    itEth.ifWithPallets(`for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
       const invalidLimits = {
         accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
         transfersEnabled: 3,
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
18import {Pallets} from '../util';18import {Pallets} from '../util';
19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';
21import {TCollectionMode} from '../util/playgrounds/types';
2221
23describe('EVM collection properties', () => {22describe('EVM collection properties', () => {
24 let donor: IKeyringPair;23 let donor: IKeyringPair;
134 });133 });
135 });134 });
136135
136 [
137 const checkERC721Metadata = async (helper: EthUniqueHelper, mode: 'nft' | 'rft') => {137 {case: 'nft' as const},
138 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
139 ].map(testCase =>
140 itEth.ifWithPallets(`ERC721Metadata property can be set for ${testCase.case} collection`, testCase.requiredPallets || [], async ({helper}) => {
138 const caller = await helper.eth.createAccountWithBalance(donor);141 const caller = await helper.eth.createAccountWithBalance(donor);
139 const bruh = await helper.eth.createAccountWithBalance(donor);142 const bruh = await helper.eth.createAccountWithBalance(donor);
140143
143 const URI = 'uri1';146 const URI = 'uri1';
144147
145 const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);148 const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);
146 const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection';149 const creatorMethod = testCase.case === 'rft' ? 'createRFTCollection' : 'createNFTCollection';
147150
148 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');151 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');
149 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);152 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);
150153
151 const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);154 const contract = helper.ethNativeContract.collectionById(collectionId, testCase.case, caller);
152 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too155 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too
153156
154 const collection1 = helper.nft.getCollectionObject(collectionId);157 const collection1 = helper.nft.getCollectionObject(collectionId);
204207
205 await contract.methods.setProperties(tokenId2, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();208 await contract.methods.setProperties(tokenId2, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();
206 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);209 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
207 };210 }));
208
209 itEth('ERC721Metadata property can be set for NFT collection', async({helper}) => {
210 await checkERC721Metadata(helper, 'nft');
211 });
212
213 itEth.ifWithPallets('ERC721Metadata property can be set for RFT collection', [Pallets.ReFungible], async({helper}) => {
214 await checkERC721Metadata(helper, 'rft');
215 });
216});211});
217212
218describe('EVM collection property', () => {213describe('EVM collection property', () => {
224 });219 });
225 });220 });
226221
222 [
223 {case: 'nft' as const},
224 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
227 async function testSetReadProperties(helper: EthUniqueHelper, mode: TCollectionMode) {225 {case: 'ft' as const},
226 ].map(testCase =>
227 itEth.ifWithPallets(`can set/read properties ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
228 const collection = await helper[mode].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});228 const collection = await helper[testCase.case].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
229229
230 const sender = await helper.eth.createAccountWithBalance(donor, 100n);230 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
231 await collection.addAdmin(donor, {Ethereum: sender});231 await collection.addAdmin(donor, {Ethereum: sender});
232232
233 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);233 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
234 const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);234 const contract = helper.ethNativeContract.collection(collectionAddress, testCase.case, sender);
235235
236 const keys = ['key0', 'key1'];236 const keys = ['key0', 'key1'];
237237
243 await contract.methods.setCollectionProperties(writeProperties).send();243 await contract.methods.setCollectionProperties(writeProperties).send();
244 const readProperties = await contract.methods.collectionProperties([keys[0], keys[1]]).call();244 const readProperties = await contract.methods.collectionProperties([keys[0], keys[1]]).call();
245 expect(readProperties).to.be.like(writeProperties);245 expect(readProperties).to.be.like(writeProperties);
246 }246 }));
247247
248 itEth('Set/read properties ft', async ({helper}) => {248 [
249 await testSetReadProperties(helper, 'ft');249 {case: 'nft' as const},
250 });250 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
251 itEth.ifWithPallets('Set/read properties rft', [Pallets.ReFungible], async ({helper}) => {
252 await testSetReadProperties(helper, 'rft');
253 });
254 itEth('Set/read properties nft', async ({helper}) => {
255 await testSetReadProperties(helper, 'nft');
256 });
257
258 async function testDeleteProperties(helper: EthUniqueHelper, mode: TCollectionMode) {251 {case: 'ft' as const},
252 ].map(testCase =>
253 itEth.ifWithPallets(`can delete properties ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
259 const collection = await helper[mode].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});254 const collection = await helper[testCase.case].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
260255
261 const sender = await helper.eth.createAccountWithBalance(donor, 100n);256 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
262 await collection.addAdmin(donor, {Ethereum: sender});257 await collection.addAdmin(donor, {Ethereum: sender});
263258
264 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);259 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
265 const contract = helper.ethNativeContract.collection(collectionAddress, mode, sender);260 const contract = helper.ethNativeContract.collection(collectionAddress, testCase.case, sender);
266261
267 const keys = ['key0', 'key1', 'key2', 'key3'];262 const keys = ['key0', 'key1', 'key2', 'key3'];
268263
289 const readProperties = await contract.methods.collectionProperties([]).call();284 const readProperties = await contract.methods.collectionProperties([]).call();
290 expect(readProperties).to.be.like(expectProperties);285 expect(readProperties).to.be.like(expectProperties);
291 }286 }
292 }287 }));
293
294 itEth('Delete properties ft', async ({helper}) => {
295 await testDeleteProperties(helper, 'ft');
296 });
297 itEth.ifWithPallets('Delete properties rft', [Pallets.ReFungible], async ({helper}) => {
298 await testDeleteProperties(helper, 'rft');
299 });
300 itEth('Delete properties nft', async ({helper}) => {
301 await testDeleteProperties(helper, 'nft');
302 });
303
304});288});
305289