From 1e2863e228ee39367dcf3b7f4bf589e9498a5fd6 Mon Sep 17 00:00:00 2001 From: ut-akuznetsov <59873862+ut-akuznetsov@users.noreply.github.com> Date: Fri, 16 Dec 2022 14:06:41 +0000 Subject: [PATCH] Merge pull request #780 from UniqueNetwork/feature/properties-for-ft-collections --- --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -1222,7 +1222,8 @@ Ok(()) } - /// Set scouped collection property. + /// Set a scoped collection property, where the scope is a special prefix + /// prohibiting a user to change the property. /// /// * `collection_id` - ID of the collection for which the property is being set. /// * `scope` - Property scope. @@ -1240,7 +1241,8 @@ Ok(()) } - /// Set scouped collection properties. + /// Set scoped collection properties, where the scope is a special prefix + /// prohibiting a user to change the properties. /// /// * `collection_id` - ID of the collection for which the properties is being set. /// * `scope` - Property scope. --- a/pallets/fungible/src/common.rs +++ b/pallets/fungible/src/common.rs @@ -18,7 +18,10 @@ use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get}; use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData}; -use pallet_common::{CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight}; +use pallet_common::{ + CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight, + weights::WeightInfo as _, +}; use pallet_structure::Error as StructureError; use sp_runtime::ArithmeticError; use sp_std::{vec::Vec, vec}; @@ -53,14 +56,12 @@ >::burn_item() } - fn set_collection_properties(_amount: u32) -> Weight { - // Error - Weight::zero() + fn set_collection_properties(amount: u32) -> Weight { + >::set_collection_properties(amount) } - fn delete_collection_properties(_amount: u32) -> Weight { - // Error - Weight::zero() + fn delete_collection_properties(amount: u32) -> Weight { + >::delete_collection_properties(amount) } fn set_token_properties(_amount: u32) -> Weight { @@ -294,18 +295,28 @@ fn set_collection_properties( &self, - _sender: T::CrossAccountId, - _property: Vec, + sender: T::CrossAccountId, + properties: Vec, ) -> DispatchResultWithPostInfo { - fail!(>::SettingPropertiesNotAllowed) + let weight = >::set_collection_properties(properties.len() as u32); + + with_weight( + >::set_collection_properties(self, &sender, properties), + weight, + ) } fn delete_collection_properties( &self, - _sender: &T::CrossAccountId, - _property_keys: Vec, + sender: &T::CrossAccountId, + property_keys: Vec, ) -> DispatchResultWithPostInfo { - fail!(>::SettingPropertiesNotAllowed) + let weight = >::delete_collection_properties(property_keys.len() as u32); + + with_weight( + >::delete_collection_properties(self, sender, property_keys), + weight, + ) } fn set_token_properties( --- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -80,11 +80,11 @@ use core::ops::Deref; use evm_coder::ToLog; -use frame_support::{ensure}; +use frame_support::ensure; use pallet_evm::account::CrossAccountId; use up_data_structs::{ AccessMode, CollectionId, CollectionFlags, TokenId, CreateCollectionData, - mapping::TokenAddressMapping, budget::Budget, + mapping::TokenAddressMapping, budget::Budget, PropertyKey, Property, }; use pallet_common::{ Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, @@ -260,7 +260,25 @@ Ok(()) } - ///Checks if collection has tokens. Return `true` if it has. + /// Add properties to the collection. + pub fn set_collection_properties( + collection: &FungibleHandle, + sender: &T::CrossAccountId, + properties: Vec, + ) -> DispatchResult { + >::set_collection_properties(collection, sender, properties) + } + + /// Delete properties of the collection, associated with the provided keys. + pub fn delete_collection_properties( + collection: &FungibleHandle, + sender: &T::CrossAccountId, + property_keys: Vec, + ) -> DispatchResult { + >::delete_collection_properties(collection, sender, property_keys) + } + + /// Checks if collection has tokens. Return `true` if it has. fn collection_has_tokens(collection_id: CollectionId) -> bool { >::get(collection_id) != 0 } --- a/tests/package.json +++ b/tests/package.json @@ -45,6 +45,7 @@ "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts", "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts", "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.test.ts ./**/tokenProperties.test.ts ./**/getPropertiesRpc.test.ts", + "testCollectionProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.test.ts", "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts", "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts", "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts", --- a/tests/src/nesting/collectionProperties.test.ts +++ b/tests/src/nesting/collectionProperties.test.ts @@ -15,8 +15,7 @@ // along with Unique Network. If not, see . import {IKeyringPair} from '@polkadot/types/types'; -import {itSub, Pallets, usingPlaygrounds, expect} from '../util'; -import {UniqueBaseCollection} from '../util/playgrounds/unique'; +import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip} from '../util'; describe('Integration Test: Collection Properties', () => { let alice: IKeyringPair; @@ -32,116 +31,98 @@ itSub('Properties are initially empty', async ({helper}) => { const collection = await helper.nft.mintCollection(alice); expect(await collection.getProperties()).to.be.empty; - }); - - async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) { - // As owner - await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}])).to.be.fulfilled; - - await collection.addAdmin(alice, {Substrate: bob.address}); - - // As administrator - await expect(collection.setProperties(bob, [{key: 'black_hole'}])).to.be.fulfilled; - - const properties = await collection.getProperties(); - expect(properties).to.include.deep.members([ - {key: 'electron', value: 'come bond'}, - {key: 'black_hole', value: ''}, - ]); - } - - itSub('Sets properties for a NFT collection', async ({helper}) => { - await testSetsPropertiesForCollection(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Sets properties for a ReFungible collection', [Pallets.ReFungible], async ({helper}) => { - await testSetsPropertiesForCollection(await helper.rft.mintCollection(alice)); }); - - async function testCheckValidNames(collection: UniqueBaseCollection) { - // alpha symbols - await expect(collection.setProperties(alice, [{key: 'answer'}])).to.be.fulfilled; - - // numeric symbols - await expect(collection.setProperties(alice, [{key: '451'}])).to.be.fulfilled; - - // underscore symbol - await expect(collection.setProperties(alice, [{key: 'black_hole'}])).to.be.fulfilled; - - // dash symbol - await expect(collection.setProperties(alice, [{key: '-'}])).to.be.fulfilled; - - // dot symbol - await expect(collection.setProperties(alice, [{key: 'once.in.a.long.long.while...', value: 'you get a little lost'}])).to.be.fulfilled; - - const properties = await collection.getProperties(); - expect(properties).to.include.deep.members([ - {key: 'answer', value: ''}, - {key: '451', value: ''}, - {key: 'black_hole', value: ''}, - {key: '-', value: ''}, - {key: 'once.in.a.long.long.while...', value: 'you get a little lost'}, - ]); - } - - itSub('Check valid names for NFT collection properties keys', async ({helper}) => { - await testCheckValidNames(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Check valid names for ReFungible collection properties keys', [Pallets.ReFungible], async ({helper}) => { - await testCheckValidNames(await helper.rft.mintCollection(alice)); - }); - - async function testChangesProperties(collection: UniqueBaseCollection) { - await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: ''}])).to.be.fulfilled; - - // Mutate the properties - await expect(collection.setProperties(alice, [{key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled; - - const properties = await collection.getProperties(); - expect(properties).to.include.deep.members([ - {key: 'electron', value: 'come bond'}, - {key: 'black_hole', value: 'LIGO'}, - ]); - } - - itSub('Changes properties of a NFT collection', async ({helper}) => { - await testChangesProperties(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Changes properties of a ReFungible collection', [Pallets.ReFungible], async ({helper}) => { - await testChangesProperties(await helper.rft.mintCollection(alice)); - }); - - async function testDeleteProperties(collection: UniqueBaseCollection) { - await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled; - - await expect(collection.deleteProperties(alice, ['electron'])).to.be.fulfilled; - - const properties = await collection.getProperties(['black_hole', 'electron']); - expect(properties).to.be.deep.equal([ - {key: 'black_hole', value: 'LIGO'}, - ]); - } - - itSub('Deletes properties of a NFT collection', async ({helper}) => { - await testDeleteProperties(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Deletes properties of a ReFungible collection', [Pallets.ReFungible], async ({helper}) => { - await testDeleteProperties(await helper.rft.mintCollection(alice)); - }); [ - // TODO enable properties for FT collection in Substrate (release 040) - // {mode: 'ft' as const, requiredPallets: []}, {mode: 'nft' as const, requiredPallets: []}, + {mode: 'ft' as const, requiredPallets: []}, {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, - ].map(testCase => - itSub.ifWithPallets(`Allows modifying a collection property multiple times with the same size (${testCase.mode})`, testCase.requiredPallets, async({helper}) => { + ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => { + before(async function() { + // eslint-disable-next-line require-await + await usingPlaygrounds(async helper => { + requirePalletsOrSkip(this, helper, testSuite.requiredPallets); + }); + }); + + itSub('Sets properties for a collection', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + // As owner + await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}])).to.be.fulfilled; + + await collection.addAdmin(alice, {Substrate: bob.address}); + + // As administrator + await expect(collection.setProperties(bob, [{key: 'black_hole'}])).to.be.fulfilled; + + const properties = await collection.getProperties(); + expect(properties).to.include.deep.members([ + {key: 'electron', value: 'come bond'}, + {key: 'black_hole', value: ''}, + ]); + }); + + itSub('Check valid names for collection properties keys', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + // alpha symbols + await expect(collection.setProperties(alice, [{key: 'answer'}])).to.be.fulfilled; + + // numeric symbols + await expect(collection.setProperties(alice, [{key: '451'}])).to.be.fulfilled; + + // underscore symbol + await expect(collection.setProperties(alice, [{key: 'black_hole'}])).to.be.fulfilled; + + // dash symbol + await expect(collection.setProperties(alice, [{key: '-'}])).to.be.fulfilled; + + // dot symbol + await expect(collection.setProperties(alice, [{key: 'once.in.a.long.long.while...', value: 'you get a little lost'}])).to.be.fulfilled; + + const properties = await collection.getProperties(); + expect(properties).to.include.deep.members([ + {key: 'answer', value: ''}, + {key: '451', value: ''}, + {key: 'black_hole', value: ''}, + {key: '-', value: ''}, + {key: 'once.in.a.long.long.while...', value: 'you get a little lost'}, + ]); + }); + + itSub('Changes properties of a collection', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: ''}])).to.be.fulfilled; + + // Mutate the properties + await expect(collection.setProperties(alice, [{key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled; + + const properties = await collection.getProperties(); + expect(properties).to.include.deep.members([ + {key: 'electron', value: 'come bond'}, + {key: 'black_hole', value: 'LIGO'}, + ]); + }); + + itSub('Deletes properties of a collection', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled; + + await expect(collection.deleteProperties(alice, ['electron'])).to.be.fulfilled; + + const properties = await collection.getProperties(['black_hole', 'electron']); + expect(properties).to.be.deep.equal([ + {key: 'black_hole', value: 'LIGO'}, + ]); + }); + + itSub('Allows modifying a collection property multiple times with the same size', async({helper}) => { const propKey = 'tok-prop'; - const collection = await helper[testCase.mode].mintCollection(alice); + const collection = await helper[testSuite.mode].mintCollection(alice); const maxCollectionPropertiesSize = 40960; @@ -166,18 +147,12 @@ const consumedSpace = await collection.getPropertiesConsumedSpace(); expect(consumedSpace).to.be.equal(originalSpace); } - })); + }); - [ - // TODO enable properties for FT collection in Substrate (release 040) - // {mode: 'ft' as const, requiredPallets: []}, - {mode: 'nft' as const, requiredPallets: []}, - {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, - ].map(testCase => - itSub.ifWithPallets(`Adding then removing a collection property doesn't change the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => { + itSub('Adding then removing a collection property doesn\'t change the consumed space', async({helper}) => { const propKey = 'tok-prop'; - const collection = await helper[testCase.mode].mintCollection(alice); + const collection = await helper[testSuite.mode].mintCollection(alice); const originalSpace = await collection.getPropertiesConsumedSpace(); const propDataSize = 4096; @@ -190,18 +165,12 @@ await collection.deleteProperties(alice, [propKey]); consumedSpace = await collection.getPropertiesConsumedSpace(); expect(consumedSpace).to.be.equal(originalSpace); - })); + }); - [ - // TODO enable properties for FT collection in Substrate (release 040) - // {mode: 'ft' as const, requiredPallets: []}, - {mode: 'nft' as const, requiredPallets: []}, - {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, - ].map(testCase => - itSub.ifWithPallets(`Modifying a collection property with different sizes correctly changes the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => { + itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => { const propKey = 'tok-prop'; - const collection = await helper[testCase.mode].mintCollection(alice); + const collection = await helper[testSuite.mode].mintCollection(alice); const originalSpace = await collection.getPropertiesConsumedSpace(); const initPropDataSize = 4096; @@ -229,7 +198,8 @@ consumedSpace = await collection.getPropertiesConsumedSpace(); expectedConsumedSpaceDiff = biggerPropDataSize - smallerPropDataSize; expect(consumedSpace).to.be.equal(biggerPropDataSize - expectedConsumedSpaceDiff); - })); + }); + })); }); describe('Negative Integration Test: Collection Properties', () => { @@ -242,119 +212,108 @@ [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor); }); }); + + [ + {mode: 'nft' as const, requiredPallets: []}, + {mode: 'ft' as const, requiredPallets: []}, + {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, + ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => { + before(async function() { + // eslint-disable-next-line require-await + await usingPlaygrounds(async helper => { + requirePalletsOrSkip(this, helper, testSuite.requiredPallets); + }); + }); - async function testFailsSetPropertiesIfNotOwnerOrAdmin(collection: UniqueBaseCollection) { - await expect(collection.setProperties(bob, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])) - .to.be.rejectedWith(/common\.NoPermission/); - - expect(await collection.getProperties()).to.be.empty; - } - - itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => { - await testFailsSetPropertiesIfNotOwnerOrAdmin(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Fails to set properties in a ReFungible collection if not its onwer/administrator', [Pallets.ReFungible], async ({helper}) => { - await testFailsSetPropertiesIfNotOwnerOrAdmin(await helper.rft.mintCollection(alice)); - }); + itSub('Fails to set properties in a collection if not its onwer/administrator', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + await expect(collection.setProperties(bob, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])) + .to.be.rejectedWith(/common\.NoPermission/); - async function testFailsSetPropertiesThatExeedLimits(collection: UniqueBaseCollection) { - const spaceLimit = (await (collection.helper!.api! as any).query.common.collectionProperties(collection.collectionId)).spaceLimit.toNumber(); + expect(await collection.getProperties()).to.be.empty; + }); - // Mute the general tx parsing error, too many bytes to process - { - console.error = () => {}; + itSub('Fails to set properties that exceed the limits', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + const spaceLimit = (await (collection.helper!.api! as any).query.common.collectionProperties(collection.collectionId)).spaceLimit.toNumber(); + + // Mute the general tx parsing error, too many bytes to process + { + console.error = () => {}; + await expect(collection.setProperties(alice, [ + {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 9))}, + ])).to.be.rejected; + } + + expect(await collection.getProperties(['electron'])).to.be.empty; + await expect(collection.setProperties(alice, [ - {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 9))}, - ])).to.be.rejected; - } - - expect(await collection.getProperties(['electron'])).to.be.empty; - - await expect(collection.setProperties(alice, [ - {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 18))}, - {key: 'black_hole', value: '0'.repeat(Math.ceil(spaceLimit! / 2))}, - ])).to.be.rejectedWith(/common\.NoSpaceForProperty/); - - expect(await collection.getProperties(['electron', 'black_hole'])).to.be.empty; - } - - itSub('Fails to set properties that exceed the limits (NFT)', async ({helper}) => { - await testFailsSetPropertiesThatExeedLimits(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Fails to set properties that exceed the limits (ReFungible)', [Pallets.ReFungible], async ({helper}) => { - await testFailsSetPropertiesThatExeedLimits(await helper.rft.mintCollection(alice)); - }); + {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 18))}, + {key: 'black_hole', value: '0'.repeat(Math.ceil(spaceLimit! / 2))}, + ])).to.be.rejectedWith(/common\.NoSpaceForProperty/); - async function testFailsSetMorePropertiesThanAllowed(collection: UniqueBaseCollection) { - const propertiesToBeSet = []; - for (let i = 0; i < 65; i++) { - propertiesToBeSet.push({ - key: 'electron_' + i, - value: Math.random() > 0.5 ? 'high' : 'low', - }); - } - - await expect(collection.setProperties(alice, propertiesToBeSet)). - to.be.rejectedWith(/common\.PropertyLimitReached/); - - expect(await collection.getProperties()).to.be.empty; - } - - itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => { - await testFailsSetMorePropertiesThanAllowed(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Fails to set more properties than it is allowed (ReFungible)', [Pallets.ReFungible], async ({helper}) => { - await testFailsSetMorePropertiesThanAllowed(await helper.rft.mintCollection(alice)); - }); + expect(await collection.getProperties(['electron', 'black_hole'])).to.be.empty; + }); + + itSub('Fails to set more properties than it is allowed', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + const propertiesToBeSet = []; + for (let i = 0; i < 65; i++) { + propertiesToBeSet.push({ + key: 'electron_' + i, + value: Math.random() > 0.5 ? 'high' : 'low', + }); + } + + await expect(collection.setProperties(alice, propertiesToBeSet)). + to.be.rejectedWith(/common\.PropertyLimitReached/); + + expect(await collection.getProperties()).to.be.empty; + }); + + itSub('Fails to set properties with invalid names', async ({helper}) => { + const collection = await helper[testSuite.mode].mintCollection(alice); + + const invalidProperties = [ + [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}], + [{key: 'Mr/Sandman', value: 'Bring me a gene'}], + [{key: 'déjà vu', value: 'hmm...'}], + ]; - async function testFailsSetPropertiesWithInvalidNames(collection: UniqueBaseCollection) { - const invalidProperties = [ - [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}], - [{key: 'Mr/Sandman', value: 'Bring me a gene'}], - [{key: 'déjà vu', value: 'hmm...'}], - ]; - - for (let i = 0; i < invalidProperties.length; i++) { + for (let i = 0; i < invalidProperties.length; i++) { + await expect( + collection.setProperties(alice, invalidProperties[i]), + `on rejecting the new badly-named property #${i}`, + ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/); + } + await expect( - collection.setProperties(alice, invalidProperties[i]), - `on rejecting the new badly-named property #${i}`, - ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/); - } - - await expect( - collection.setProperties(alice, [{key: '', value: 'nothing must not exist'}]), - 'on rejecting an unnamed property', - ).to.be.rejectedWith(/common\.EmptyPropertyKey/); - - await expect( - collection.setProperties(alice, [{key: 'CRISPR-Cas9', value: 'rewriting nature!'}]), - 'on setting the correctly-but-still-badly-named property', - ).to.be.fulfilled; - - const keys = invalidProperties.flatMap(propertySet => propertySet.map(property => property.key)).concat('CRISPR-Cas9').concat(''); - - const properties = await collection.getProperties(keys); - expect(properties).to.be.deep.equal([ - {key: 'CRISPR-Cas9', value: 'rewriting nature!'}, - ]); - - for (let i = 0; i < invalidProperties.length; i++) { + collection.setProperties(alice, [{key: '', value: 'nothing must not exist'}]), + 'on rejecting an unnamed property', + ).to.be.rejectedWith(/common\.EmptyPropertyKey/); + await expect( - collection.deleteProperties(alice, invalidProperties[i].map(propertySet => propertySet.key)), - `on trying to delete the non-existent badly-named property #${i}`, - ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/); - } - } - - itSub('Fails to set properties with invalid names (NFT)', async ({helper}) => { - await testFailsSetPropertiesWithInvalidNames(await helper.nft.mintCollection(alice)); - }); - - itSub.ifWithPallets('Fails to set properties with invalid names (ReFungible)', [Pallets.ReFungible], async ({helper}) => { - await testFailsSetPropertiesWithInvalidNames(await helper.rft.mintCollection(alice)); - }); + collection.setProperties(alice, [{key: 'CRISPR-Cas9', value: 'rewriting nature!'}]), + 'on setting the correctly-but-still-badly-named property', + ).to.be.fulfilled; + + const keys = invalidProperties.flatMap(propertySet => propertySet.map(property => property.key)).concat('CRISPR-Cas9').concat(''); + + const properties = await collection.getProperties(keys); + expect(properties).to.be.deep.equal([ + {key: 'CRISPR-Cas9', value: 'rewriting nature!'}, + ]); + + for (let i = 0; i < invalidProperties.length; i++) { + await expect( + collection.deleteProperties(alice, invalidProperties[i].map(propertySet => propertySet.key)), + `on trying to delete the non-existent badly-named property #${i}`, + ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/); + } + }); + })); }); \ No newline at end of file -- gitstuff