git.delta.rocks / unique-network / refs/commits / 8b9e1d8de76d

difftreelog

tests: fix collection info getting

Yaroslav Bolyukin2021-03-05parent: #353c1c6.patch.diff
in: master

10 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -44,7 +44,7 @@
     "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",
     "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",
     "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",
-    "setVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts"
+    "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts"
   },
   "author": "",
   "license": "SEE LICENSE IN ../LICENSE",
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
before · tests/src/addCollectionAdmin.test.ts
1//
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4//
5
6import { ApiPromise } from '@polkadot/api';
7import BN from 'bn.js';
8import chai from 'chai';
9import chaiAsPromised from 'chai-as-promised';
10import privateKey from './substrate/privateKey';
11import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
12import {createCollectionExpectSuccess, destroyCollectionExpectSuccess} from './util/helpers';
13
14chai.use(chaiAsPromised);
15const expect = chai.expect;
16
17describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
18  it('Add collection admin.', async () => {
19    await usingApi(async (api) => {
20      const collectionId = await createCollectionExpectSuccess();
21      const alice = privateKey('//Alice');
22      const bob = privateKey('//Bob');
23
24      const collection: any = (await api.query.nft.collection(collectionId));
25      expect(collection.Owner.toString()).to.be.eq(alice.address);
26
27      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);
28      await submitTransactionAsync(alice, changeAdminTx);
29
30      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
31      expect(adminListAfterAddAdmin).to.be.contains(bob.address);
32    });
33  });
34
35  it('Add admin using added collection admin.', async () => {
36    await usingApi(async (api) => {
37      const collectionId = await createCollectionExpectSuccess();
38      const Alice = privateKey('//Alice');
39      const Bob = privateKey('//Bob');
40      const Charlie = privateKey('//CHARLIE');
41
42      const collection: any = (await api.query.nft.collection(collectionId));
43      expect(collection.Owner.toString()).to.be.eq(Alice.address);
44
45      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
46      await submitTransactionAsync(Alice, changeAdminTx);
47
48      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
49      expect(adminListAfterAddAdmin).to.be.contains(Bob.address);
50
51      const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);
52      await submitTransactionAsync(Bob, changeAdminTxCharlie);
53      const adminListAfterAddNewAdmin: any = (await api.query.nft.adminList(collectionId));
54      expect(adminListAfterAddNewAdmin).to.be.contains(Bob.address);
55      expect(adminListAfterAddNewAdmin).to.be.contains(Charlie.address);
56    });
57  });
58});
59
60describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
61  it("Not owner can't add collection admin.", async () => {
62    await usingApi(async (api) => {
63      const collectionId = await createCollectionExpectSuccess();
64      const alice = privateKey('//Alice');
65      const nonOwner = privateKey('//Bob_stash');
66
67      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, alice.address);
68      await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;
69
70      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
71      expect(adminListAfterAddAdmin).not.to.be.contains(alice.address);
72
73      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
74      await createCollectionExpectSuccess();
75    });
76  });
77  it("Can't add collection admin of not existing collection.", async () => {
78    await usingApi(async (api) => {
79      // tslint:disable-next-line: no-bitwise
80      const collectionId = (1 << 32) - 1;
81      const alice = privateKey('//Alice');
82      const bob = privateKey('//Bob');
83
84      const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);
85      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
86
87      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
88      await createCollectionExpectSuccess();
89    });
90  });
91
92  it("Can't add an admin to a destroyed collection.", async () => {
93    await usingApi(async (api) => {
94      const collectionId = await createCollectionExpectSuccess();
95      const Alice = privateKey('//Alice');
96      const Bob = privateKey('//Bob');
97      await destroyCollectionExpectSuccess(collectionId);
98      const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
99      await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
100
101      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
102      await createCollectionExpectSuccess();
103    });
104  });
105
106  it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
107    await usingApi(async (api: ApiPromise) => {
108      const Alice = privateKey('//Alice');
109      const accounts = [
110        'GsvVmjr1CBHwQHw84pPHMDxgNY3iBLz6Qn7qS3CH8qPhrHz',
111        'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP',
112        'JKspFU6ohf1Grg3Phdzj2pSgWvsYWzSfKghhfzMbdhNBWs5',
113        'Fr4NzY1udSFFLzb2R3qxVQkwz9cZraWkyfH4h3mVVk7BK7P',
114        'DfnTB4z7eUvYRqcGtTpFsLC69o6tvBSC1pEv8vWPZFtCkaK',
115        'HnMAUz7r2G8G3hB27SYNyit5aJmh2a5P4eMdDtACtMFDbam',
116        'DE14BzQ1bDXWPKeLoAqdLAm1GpyAWaWF1knF74cEZeomTBM',
117      ];
118      const collectionId = await createCollectionExpectSuccess();
119
120      const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };
121      const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();
122      expect(chainAdminLimit).to.be.equal(5);
123
124      for (let i = 0; i < chainAdminLimit; i++) {
125        const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
126        await submitTransactionAsync(Alice, changeAdminTx);
127        const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
128        expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
129      }
130
131      const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainAdminLimit]);
132      await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
133    });
134  });
135});
after · tests/src/addCollectionAdmin.test.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise } from '@polkadot/api';7import BN from 'bn.js';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import privateKey from './substrate/privateKey';11import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';12import {createCollectionExpectSuccess, destroyCollectionExpectSuccess} from './util/helpers';1314chai.use(chaiAsPromised);15const expect = chai.expect;1617describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {18  it('Add collection admin.', async () => {19    await usingApi(async (api) => {20      const collectionId = await createCollectionExpectSuccess();21      const alice = privateKey('//Alice');22      const bob = privateKey('//Bob');2324      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();25      expect(collection.Owner.toString()).to.be.eq(alice.address);2627      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);28      await submitTransactionAsync(alice, changeAdminTx);2930      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));31      expect(adminListAfterAddAdmin).to.be.contains(bob.address);32    });33  });3435  it('Add admin using added collection admin.', async () => {36    await usingApi(async (api) => {37      const collectionId = await createCollectionExpectSuccess();38      const Alice = privateKey('//Alice');39      const Bob = privateKey('//Bob');40      const Charlie = privateKey('//CHARLIE');4142      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();43      expect(collection.Owner.toString()).to.be.eq(Alice.address);4445      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);46      await submitTransactionAsync(Alice, changeAdminTx);4748      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));49      expect(adminListAfterAddAdmin).to.be.contains(Bob.address);5051      const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);52      await submitTransactionAsync(Bob, changeAdminTxCharlie);53      const adminListAfterAddNewAdmin: any = (await api.query.nft.adminList(collectionId));54      expect(adminListAfterAddNewAdmin).to.be.contains(Bob.address);55      expect(adminListAfterAddNewAdmin).to.be.contains(Charlie.address);56    });57  });58});5960describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {61  it("Not owner can't add collection admin.", async () => {62    await usingApi(async (api) => {63      const collectionId = await createCollectionExpectSuccess();64      const alice = privateKey('//Alice');65      const nonOwner = privateKey('//Bob_stash');6667      const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, alice.address);68      await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;6970      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));71      expect(adminListAfterAddAdmin).not.to.be.contains(alice.address);7273      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)74      await createCollectionExpectSuccess();75    });76  });77  it("Can't add collection admin of not existing collection.", async () => {78    await usingApi(async (api) => {79      // tslint:disable-next-line: no-bitwise80      const collectionId = (1 << 32) - 1;81      const alice = privateKey('//Alice');82      const bob = privateKey('//Bob');8384      const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);85      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;8687      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)88      await createCollectionExpectSuccess();89    });90  });9192  it("Can't add an admin to a destroyed collection.", async () => {93    await usingApi(async (api) => {94      const collectionId = await createCollectionExpectSuccess();95      const Alice = privateKey('//Alice');96      const Bob = privateKey('//Bob');97      await destroyCollectionExpectSuccess(collectionId);98      const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);99      await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;100101      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)102      await createCollectionExpectSuccess();103    });104  });105106  it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {107    await usingApi(async (api: ApiPromise) => {108      const Alice = privateKey('//Alice');109      const accounts = [110        'GsvVmjr1CBHwQHw84pPHMDxgNY3iBLz6Qn7qS3CH8qPhrHz',111        'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP',112        'JKspFU6ohf1Grg3Phdzj2pSgWvsYWzSfKghhfzMbdhNBWs5',113        'Fr4NzY1udSFFLzb2R3qxVQkwz9cZraWkyfH4h3mVVk7BK7P',114        'DfnTB4z7eUvYRqcGtTpFsLC69o6tvBSC1pEv8vWPZFtCkaK',115        'HnMAUz7r2G8G3hB27SYNyit5aJmh2a5P4eMdDtACtMFDbam',116        'DE14BzQ1bDXWPKeLoAqdLAm1GpyAWaWF1knF74cEZeomTBM',117      ];118      const collectionId = await createCollectionExpectSuccess();119120      const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };121      const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();122      expect(chainAdminLimit).to.be.equal(5);123124      for (let i = 0; i < chainAdminLimit; i++) {125        const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);126        await submitTransactionAsync(Alice, changeAdminTx);127        const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));128        expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);129      }130131      const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainAdminLimit]);132      await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;133    });134  });135});
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -19,13 +19,13 @@
       const alice = privateKey('//Alice');
       const bob = privateKey('//Bob');
 
