git.delta.rocks / unique-network / refs/commits / 295de97207bc

difftreelog

source

tests/src/removeFromContractWhiteList.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 privateKey from "./substrate/privateKey";7import usingApi from "./substrate/substrate-api";8import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from "./util/contracthelpers";9import { addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess } from "./util/helpers";10import { IKeyringPair } from '@polkadot/types/types';11import { expect } from "chai";1213describe('Integration Test removeFromContractWhiteList', () => {14    let bob: IKeyringPair;1516    before(() => {17        bob = privateKey('//Bob');18    });1920    it('user is no longer whitelisted after removal', async () => {21        await usingApi(async (api) => {22            const [flipper, deployer] = await deployFlipper(api);2324            await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);25            await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);2627            expect(await isWhitelistedInContract(flipper.address, bob.address)).to.be.false;28        });29    });3031    it('user can\'t execute contract after removal', async () => {32        await usingApi(async (api) => {33            const [flipper, deployer] = await deployFlipper(api);34            await toggleContractWhitelistExpectSuccess(deployer, flipper.address, true);3536            await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);37            await toggleFlipValueExpectSuccess(bob, flipper);3839            await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);40            await toggleFlipValueExpectFailure(bob, flipper);41        });42    });4344    it('can be called twice', async () => {45        await usingApi(async (api) => {46            const [flipper, deployer] = await deployFlipper(api);4748            await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);49            await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);50            await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);51        });52    });53});5455describe('Negative Integration Test removeFromContractWhiteList', () => {56    let alice: IKeyringPair;57    let bob: IKeyringPair;5859    before(() => {60        alice = privateKey('//Alice');61        bob = privateKey('//Bob');62    });6364    it('fails when called with non-contract address', async () => {65        await usingApi(async () => {66            await removeFromContractWhiteListExpectFailure(alice, alice.address, bob.address);67        });68    });6970    it('fails when executed by non owner', async () => {71        await usingApi(async (api) => {72            const [flipper, _] = await deployFlipper(api);7374            await removeFromContractWhiteListExpectFailure(alice, flipper.address, bob.address);75        });76    });77});