difftreelog
test(structure) extra nesting + properties refactoring
in: master
7 files changed
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -144,7 +144,6 @@
it('User doesnt have editing rights', async () => {
await usingApi(async api => {
- const createMode = 'NFT';
const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});
const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -146,7 +146,6 @@
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}},
{Nft: {const_data: '0x32', variable_data: '0x32'}},
{Nft: {const_data: '0x33', variable_data: '0x33'}}];
@@ -182,7 +181,6 @@
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}},
{Nft: {const_data: '0x32', variable_data: '0x32'}},
{Nft: {const_data: '0x33', variable_data: '0x33'}}];
@@ -218,7 +216,6 @@
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}},
{Nft: {const_data: '0x32', variable_data: '0x32'}},
{Nft: {const_data: '0x33', variable_data: '0x33'}}];
tests/src/nesting/migration-check.test.tsdiffbeforeafterboth--- a/tests/src/nesting/migration-check.test.ts
+++ b/tests/src/nesting/migration-check.test.ts
@@ -8,8 +8,8 @@
// Used for polkadot-launch signalling
import find from 'find-process';
-// todo skip
-describe('Migration testing for pallet-common', () => {
+// todo un-skip for migrations
+describe.skip('Migration testing for pallet-common', () => {
let alice: IKeyringPair;
before(async() => {
@@ -63,16 +63,33 @@
});
// And wait for the parachain upgrade
- while (newVersion == oldVersion! && connectionFailCounter < 2) {
- try {
- await usingApi(async api => {
- await waitNewBlocks(api);
- newVersion = (api.consts.system.version.toJSON() as any).specVersion;
- });
- } catch (_) {
- connectionFailCounter++;
- console.log(`Still waiting for the parachain upgrade from ${oldVersion!}...`);
- await new Promise(resolve => setTimeout(resolve, 12000));
+ {
+ // Catch warnings like 'RPC methods not decorated' and keep the 'waiting' message in front
+ const stdlog = console.warn.bind(console);
+ let warnCount = 0;
+ console.warn = function(...args){
+ if (arguments.length <= 2 || !args[2].includes('RPC methods not decorated')) {
+ warnCount++;
+ stdlog.apply(console, args as any);
+ }
+ };
+
+ let oldWarnCount = 0;
+ while (newVersion == oldVersion! && connectionFailCounter < 2) {
+ try {
+ await usingApi(async api => {
+ await waitNewBlocks(api);
+ newVersion = (api.consts.system.version.toJSON() as any).specVersion;
+ if (warnCount > oldWarnCount) {
+ console.log(`Still waiting for the parachain upgrade from ${oldVersion!}...`);
+ oldWarnCount = warnCount;
+ }
+ await new Promise(resolve => setTimeout(resolve, 6000));
+ });
+ } catch (_) {
+ connectionFailCounter++;
+ await new Promise(resolve => setTimeout(resolve, 12000));
+ }
}
}
tests/src/nesting/nest.test.tsdiffbeforeafterboth9 enableAllowListExpectSuccess,9 enableAllowListExpectSuccess,10 enablePublicMintingExpectSuccess,10 enablePublicMintingExpectSuccess,11 getTokenOwner, 11 getTokenOwner, 12 getTopmostTokenOwner, 12 getTopmostTokenOwner,13 normalizeAccountId, 14 setCollectionLimitsExpectSuccess, 13 setCollectionLimitsExpectSuccess, 15 transferExpectFailure, 14 transferExpectFailure, 16 transferExpectSuccess, 15 transferExpectSuccess, 232224describe('Integration Test: Nesting', () => {23describe('Integration Test: Nesting', () => {25 before(async () => {24 before(async () => {26 await usingApi(async api => {25 await usingApi(async () => {27 alice = privateKey('//Alice');26 alice = privateKey('//Alice');28 bob = privateKey('//Bob');27 bob = privateKey('//Bob');29 });28 });196195197describe('Negative Test: Nesting', async() => {196describe('Negative Test: Nesting', async() => {198 before(async () => {197 before(async () => {199 await usingApi(async api => {198 await usingApi(async () => {200 alice = privateKey('//Alice');199 alice = privateKey('//Alice');201 bob = privateKey('//Bob');200 bob = privateKey('//Bob');202 });201 });212 const nestedToken1 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});211 const nestedToken1 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});213 const nestedToken2 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, nestedToken1)});212 const nestedToken2 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, nestedToken1)});214 // The nesting depth is limited by 2213 // The nesting depth is limited by 2215 await expect(executeTransaction(214 await expect(executeTransaction(api, alice, api.tx.unique.createItem(216 api, alice, 217 api.tx.unique.createItem(218 collection, 215 collection, 219 {Ethereum: tokenIdToAddress(collection, nestedToken2)}, 216 {Ethereum: tokenIdToAddress(collection, nestedToken2)}, 220 {nft: {const_data: [], variable_data: []}} as any,217 {nft: {const_data: [], variable_data: []}} as any,221 ),218 )), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/);222 ), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/); // OuroborosDetected?223219224 expect(await getTopmostTokenOwner(api, collection, nestedToken2)).to.be.deep.equal({Substrate: alice.address});220 expect(await getTopmostTokenOwner(api, collection, nestedToken2)).to.be.deep.equal({Substrate: alice.address});225 });221 });234 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');230 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');235231236 // Try to create a nested token232 // Try to create a nested token237 await expect(executeTransaction(233 await expect(executeTransaction(api, alice, api.tx.unique.createItem(238 api, alice, 239 api.tx.unique.createItem(240 collection, 234 collection, 241 {Ethereum: tokenIdToAddress(collection, targetToken)}, 235 {Ethereum: tokenIdToAddress(collection, targetToken)}, 242 {nft: {const_data: [], variable_data: []}} as any,236 {nft: {const_data: [], variable_data: []}} as any,243 ),237 )), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);244 ), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);245238246 // Create a token to be nested239 // Create a token to be nested247 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');240 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');248 // Try to nest241 // Try to nest249 await expect(executeTransaction(242 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.NestingIsDisabled/);250 api, alice, 251 api.tx.unique.transfer(252 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,253 ),254 ), 'while nesting new token').to.be.rejectedWith(/common\.NestingIsDisabled/); // todo to.be.rejected for all255 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});243 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});256 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});244 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});257 });245 });270 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');258 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');271259272 // Try to create a nested token in the wrong collection260 // Try to create a nested token in the wrong collection273 await expect(executeTransaction(261 await expect(executeTransaction(api, alice, api.tx.unique.createItem(274 api, alice, 275 api.tx.unique.createItem(276 collection, 262 collection, 277 {Ethereum: tokenIdToAddress(collection, targetToken)}, 263 {Ethereum: tokenIdToAddress(collection, targetToken)}, 278 {nft: {const_data: [], variable_data: []}} as any,264 {nft: {const_data: [], variable_data: []}} as any,279 ),265 )), 'while creating nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);280 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/); // todo NestingIsDisabled?281266282 // Try to create and nest a token in the wrong collection267 // Try to create and nest a token in the wrong collection283 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');268 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');284 await expect(executeTransaction(269 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);285 api, alice, 286 api.tx.unique.transfer(287 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,288 ),289 ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);290 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});270 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});291 });271 });292 });272 });304 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');284 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');305285306 // Try to create a nested token in the wrong collection286 // Try to create a nested token in the wrong collection307 await expect(executeTransaction(287 await expect(executeTransaction(api, alice, api.tx.unique.createItem(308 api, alice, 309 api.tx.unique.createItem(310 collection, 288 collection, 311 {Ethereum: tokenIdToAddress(collection, targetToken)}, 289 {Ethereum: tokenIdToAddress(collection, targetToken)}, 312 {nft: {const_data: [], variable_data: []}} as any,290 {nft: {const_data: [], variable_data: []}} as any,313 ),291 )), 'while creating nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);314 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/);315292316 // Try to create and nest a token in the wrong collection293 // Try to create and nest a token in the wrong collection317 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');294 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');318 await expect(executeTransaction(295 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);319 api, alice, 320 api.tx.unique.transfer(321 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,322 ),323 ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);324 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});296 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});325 });297 });326 });298 });334 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');306 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');335307336 // Try to create a nested token in the wrong collection308 // Try to create a nested token in the wrong collection337 await expect(executeTransaction(309 await expect(executeTransaction(api, alice, api.tx.unique.createItem(338 api, alice, 339 api.tx.unique.createItem(340 collection, 310 collection, 341 {Ethereum: tokenIdToAddress(collection, targetToken)}, 311 {Ethereum: tokenIdToAddress(collection, targetToken)}, 342 {nft: {const_data: [], variable_data: []}} as any,312 {nft: {const_data: [], variable_data: []}} as any,343 ),313 )), 'while creating nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);344 ), 'while creating nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);345314346 // Try to create and nest a token in the wrong collection315 // Try to create and nest a token in the wrong collection347 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');316 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');348 await expect(executeTransaction(317 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collection, targetToken)}, collection, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);349 api, alice, 350 api.tx.unique.transfer(351 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,352 ),353 ), 'while nesting new token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);354 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});318 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});355 });319 });356 });320 });367 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});331 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});368332369 // Try to create a nested token333 // Try to create a nested token370 await expect(executeTransaction(334 await expect(executeTransaction(api, alice, api.tx.unique.createItem(371 api, alice, 372 api.tx.unique.createItem(373 collectionFT, 335 collectionFT, 374 targetAddress, 336 targetAddress, 375 {Fungible: {Value: 10}},337 {Fungible: {Value: 10}},376 )338 )), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);377 ), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);339 378379 // Create a token to be nested340 // Create a token to be nested380 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');341 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');381 // Try to nest342 // Try to nest382 await expect(executeTransaction(343 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.NestingIsDisabled/);383 api, alice, 344384 api.tx.unique.transfer(345 // Create another token to be nested385 normalizeAccountId({Ethereum: tokenIdToAddress(collectionFT, targetToken)}), collectionFT, newToken, 1,346 const newToken2 = await createItemExpectSuccess(alice, collectionFT, 'Fungible');347 // Try to nest inside a fungible token386 ),348 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collectionFT, newToken)}, collectionFT, newToken2, 1)), 'while nesting new token inside fungible').to.be.rejectedWith(/fungible\.FungibleDisallowsNesting/);387 ), 'while nesting new token').to.be.rejectedWith(/fungible\.FungibleDisallowsNesting/);388 });349 });389 });350 });390351404 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});365 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});405366406 // Try to create a nested token in the wrong collection367 // Try to create a nested token in the wrong collection407 await expect(executeTransaction(368 await expect(executeTransaction(api, alice, api.tx.unique.createItem(408 api, alice, 409 api.tx.unique.createItem(410 collectionFT, 369 collectionFT, 411 targetAddress, 370 targetAddress, 412 {Fungible: {Value: 10}},371 {Fungible: {Value: 10}},413 )372 )), 'while creating nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);414 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/);415373416 // Try to create and nest a token in the wrong collection374 // Try to create and nest a token in the wrong collection417 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');375 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');418 await expect(executeTransaction(376 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);419 api, alice, 420 api.tx.unique.transfer(421 normalizeAccountId({Ethereum: tokenIdToAddress(collectionFT, targetToken)}), collectionFT, newToken, 1,422 ),423 ), 'while nesting new token').to.be.rejectedWith(/fungible\.FungibleDisallowsNesting/);424 });377 });425 });378 });426379427 it('Fungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {380 it('Fungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {428 await usingApi(async api => {381 await usingApi(async api => {429 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});382 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});430 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}}); // todo clear redundant restrictions?431432 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);383 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);433 await enableAllowListExpectSuccess(alice, collectionNFT);384 await enableAllowListExpectSuccess(alice, collectionNFT);434 await enablePublicMintingExpectSuccess(alice, collectionNFT);385 await enablePublicMintingExpectSuccess(alice, collectionNFT);438 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};389 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};439390440 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});391 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});392 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});441393442 // Try to create a nested token in the wrong collection394 // Try to create a nested token in the wrong collection443 await expect(executeTransaction(api, alice, api.tx.unique.createItem(395 await expect(executeTransaction(api, alice, api.tx.unique.createItem(444 collectionFT, 396 collectionFT, 445 targetAddress, 397 targetAddress, 446 {Fungible: {Value: 10}},398 {Fungible: {Value: 10}},447 ))).to.be.rejected;399 )), 'while creating nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);448400449 // Try to create and nest a token in the wrong collection401 // Try to create and nest a token in the wrong collection450 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');402 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');451 await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);403 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);452 });404 });453 });405 });454406468 collectionFT, 420 collectionFT, 469 targetAddress, 421 targetAddress, 470 {Fungible: {Value: 10}},422 {Fungible: {Value: 10}},471 ))).to.be.rejected;423 )), 'while creating a nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);472424473 // Try to create and nest a token in the wrong collection425 // Try to create and nest a token in the wrong collection474 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');426 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');475 await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);427 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);476 });428 });477 });429 });478430492 collectionRFT, 444 collectionRFT, 493 targetAddress, 445 targetAddress, 494 {ReFungible: {const_data: [], pieces: 100}},446 {ReFungible: {const_data: [], pieces: 100}},495 ))).to.be.rejectedWith(/^common\.NestingIsDisabled$/);447 )), 'while creating a nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);496448497 // Create a token to be nested449 // Create a token to be nested498 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');450 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');499 // Try to nest451 // Try to nest500 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);452 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);453 // Try to nest454 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionRFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.NestingIsDisabled/);455456 // Create another token to be nested457 const newToken2 = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');458 // Try to nest inside a fungible token459 await expect(executeTransaction(api, alice, api.tx.unique.transfer({Ethereum: tokenIdToAddress(collectionRFT, newToken)}, collectionRFT, newToken2, 1)), 'while nesting new token inside refungible').to.be.rejectedWith(/refungible\.RefungibleDisallowsNesting/);501 });460 });502 });461 });503462521 collectionRFT, 480 collectionRFT, 522 targetAddress, 481 targetAddress, 523 {ReFungible: {const_data: [], pieces: 100}},482 {ReFungible: {const_data: [], pieces: 100}},524 ))).to.be.rejected;483 )), 'while creating a nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);525484526 // Try to create and nest a token in the wrong collection485 // Try to create and nest a token in the wrong collection527 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');486 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');528 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);487 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionRFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);529 });488 });530 });489 });531490532 it('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {491 it('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {533 await usingApi(async api => {492 await usingApi(async api => {534 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});493 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});535 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}});536537 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);494 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);538 await enableAllowListExpectSuccess(alice, collectionNFT);495 await enableAllowListExpectSuccess(alice, collectionNFT);539 await enablePublicMintingExpectSuccess(alice, collectionNFT);496 await enablePublicMintingExpectSuccess(alice, collectionNFT);543 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};500 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};544501545 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});502 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});503 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});546504547 // Try to create a nested token in the wrong collection505 // Try to create a nested token in the wrong collection548 await expect(executeTransaction(api, alice, api.tx.unique.createItem(506 await expect(executeTransaction(api, alice, api.tx.unique.createItem(549 collectionRFT, 507 collectionRFT, 550 targetAddress, 508 targetAddress, 551 {ReFungible: {const_data: [], pieces: 100}},509 {ReFungible: {const_data: [], pieces: 100}},552 ))).to.be.rejected;510 )), 'while creating a nested token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);553511554 // Try to create and nest a token in the wrong collection512 // Try to create and nest a token in the wrong collection555 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');513 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');556 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);514 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionRFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.OnlyOwnerAllowedToNest/);557 });515 });558 });516 });559517573 collectionRFT, 531 collectionRFT, 574 targetAddress, 532 targetAddress, 575 {ReFungible: {const_data: [], pieces: 100}},533 {ReFungible: {const_data: [], pieces: 100}},576 ))).to.be.rejected;534 )), 'while creating a nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);577535578 // Try to create and nest a token in the wrong collection536 // Try to create and nest a token in the wrong collection579 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');537 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');580 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);538 await expect(executeTransaction(api, alice, api.tx.unique.transfer(targetAddress, collectionRFT, newToken, 1)), 'while nesting new token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);581 });539 });582 });540 });583});541});tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -18,7 +18,7 @@
describe('Integration Test: Collection Properties', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -113,7 +113,7 @@
describe('Negative Integration Test: Collection Properties', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -213,13 +213,13 @@
api,
alice,
api.tx.unique.setCollectionProperties(collection, [{key: '', value: 'nothing must not exist'}]),
- ), `on rejecting an unnamed property`).to.be.rejectedWith(/common\.EmptyPropertyKey/);
+ ), 'on rejecting an unnamed property').to.be.rejectedWith(/common\.EmptyPropertyKey/);
await expect(executeTransaction(
api,
alice,
api.tx.unique.setCollectionProperties(collection, [
- {key: 'CRISPR-Cas9', value: 'rewriting nature!'}
+ {key: 'CRISPR-Cas9', value: 'rewriting nature!'},
]),
), 'on setting the correctly-but-still-badly-named property').to.not.be.rejected;
@@ -245,7 +245,7 @@
describe('Integration Test: Access Rights to Token Properties', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -311,7 +311,7 @@
describe('Negative Integration Test: Access Rights to Token Properties', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -400,7 +400,7 @@
api,
alice,
api.tx.unique.setPropertyPermissions(collection, [{key: '', permission: {}}]),
- ), `on rejecting an unnamed property`).to.be.rejectedWith(/common\.EmptyPropertyKey/);
+ ), 'on rejecting an unnamed property').to.be.rejectedWith(/common\.EmptyPropertyKey/);
const correctKey = '--0x03116e387820CA05'; // PolkadotJS would parse this as an already encoded hex-string
await expect(executeTransaction(
@@ -429,7 +429,7 @@
let permissions: {permission: any, signers: IKeyringPair[]}[];
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
charlie = privateKey('//Charlie');
@@ -446,10 +446,12 @@
});
beforeEach(async () => {
- collection = await createCollectionExpectSuccess();
- token = await createItemExpectSuccess(alice, collection, 'NFT');
- await addCollectionAdminExpectSuccess(alice, collection, bob.address);
- await transferExpectSuccess(collection, token, alice, charlie);
+ await usingApi(async () => {
+ collection = await createCollectionExpectSuccess();
+ token = await createItemExpectSuccess(alice, collection, 'NFT');
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+ await transferExpectSuccess(collection, token, alice, charlie);
+ });
});
it('Reads yet empty properties of a token', async () => {
@@ -592,7 +594,7 @@
let constitution: {permission: any, signers: IKeyringPair[], sinner: IKeyringPair}[];
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
charlie = privateKey('//Charlie');
tests/src/nesting/unnest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/unnest.test.ts
+++ b/tests/src/nesting/unnest.test.ts
@@ -4,11 +4,9 @@
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
createCollectionExpectSuccess,
- createItemExpectFailure,
createItemExpectSuccess,
getBalance,
getTokenOwner,
- getTopmostTokenOwner,
normalizeAccountId,
setCollectionLimitsExpectSuccess,
transferExpectSuccess,
@@ -21,7 +19,7 @@
describe('Integration Test: Unnesting', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -112,7 +110,7 @@
describe('Negative Test: Unnesting', () => {
before(async () => {
- await usingApi(async api => {
+ await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
});
@@ -133,7 +131,7 @@
api,
bob,
api.tx.unique.transferFrom(normalizeAccountId(targetAddress), normalizeAccountId(bob), collection, nestedToken, 1),
- ), 'while unnesting').to.be.rejectedWith(/^structure\.DepthLimit$/); // todo ApprovedValueTooLow?
+ ), 'while unnesting').to.be.rejectedWith(/^common\.ApprovedValueTooLow$/);
expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});
// Try to burn
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -427,7 +427,6 @@
export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {
const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
- const collectionId = 0;
await usingApi(async (api) => {
// Get number of collections before the transaction
const collectionCountBefore = await getCreatedCollectionCount(api);