git.delta.rocks / unique-network / refs/commits / 17a564cfbd3b

difftreelog

source

tests/src/removeFromWhiteList.test.ts3.0 KiBsourcehistory
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 chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi } from './substrate/substrate-api';9import {10  createCollectionExpectSuccess,11  destroyCollectionExpectSuccess,12  enableWhiteListExpectSuccess,13  addToWhiteListExpectSuccess,14  removeFromWhiteListExpectSuccess,15  isWhitelisted,16  findNotExistingCollection,17  removeFromWhiteListExpectFailure,18  disableWhiteListExpectSuccess,19} from './util/helpers';20import { IKeyringPair } from '@polkadot/types/types';21import privateKey from './substrate/privateKey';2223chai.use(chaiAsPromised);24const expect = chai.expect;2526describe('Integration Test removeFromWhiteList', () => {27  let alice: IKeyringPair;28  let bob: IKeyringPair;2930  before(async () => {31    await usingApi(async (api) => {32      alice = privateKey('//Alice');33      bob = privateKey('//Bob');34    });35  });3637  it('ensure bob is not in whitelist after removal', async () => {38    await usingApi(async () => {39      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });40      await enableWhiteListExpectSuccess(alice, collectionId);41      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);4243      await removeFromWhiteListExpectSuccess(alice, collectionId, bob.address);44      expect(await isWhitelisted(collectionId, bob.address)).to.be.false;45    });46  });4748  it('allows removal from collection with unset whitelist status', async () => {49    await usingApi(async () => {50      const collectionWithoutWhitelistId = await createCollectionExpectSuccess();51      await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);52      await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);53      await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);5455      await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);56    });57  });58});5960describe('Negative Integration Test removeFromWhiteList', () => {61  let alice: IKeyringPair;62  let bob: IKeyringPair;6364  before(async () => {65    await usingApi(async (api) => {66      alice = privateKey('//Alice');67      bob = privateKey('//Bob');68    });69  });7071  it('fails on removal from not existing collection', async () => {72    await usingApi(async (api) => {73      const collectionId = await findNotExistingCollection(api);7475      await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);76    });77  });7879  it('fails on removal from removed collection', async () => {80    await usingApi(async () => {81      const collectionId = await createCollectionExpectSuccess();82      await enableWhiteListExpectSuccess(alice, collectionId);83      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);84      await destroyCollectionExpectSuccess(collectionId);8586      await removeFromWhiteListExpectFailure(alice, collectionId, bob.address);87    });88  });89});