1import privateKey from "./substrate/privateKey";2import usingApi from "./substrate/substrate-api";3import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from "./util/contracthelpers";4import { addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess } from "./util/helpers";5import { IKeyringPair } from '@polkadot/types/types';6import { expect } from "chai";78describe('Integration Test removeFromContractWhiteList', () => {9 let bob: IKeyringPair;1011 before(() => {12 bob = privateKey('//Bob');13 });1415 it('user is no longer whitelisted after removal', async () => {16 await usingApi(async (api) => {17 const [flipper, deployer] = await deployFlipper(api);1819 await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);20 await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);2122 expect(await isWhitelistedInContract(flipper.address, bob.address)).to.be.false;23 });24 });2526 it('user can\'t execute contract after removal', async () => {27 await usingApi(async (api) => {28 const [flipper, deployer] = await deployFlipper(api);29 await toggleContractWhitelistExpectSuccess(deployer, flipper.address, true);3031 await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);32 await toggleFlipValueExpectSuccess(bob, flipper);3334 await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);35 await toggleFlipValueExpectFailure(bob, flipper);36 });37 });3839 it('can be called twice', async () => {40 await usingApi(async (api) => {41 const [flipper, deployer] = await deployFlipper(api);4243 await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);44 await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);45 await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);46 });47 });48});4950describe('Negative Integration Test removeFromContractWhiteList', () => {51 let alice: IKeyringPair;52 let bob: IKeyringPair;5354 before(() => {55 alice = privateKey('//Alice');56 bob = privateKey('//Bob');57 });5859 it('fails when called with non-contract address', async () => {60 await usingApi(async () => {61 await removeFromContractWhiteListExpectFailure(alice, alice.address, bob.address);62 });63 });6465 it('fails when executed by non owner', async () => {66 await usingApi(async (api) => {67 const [flipper, _] = await deployFlipper(api);6869 await removeFromContractWhiteListExpectFailure(alice, flipper.address, bob.address);70 });71 });72});