git.delta.rocks / unique-network / refs/commits / dfb31491c2fc

difftreelog

source

tests/src/removeFromContractAllowList.test.ts3.8 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import usingApi from './substrate/substrate-api';18import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';19import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from './util/helpers';20import {IKeyringPair} from '@polkadot/types/types';21import {expect} from 'chai';2223describe.skip('Integration Test removeFromContractAllowList', () => {24  let bob: IKeyringPair;2526  before(async () => {27    await usingApi(async (api, privateKeyWrapper) => {28      bob = privateKeyWrapper('//Bob');29    });30  });3132  it('user is no longer allowlisted after removal', async () => {33    await usingApi(async (api, privateKeyWrapper) => {34      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);3536      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);37      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);3839      expect(await isAllowlistedInContract(flipper.address, bob.address)).to.be.false;40    });41  });4243  it('user can\'t execute contract after removal', async () => {44    await usingApi(async (api, privateKeyWrapper) => {45      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);46      await toggleContractAllowlistExpectSuccess(deployer, flipper.address.toString(), true);4748      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);49      await toggleFlipValueExpectSuccess(bob, flipper);5051      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);52      await toggleFlipValueExpectFailure(bob, flipper);53    });54  });5556  it('can be called twice', async () => {57    await usingApi(async (api, privateKeyWrapper) => {58      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);5960      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);61      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);62      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);63    });64  });65});6667describe.skip('Negative Integration Test removeFromContractAllowList', () => {68  let alice: IKeyringPair;69  let bob: IKeyringPair;7071  before(async () => {72    await usingApi(async (api, privateKeyWrapper) => {73      alice = privateKeyWrapper('//Alice');74      bob = privateKeyWrapper('//Bob');75    });76  });7778  it('fails when called with non-contract address', async () => {79    await usingApi(async () => {80      await removeFromContractAllowListExpectFailure(alice, alice.address, bob.address);81    });82  });8384  it('fails when executed by non owner', async () => {85    await usingApi(async (api, privateKeyWrapper) => {86      const [flipper] = await deployFlipper(api, privateKeyWrapper);8788      await removeFromContractAllowListExpectFailure(alice, flipper.address.toString(), bob.address);89    });90  });91});