git.delta.rocks / unique-network / refs/commits / 5b3615fb06c7

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(async () => {17    await usingApi(async () => {18      bob = privateKey('//Bob');19    });20  });2122  it('user is no longer whitelisted after removal', async () => {23    await usingApi(async (api) => {24      const [flipper, deployer] = await deployFlipper(api);2526      await addToContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);27      await removeFromContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);2829      expect(await isWhitelistedInContract(flipper.address, bob.address)).to.be.false;30    });31  });3233  it('user can\'t execute contract after removal', async () => {34    await usingApi(async (api) => {35      const [flipper, deployer] = await deployFlipper(api);36      await toggleContractWhitelistExpectSuccess(deployer, flipper.address.toString(), true);3738      await addToContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);39      await toggleFlipValueExpectSuccess(bob, flipper);4041      await removeFromContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);42      await toggleFlipValueExpectFailure(bob, flipper);43    });44  });4546  it('can be called twice', async () => {47    await usingApi(async (api) => {48      const [flipper, deployer] = await deployFlipper(api);4950      await addToContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);51      await removeFromContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);52      await removeFromContractWhiteListExpectSuccess(deployer, flipper.address.toString(), bob.address);53    });54  });55});5657describe('Negative Integration Test removeFromContractWhiteList', () => {58  let alice: IKeyringPair;59  let bob: IKeyringPair;6061  before(async () => {62    await usingApi(async () => {63      alice = privateKey('//Alice');64      bob = privateKey('//Bob');65    });66  });6768  it('fails when called with non-contract address', async () => {69    await usingApi(async () => {70      await removeFromContractWhiteListExpectFailure(alice, alice.address, bob.address);71    });72  });7374  it('fails when executed by non owner', async () => {75    await usingApi(async (api) => {76      const [flipper] = await deployFlipper(api);7778      await removeFromContractWhiteListExpectFailure(alice, flipper.address.toString(), bob.address);79    });80  });81});