-      const collection: any = (await api.query.nft.collection(collectionId));
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collection.Owner.toString()).to.be.eq(alice.address);
 
       const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
       await submitTransactionAsync(alice, changeOwnerTx);
 
-      const collectionAfterOwnerChange: any = (await api.query.nft.collection(collectionId));
+      const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collectionAfterOwnerChange.Owner.toString()).to.be.eq(bob.address);
     });
   });
@@ -41,7 +41,7 @@
       const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
       await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
 
-      const collectionAfterOwnerChange: any = (await api.query.nft.collection(collectionId));
+      const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collectionAfterOwnerChange.Owner.toString()).to.be.eq(alice.address);
 
       // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -19,7 +19,7 @@
       const collectionId = await createCollectionExpectSuccess();
       const Alice = privateKey('//Alice');
       const Bob = privateKey('//Bob');
-      const collection: any = (await api.query.nft.collection(collectionId));
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collection.Owner.toString()).to.be.eq(Alice.address);
       // first - add collection admin Bob
       const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -61,12 +61,12 @@
 
       // tslint:disable-next-line:no-unused-expression
       expect(result.success).to.be.true;
-      expect(collectionInfo.Limits.AccountTokenOwnershipLimit.toNumber()).to.be.equal(accountTokenOwnershipLimit);
-      expect(collectionInfo.Limits.SponsoredMintSize.toNumber()).to.be.equal(sponsoredDataSize);
-      expect(collectionInfo.Limits.TokenLimit.toNumber()).to.be.equal(tokenLimit);
-      expect(collectionInfo.Limits.SponsorTimeout.toNumber()).to.be.equal(sponsorTimeout);
-      expect(collectionInfo.Limits.OwnerCanTransfer.valueOf()).to.be.true;
-      expect(collectionInfo.Limits.OwnerCanDestroy.valueOf()).to.be.true;
+      expect(collectionInfo.Limits.AccountTokenOwnershipLimit).to.be.equal(accountTokenOwnershipLimit);
+      expect(collectionInfo.Limits.SponsoredDataSize).to.be.equal(sponsoredDataSize);
+      expect(collectionInfo.Limits.TokenLimit).to.be.equal(tokenLimit);
+      expect(collectionInfo.Limits.SponsorTimeout).to.be.equal(sponsorTimeout);
+      expect(collectionInfo.Limits.OwnerCanTransfer).to.be.true;
+      expect(collectionInfo.Limits.OwnerCanDestroy).to.be.true;
     });
   });
 });
