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

difftreelog

Integration tests setConstOnChainSchema and setVariableOnChainSchema fixed

str-mv2021-07-15parent: #430a12f.patch.diff
in: master

4 files changed

modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -12,7 +12,7 @@
 chai.use(chaiAsPromised);
 const expect = chai.expect;
 
-describe.only('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
+describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
   it('Changing owner changes owner address', async () => {
     await usingApi(async api => {
       const collectionId = await createCollectionExpectSuccess();
@@ -31,7 +31,7 @@
   });
 });
 
-describe.only('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
+describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
   it('Not owner can\'t change owner.', async () => {
     await usingApi(async api => {
       const collectionId = await createCollectionExpectSuccess();
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -61,7 +61,7 @@
   });
 });
 
-describe.only('Plain calls', () => {
+describe('Plain calls', () => {
   itWeb3('Can perform approve()', async ({ web3, api }) => {
     const collection = await createCollectionExpectSuccess({
       mode: { type: 'NFT' },
modifiedtests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth
before · tests/src/setConstOnChainSchema.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 { Keyring } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';11import {12  createCollectionExpectSuccess,13  destroyCollectionExpectSuccess,14  normalizeAccountId,15} from './util/helpers';1617chai.use(chaiAsPromised);18const expect = chai.expect;1920let Alice: IKeyringPair;21let Bob: IKeyringPair;22let Shema: any;23let largeShema: any;2425before(async () => {26  await usingApi(async () => {27    const keyring = new Keyring({ type: 'sr25519' });28    Alice = keyring.addFromUri('//Alice');29    Bob = keyring.addFromUri('//Bob');30    Shema = '0x31';31    largeShema = new Array(4097).fill(0xff);3233  });34});35describe('Integration Test ext. setConstOnChainSchema()', () => {3637  it('Run extrinsic with parameters of the collection id, set the scheme', async () => {38    await usingApi(async (api) => {39      const collectionId = await createCollectionExpectSuccess();40      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();41      expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));42      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);43      await submitTransactionAsync(Alice, setShema);44    });45  });4647  it('Checking collection data using the ConstOnChainSchema parameter', async () => {48    await usingApi(async (api) => {49      const collectionId = await createCollectionExpectSuccess();50      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);51      await submitTransactionAsync(Alice, setShema);52      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();53      expect(collection.ConstOnChainSchema.toString()).to.be.eq(Shema);5455    });56  });57});5859describe('Negative Integration Test ext. setConstOnChainSchema()', () => {6061  it('Set a non-existent collection', async () => {62    await usingApi(async (api) => {63      // tslint:disable-next-line: radix64      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;65      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);66      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;67    });68  });6970  it('Set a previously deleted collection', async () => {71    await usingApi(async (api) => {72      const collectionId = await createCollectionExpectSuccess();73      await destroyCollectionExpectSuccess(collectionId);74      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);75      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;76    });77  });7879  it('Set invalid data in schema (size too large:> 1024b)', async () => {80    await usingApi(async (api) => {81      const collectionId = await createCollectionExpectSuccess();82      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);83      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;84    });85  });8687  it('Execute method not on behalf of the collection owner', async () => {88    await usingApi(async (api) => {89      const collectionId = await createCollectionExpectSuccess();90      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();91      expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));92      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);93      await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;94    });95  });9697});
after · tests/src/setConstOnChainSchema.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 { Keyring } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import chai from 'chai';9import chaiAsPromised from 'chai-as-promised';10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';11import {12  createCollectionExpectSuccess,13  destroyCollectionExpectSuccess,14  normalizeAccountId,15} from './util/helpers';1617chai.use(chaiAsPromised);18const expect = chai.expect;1920let Alice: IKeyringPair;21let Bob: IKeyringPair;22let Shema: any;23let largeShema: any;2425before(async () => {26  await usingApi(async () => {27    const keyring = new Keyring({ type: 'sr25519' });28    Alice = keyring.addFromUri('//Alice');29    Bob = keyring.addFromUri('//Bob');30    Shema = '0x31';31    largeShema = new Array(4097).fill(0xff);3233  });34});35describe('Integration Test ext. setConstOnChainSchema()', () => {3637  it('Run extrinsic with parameters of the collection id, set the scheme', async () => {38    await usingApi(async (api) => {39      const collectionId = await createCollectionExpectSuccess();40      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();41      expect(collection.Owner).to.be.eq(Alice.address);42      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);43      await submitTransactionAsync(Alice, setShema);44    });45  });4647  it('Checking collection data using the ConstOnChainSchema parameter', async () => {48    await usingApi(async (api) => {49      const collectionId = await createCollectionExpectSuccess();50      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);51      await submitTransactionAsync(Alice, setShema);52      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();53      expect(collection.ConstOnChainSchema.toString()).to.be.eq(Shema);5455    });56  });57});5859describe('Negative Integration Test ext. setConstOnChainSchema()', () => {6061  it('Set a non-existent collection', async () => {62    await usingApi(async (api) => {63      // tslint:disable-next-line: radix64      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;65      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);66      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;67    });68  });6970  it('Set a previously deleted collection', async () => {71    await usingApi(async (api) => {72      const collectionId = await createCollectionExpectSuccess();73      await destroyCollectionExpectSuccess(collectionId);74      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);75      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;76    });77  });7879  it('Set invalid data in schema (size too large:> 1024b)', async () => {80    await usingApi(async (api) => {81      const collectionId = await createCollectionExpectSuccess();82      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);83      await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;84    });85  });8687  it('Execute method not on behalf of the collection owner', async () => {88    await usingApi(async (api) => {89      const collectionId = await createCollectionExpectSuccess();90      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();91      expect(collection.Owner).to.be.eq(Alice.address);92      const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);93      await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;94    });95  });9697});
modifiedtests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -38,7 +38,7 @@
     await usingApi(async (api) => {
       const collectionId = await createCollectionExpectSuccess();
       const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
-      expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));
+      expect(collection.Owner).to.be.eq(Alice.address);
       const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
       await submitTransactionAsync(Alice, setSchema);
     });
@@ -88,7 +88,7 @@
     await usingApi(async (api) => {
       const collectionId = await createCollectionExpectSuccess();
       const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
-      expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));
+      expect(collection.Owner).to.be.eq(Alice.address);
       const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
       await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;
     });