git.delta.rocks / unique-network / refs/commits / 33bde7dbb9a9

difftreelog

test remove ChainLimit usage

Yaroslav Bolyukin2021-08-10parent: #7a034de.patch.diff
in: master

3 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -433,6 +433,7 @@
 		origin: T::Origin
 	{
 		fn deposit_event() = default;
+		const CollectionAdminsLimit: u64 = COLLECTION_ADMINS_LIMIT;
 		type Error = Error<T>;
 
 		fn on_initialize(_now: T::BlockNumber) -> Weight {
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -117,8 +117,7 @@
       ];
       const collectionId = await createCollectionExpectSuccess();
 
-      const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };
-      const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();
+      const chainAdminLimit = api.consts.nft.collectionAdminsLimit.toNumber();
       expect(chainAdminLimit).to.be.equal(5);
 
       for (let i = 0; i < chainAdminLimit; i++) {
modifiedtests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth
before · tests/src/collision-tests/adminLimitsOff.test.ts
1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8  createCollectionExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;15let Ferdie: IKeyringPair;16let Charlie: IKeyringPair;17let Eve: IKeyringPair;18let Dave: IKeyringPair;1920before(async () => {21  await usingApi(async () => {22    Alice = privateKey('//Alice');23    Bob = privateKey('//Bob');24    Ferdie = privateKey('//Ferdie');25    Charlie = privateKey('//Charlie');26    Eve = privateKey('//Eve');27    Dave = privateKey('//Dave');28  });29});3031describe('Admin limit exceeded collection: ', () => {32  // tslint:disable-next-line: max-line-length33  it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {34    await usingApi(async (api) => {35      const collectionId = await createCollectionExpectSuccess();3637      const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };38      const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();39      expect(chainAdminLimit).to.be.equal(5);4041      const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);42      await submitTransactionAsync(Alice, changeAdminTx1);43      const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);44      await submitTransactionAsync(Alice, changeAdminTx2);45      const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);46      await submitTransactionAsync(Alice, changeAdminTx3);4748      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));49      const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);50      const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);51      await Promise.all([52        addAdmOne.signAndSend(Bob),53        addAdmTwo.signAndSend(Alice),54      ]);55      await timeoutPromise(10000);56      const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);57      // tslint:disable-next-line: no-unused-expression58      expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5960      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));61      expect(adminListAfterAddAdmin).to.be.contains(Eve.address);62      expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);63      expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);64      await timeoutPromise(20000);65    });66  });67});