From c5c3942d47135d1c82d480271376aca7107da8d1 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 29 Jun 2022 07:27:44 +0000 Subject: [PATCH] CORE-410 Adapt token property test for ReFungible collection --- --- a/tests/src/nesting/properties.test.ts +++ b/tests/src/nesting/properties.test.ts @@ -647,8 +647,7 @@ nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)}); await addCollectionAdminExpectSuccess(alice, collection, bob.address); - await transferExpectSuccess(collection, token, alice, charlie); - }); + await transferExpectSuccess(collection, token, alice, charlie); }); }); it('Reads yet empty properties of a token', async () => { @@ -699,6 +698,45 @@ }); }); + it.only('Assigns properties to a token according to permissions (ReFungible)', async () => { + await usingApi(async api => { + const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}}); + const token = await createItemExpectSuccess(alice, collection, 'ReFungible'); + await addCollectionAdminExpectSuccess(alice, collection, bob.address); + await transferExpectSuccess(collection, token, alice, charlie, 1, 'ReFungible'); + + const propertyKeys: string[] = []; + let i = 0; + for (const permission of permissions) { + for (const signer of permission.signers) { + const key = i + '_' + signer.address; + propertyKeys.push(key); + + await expect(executeTransaction( + api, + alice, + api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), + ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected; + + await expect(executeTransaction( + api, + signer, + api.tx.unique.setTokenProperties(collection, token, [{key: key, value: 'Serotonin increase'}]), + ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected; + } + + i++; + } + + // const properties = (await api.rpc.unique.tokenProperties(collection, token, propertyKeys)).toHuman() as any[]; + // const tokensData = (await api.rpc.unique.tokenData(collection, token, propertyKeys)).toHuman().properties as any[]; + // for (let i = 0; i < properties.length; i++) { + // expect(properties[i].value).to.be.equal('Serotonin increase'); + // expect(tokensData[i].value).to.be.equal('Serotonin increase'); + // } + }); + }); + it('Changes properties of a token according to permissions', async () => { await usingApi(async api => { const propertyKeys: string[] = []; -- gitstuff