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

difftreelog

CORE-410 Add specific ReFungible test for toke permissions.

Trubnikov Sergey2022-07-01parent: #77a7be6.patch.diff
in: master

1 file changed

modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
1123 await testForbidsAddingTooManyProperties({type: 'ReFungible'}, 100);1123 await testForbidsAddingTooManyProperties({type: 'ReFungible'}, 100);
1124 });1124 });
1125});1125});
1126<<<<<<< HEAD
1127=======
1128
1129describe('ReFungible token properties permissions tests', () => {
1130 let collection: number;
1131 let token: number;
1132
1133 before(async () => {
1134 await usingApi(async (api, privateKeyWrapper) => {
1135 alice = privateKeyWrapper('//Alice');
1136 bob = privateKeyWrapper('//Bob');
1137 charlie = privateKeyWrapper('//Charlie');
1138 });
1139 });
1140
1141 beforeEach(async () => {
1142 await usingApi(async api => {
1143 collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
1144 token = await createItemExpectSuccess(alice, collection, 'ReFungible');
1145 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
1146
1147 await expect(executeTransaction(
1148 api,
1149 alice,
1150 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'key', permission: {mutable:true, tokenOwner: true}}]),
1151 )).to.not.be.rejected;
1152 });
1153 });
1154
1155 it('Forbids add token property with tokenOwher==true but signer have\'t all pieces', async () => {
1156 await usingApi(async api => {
1157 await transferExpectSuccess(collection, token, alice, charlie, 33, 'ReFungible');
1158
1159 await expect(executeTransaction(
1160 api,
1161 alice,
1162 api.tx.unique.setTokenProperties(collection, token, [
1163 {key: 'key', value: 'word'},
1164 ]),
1165 )).to.be.rejectedWith(/common\.NoPermission/);
1166 });
1167 });
1168
1169 it('Forbids mutate token property with tokenOwher==true but signer have\'t all pieces', async () => {
1170 await usingApi(async api => {
1171 await expect(executeTransaction(
1172 api,
1173 alice,
1174 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'key', permission: {mutable:true, tokenOwner: true}}]),
1175 )).to.not.be.rejected;
1176
1177 await expect(executeTransaction(
1178 api,
1179 alice,
1180 api.tx.unique.setTokenProperties(collection, token, [
1181 {key: 'key', value: 'word'},
1182 ]),
1183 )).to.be.not.rejected;
1184
1185 await transferExpectSuccess(collection, token, alice, charlie, 33, 'ReFungible');
1186
1187 await expect(executeTransaction(
1188 api,
1189 alice,
1190 api.tx.unique.setTokenProperties(collection, token, [
1191 {key: 'key', value: 'bad word'},
1192 ]),
1193 )).to.be.rejectedWith(/common\.NoPermission/);
1194 });
1195 });
1196
1197 it('Forbids delete token property with tokenOwher==true but signer have\'t all pieces', async () => {
1198 await usingApi(async api => {
1199 await expect(executeTransaction(
1200 api,
1201 alice,
1202 api.tx.unique.setTokenProperties(collection, token, [
1203 {key: 'key', value: 'word'},
1204 ]),
1205 )).to.be.not.rejected;
1206
1207 await transferExpectSuccess(collection, token, alice, charlie, 33, 'ReFungible');
1208
1209 await expect(executeTransaction(
1210 api,
1211 alice,
1212 api.tx.unique.deleteTokenProperties(collection, token, [
1213 'key',
1214 ]),
1215 )).to.be.rejectedWith(/common\.NoPermission/);
1216 });
1217 });
1218});
1219>>>>>>> 39e5dede (CORE-410 Add specific ReFungible test for toke permissions.)
11261220