modifiedtests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setConstOnChainSchema.test.ts
+++ b/tests/src/setConstOnChainSchema.test.ts
@@ -36,7 +36,7 @@
   it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
       await usingApi(async (api) => {
       const collectionId = await createCollectionExpectSuccess();
-      const collection: any = (await api.query.nft.collection(collectionId));
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collection.Owner.toString()).to.be.eq(Alice.address);
       const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
       await submitTransactionAsync(Alice, setShema);
@@ -48,7 +48,7 @@
         const collectionId = await createCollectionExpectSuccess();
         const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
         await submitTransactionAsync(Alice, setShema);
-        const collection: any = (await api.query.nft.collection(collectionId));
+        const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
         expect(collection.ConstOnChainSchema.toString()).to.be.eq(Shema);
 
     });
@@ -86,7 +86,7 @@
   it('Execute method not on behalf of the collection owner', async () => {
     await usingApi(async (api) => {
       const collectionId = await createCollectionExpectSuccess();
-      const collection: any = (await api.query.nft.collection(collectionId));
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collection.Owner.toString()).to.be.eq(Alice.address);
       const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
       await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;
modifiedtests/src/setOffchainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setOffchainSchema.test.ts
+++ b/tests/src/setOffchainSchema.test.ts
@@ -36,7 +36,7 @@
     await setOffchainSchemaExpectSuccess(alice, collectionId, DATA);
     const collection = await queryCollectionExpectSuccess(collectionId);
 
-    expect(Array.from(collection.OffchainSchema)).to.be.deep.equal(DATA);
+    expect(collection.OffchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
   });
 });
 
