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

difftreelog

Merge branch 'feature/fix-tests' of github.com:usetech-llc/nft_private into feature/fix-tests

Greg Zaitsev2021-07-15parents: #dbfc408 #29efb9d.patch.diff
in: master

3 files changed

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
--- a/tests/src/setConstOnChainSchema.test.ts
+++ b/tests/src/setConstOnChainSchema.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 setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
       await submitTransactionAsync(Alice, setShema);
     });
@@ -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 setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
       await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;
     });
modifiedtests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth
before · tests/src/setVariableOnChainSchema.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 Schema: any;23let largeSchema: 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    Schema = '0x31';31    largeSchema = new Array(4097).fill(0xff);3233  });34});35describe('Integration Test ext. setVariableOnChainSchema()', () => {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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);43      await submitTransactionAsync(Alice, setSchema);44    });45  });4647  it('Checking collection data using the setVariableOnChainSchema parameter', async () => {48    await usingApi(async (api) => {49      const collectionId = await createCollectionExpectSuccess();50      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);51      await submitTransactionAsync(Alice, setSchema);52      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();53      expect(collection.VariableOnChainSchema.toString()).to.be.eq(Schema);5455    });56  });57});5859describe('Negative Integration Test ext. setVariableOnChainSchema()', () => {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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);66      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);75      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);83      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);93      await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;94    });95  });9697});
after · tests/src/setVariableOnChainSchema.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 Schema: any;23let largeSchema: 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    Schema = '0x31';31    largeSchema = new Array(4097).fill(0xff);3233  });34});35describe('Integration Test ext. setVariableOnChainSchema()', () => {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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);43      await submitTransactionAsync(Alice, setSchema);44    });45  });4647  it('Checking collection data using the setVariableOnChainSchema parameter', async () => {48    await usingApi(async (api) => {49      const collectionId = await createCollectionExpectSuccess();50      const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);51      await submitTransactionAsync(Alice, setSchema);52      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();53      expect(collection.VariableOnChainSchema.toString()).to.be.eq(Schema);5455    });56  });57});5859describe('Negative Integration Test ext. setVariableOnChainSchema()', () => {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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);66      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);75      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);83      await expect(submitTransactionExpectFailAsync(Alice, setSchema)).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 setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);93      await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;94    });95  });9697});