git.delta.rocks / unique-network / refs/commits / 4eb90d8b0eec

difftreelog

source

tests/src/removeFromContractAllowList.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 {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from './util/helpers';10import {IKeyringPair} from '@polkadot/types/types';11import {expect} from 'chai';1213describe.skip('Integration Test removeFromContractAllowList', () => {14  let bob: IKeyringPair;1516  before(async () => {17    await usingApi(async () => {18      bob = privateKey('//Bob');19    });20  });2122  it('user is no longer allowlisted after removal', async () => {23    await usingApi(async (api) => {24      const [flipper, deployer] = await deployFlipper(api);2526      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);27      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);2829      expect(await isAllowlistedInContract(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 toggleContractAllowlistExpectSuccess(deployer, flipper.address.toString(), true);3738      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);39      await toggleFlipValueExpectSuccess(bob, flipper);4041      await removeFromContractAllowListExpectSuccess(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 addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);51      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);52      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);53    });54  });55});5657describe.skip('Negative Integration Test removeFromContractAllowList', () => {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 removeFromContractAllowListExpectFailure(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 removeFromContractAllowListExpectFailure(alice, flipper.address.toString(), bob.address);79    });80  });81});