difftreelog
Tests up
in: master
1 file changed
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth90 }));90 }));91 91 92 [92 [93 {mode: 'nft' as const, requiredPallets: [Pallets.ReFungible]},93 {mode: 'nft' as const, requiredPallets: []},94 {mode: 'rft' as const, requiredPallets: []},94 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},95 ].map(testCase => 95 ].map(testCase => 96 itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {96 itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {97 const caller = await helper.eth.createAccountWithBalance(donor);97 const caller = await helper.eth.createAccountWithBalance(donor);132 }));132 }));133 133 134 [134 [135 {mode: 'nft' as const, requiredPallets: [Pallets.ReFungible]},135 {mode: 'nft' as const, requiredPallets: []},136 {mode: 'rft' as const, requiredPallets: []},136 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},137 ].map(testCase => 137 ].map(testCase => 138 itEth.ifWithPallets(`Can be deleted fro ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {138 itEth.ifWithPallets(`Can be deleted for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {139 const caller = await helper.eth.createAccountWithBalance(donor);139 const caller = await helper.eth.createAccountWithBalance(donor);140 const collection = await helper[testCase.mode].mintCollection(alice, {140 const collection = await helper[testCase.mode].mintCollection(alice, {141 tokenPropertyPermissions: [{141 tokenPropertyPermissions: [{241 caller = await helper.eth.createAccountWithBalance(donor);241 caller = await helper.eth.createAccountWithBalance(donor);242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);243 // Caller not an owner and not an admin, so he cannot set properties:243 // Caller not an owner and not an admin, so he cannot set properties:244 // FIXME: Can setProperties as non owner and non admin245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');244 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');246 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;247246270 }));269 }));271270272 [271 [273 {method: 'deleteProperty', methodParams: ['testKey_2']}, // FIXME: the method is gone?272 {method: 'deleteProperty', methodParams: ['testKey_2']},274 {method: 'deleteProperties', methodParams: [['testKey_2']]},273 {method: 'deleteProperties', methodParams: [['testKey_2']]},275 ].map(testCase => 274 ].map(testCase => 276 itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {275 itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {277 caller = await helper.eth.createAccountWithBalance(donor);276 caller = await helper.eth.createAccountWithBalance(donor);278 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');277 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');279 // Caller not an owner and not an admin, so he cannot set properties:278 // Caller not an owner and not an admin, so he cannot set properties:280 // FIXME: non owner and non admin can deleteProperties281 // await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});282 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');279 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');283 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;280 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;284281288 expect(actualProps).to.deep.eq(expectedProps);285 expect(actualProps).to.deep.eq(expectedProps);289 }));286 }));290287 288 [289 {method: 'deleteProperty', methodParams: ['testKey_3']},290 {method: 'deleteProperties', methodParams: [['testKey_3']]},291 ].map(testCase => 291 itEth('Cannot delete non-existing properties', async () => {292 itEth(`[${testCase.method}] Cannot delete non-existing properties`, async ({helper}) => {292293 caller = await helper.eth.createAccountWithBalance(donor);294 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');295 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});296 // Caller cannot delete non-existing properties:297 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');298 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;299 // Props have not changed:300 const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));301 const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();302 expect(actualProps).to.deep.eq(expectedProps);293 });303 }));294});304});295305296306