modifiedtests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -1,96 +1,96 @@
-//
-// This file is subject to the terms and conditions defined in
-// file 'LICENSE', which is part of this source code package.
-//
-
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import {
-  createCollectionExpectSuccess,
-  destroyCollectionExpectSuccess,
-} from './util/helpers';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Schema: any;
-let largeSchema: any;
-
-before(async () => {
-  await usingApi(async (api) => {
-    const keyring = new Keyring({ type: 'sr25519' });
-    Alice = keyring.addFromUri('//Alice');
-    Bob = keyring.addFromUri('//Bob');
-    Schema = '0x31';
-    largeSchema = new Array(4097).fill(0xff);
-
-  });
-});
-describe('Integration Test ext. setVariableOnChainSchema()', () => {
-
-  it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
-      await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const collection: any = (await api.query.nft.collection(collectionId));
-      expect(collection.Owner.toString()).to.be.eq(Alice.address);
-      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
-      await submitTransactionAsync(Alice, setSchema);
-    });
-  });
-
-  it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
-      await usingApi(async (api) => {
-        const collectionId = await createCollectionExpectSuccess();
-        const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
-        await submitTransactionAsync(Alice, setSchema);
-        const collection: any = (await api.query.nft.collection(collectionId));
-        expect(collection.VariableOnChainSchema.toString()).to.be.eq(Schema);
-
-    });
-  });
-});
-
-describe('Negative Integration Test ext. setVariableOnChainSchema()', () => {
-
-  it('Set a non-existent collection', async () => {
-    await usingApi(async (api) => {
-      // tslint:disable-next-line: radix
-      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
-      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
-      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Set a previously deleted collection', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      await destroyCollectionExpectSuccess(collectionId);
-      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
-      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Set invalid data in schema (size too large:> 1024b)', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);
-      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Execute method not on behalf of the collection owner', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const collection: any = (await api.query.nft.collection(collectionId));
-      expect(collection.Owner.toString()).to.be.eq(Alice.address);
-      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
-      await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;
-    });
-  });
-
-});
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import { Keyring } from '@polkadot/api';
+import { IKeyringPair } from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import {
+  createCollectionExpectSuccess,
+  destroyCollectionExpectSuccess,
+} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+let Alice: IKeyringPair;
+let Bob: IKeyringPair;
+let Schema: any;
+let largeSchema: any;
+
+before(async () => {
+  await usingApi(async (api) => {
+    const keyring = new Keyring({ type: 'sr25519' });
+    Alice = keyring.addFromUri('//Alice');
+    Bob = keyring.addFromUri('//Bob');
+    Schema = '0x31';
+    largeSchema = new Array(4097).fill(0xff);
+
+  });
+});
+describe('Integration Test ext. setVariableOnChainSchema()', () => {
+
+  it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
+      await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+      expect(collection.Owner.toString()).to.be.eq(Alice.address);
+      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
+      await submitTransactionAsync(Alice, setSchema);
+    });
+  });
+
+  it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
+      await usingApi(async (api) => {
+        const collectionId = await createCollectionExpectSuccess();
+        const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
+        await submitTransactionAsync(Alice, setSchema);
+        const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+        expect(collection.VariableOnChainSchema.toString()).to.be.eq(Schema);
+
+    });
+  });
+});
+
+describe('Negative Integration Test ext. setVariableOnChainSchema()', () => {
+
+  it('Set a non-existent collection', async () => {
+    await usingApi(async (api) => {
+      // tslint:disable-next-line: radix
+      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
+      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+    });
+  });
+
+  it('Set a previously deleted collection', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      await destroyCollectionExpectSuccess(collectionId);
+      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
+      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+    });
+  });
+
+  it('Set invalid data in schema (size too large:> 1024b)', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);
+      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+    });
+  });
+
+  it('Execute method not on behalf of the collection owner', async () => {
+    await usingApi(async (api) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+      expect(collection.Owner.toString()).to.be.eq(Alice.address);
+      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
+      await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;
+    });
+  });
+
+});
modifiedtests/src/types.tsdiffbeforeafterboth
--- a/tests/src/types.ts
+++ b/tests/src/types.ts
@@ -13,10 +13,11 @@
   Description: [BN, BN]; // utf16
   isReFungible: boolean;
   Limits: {
-    AccountTokenOwnershipLimit: BN;
-    SponsoredMintSize: BN;
-    TokenLimit: BN;
-    SponsorTimeout: BN;
+    AccountTokenOwnershipLimit: number;
+    SponsoredDataSize: number;
+    SponsoredDataRateLimit?: number,
+    TokenLimit: number;
+    SponsorTimeout: number;
     OwnerCanTransfer: boolean;
     OwnerCanDestroy: boolean;
   };
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -212,7 +212,7 @@
     const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(result.collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(result.collectionId)).toJSON();
 
     // What to expect
     // tslint:disable-next-line:no-unused-expression
