123456import 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 normalizeAccountId,20} from './util/helpers';21import { IKeyringPair } from '@polkadot/types/types';22import privateKey from './substrate/privateKey';2324chai.use(chaiAsPromised);25const expect = chai.expect;2627describe('Integration Test removeFromWhiteList', () => {28 let alice: IKeyringPair;29 let bob: IKeyringPair;3031 before(async () => {32 await usingApi(async () => {33 alice = privateKey('//Alice');34 bob = privateKey('//Bob');35 });36 });3738 it('ensure bob is not in whitelist after removal', async () => {39 await usingApi(async () => {40 const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });41 await enableWhiteListExpectSuccess(alice, collectionId);42 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);4344 await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));45 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;46 });47 });4849 it('allows removal from collection with unset whitelist status', async () => {50 await usingApi(async () => {51 const collectionWithoutWhitelistId = await createCollectionExpectSuccess();52 await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);53 await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);54 await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);5556 await removeFromWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, normalizeAccountId(bob.address));57 });58 });59});6061describe('Negative Integration Test removeFromWhiteList', () => {62 let alice: IKeyringPair;63 let bob: IKeyringPair;6465 before(async () => {66 await usingApi(async () => {67 alice = privateKey('//Alice');68 bob = privateKey('//Bob');69 });70 });7172 it('fails on removal from not existing collection', async () => {73 await usingApi(async (api) => {74 const collectionId = await findNotExistingCollection(api);7576 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));77 });78 });7980 it('fails on removal from removed collection', async () => {81 await usingApi(async () => {82 const collectionId = await createCollectionExpectSuccess();83 await enableWhiteListExpectSuccess(alice, collectionId);84 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);85 await destroyCollectionExpectSuccess(collectionId);8687 await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(bob.address));88 });89 });90});