@@ -324,18 +324,17 @@
     const result = getDestroyResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     expect(result).to.be.true;
-    expect(collection).to.be.not.null;
-    expect(collection.Owner).to.be.equal(nullPublicKey);
+    expect(collection).to.be.null;
   });
 }
 
 export async function queryCollectionLimits(collectionId: number) {
   return await usingApi(async (api) => {
-    return ((await api.query.nft.collection(collectionId)).toJSON() as any).Limits;
+    return ((await api.query.nft.collectionById(collectionId)).toJSON() as any).Limits;
   });
 }
 
@@ -373,7 +372,7 @@
     const result = getGenericResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     expect(result.success).to.be.true;
@@ -392,7 +391,7 @@
     const result = getGenericResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     expect(result.success).to.be.true;
@@ -431,7 +430,7 @@
     const result = getGenericResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     expect(result.success).to.be.true;
@@ -838,7 +837,7 @@
     const result = getGenericResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     // tslint:disable-next-line:no-unused-expression
@@ -864,7 +863,7 @@
     const result = getGenericResult(events);
 
     // Get the collection
-    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+    const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
 
     // What to expect
     // tslint:disable-next-line:no-unused-expression
@@ -946,7 +945,7 @@
 
 export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
   : Promise<ICollectionInterface | null> => {
-  return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;
+  return (await api.query.nft.collectionById(collectionId)).toJSON() as unknown as ICollectionInterface;
 };
 
 export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {
@@ -956,6 +955,6 @@
 
 export async function queryCollectionExpectSuccess(collectionId: number): Promise<ICollectionInterface> {
   return await usingApi(async (api) => {
-    return (await api.query.nft.collection(collectionId)) as unknown as ICollectionInterface;
+    return (await api.query.nft.collectionById(collectionId)).toJSON() as unknown as ICollectionInterface;
   });
 }