git.delta.rocks / unique-network / refs/commits / 2b9fe52ee469

difftreelog

source

tests/src/.outdated/removeFromContractAllowList.test.ts3.9 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 '../deprecated-helpers/contracthelpers';19import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from '../deprecated-helpers/helpers';20import {IKeyringPair} from '@polkadot/types/types';21import {expect} from 'chai';2223// todo:playgrounds skipped again24describe.skip('Integration Test removeFromContractAllowList', () => {25  let bob: IKeyringPair;2627  before(async () => {28    await usingApi(async (api, privateKeyWrapper) => {29      bob = privateKeyWrapper('//Bob');30    });31  });3233  it('user is no longer allowlisted after removal', async () => {34    await usingApi(async (api, privateKeyWrapper) => {35      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);3637      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);38      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);3940      expect(await isAllowlistedInContract(flipper.address, bob.address)).to.be.false;41    });42  });4344  it('user can\'t execute contract after removal', async () => {45    await usingApi(async (api, privateKeyWrapper) => {46      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);47      await toggleContractAllowlistExpectSuccess(deployer, flipper.address.toString(), true);4849      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);50      await toggleFlipValueExpectSuccess(bob, flipper);5152      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);53      await toggleFlipValueExpectFailure(bob, flipper);54    });55  });5657  it('can be called twice', async () => {58    await usingApi(async (api, privateKeyWrapper) => {59      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);6061      await addToContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);62      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);63      await removeFromContractAllowListExpectSuccess(deployer, flipper.address.toString(), bob.address);64    });65  });66});6768describe.skip('Negative Integration Test removeFromContractAllowList', () => {69  let alice: IKeyringPair;70  let bob: IKeyringPair;7172  before(async () => {73    await usingApi(async (api, privateKeyWrapper) => {74      alice = privateKeyWrapper('//Alice');75      bob = privateKeyWrapper('//Bob');76    });77  });7879  it('fails when called with non-contract address', async () => {80    await usingApi(async () => {81      await removeFromContractAllowListExpectFailure(alice, alice.address, bob.address);82    });83  });8485  it('fails when executed by non owner', async () => {86    await usingApi(async (api, privateKeyWrapper) => {87      const [flipper] = await deployFlipper(api, privateKeyWrapper);8889      await removeFromContractAllowListExpectFailure(alice, flipper.address.toString(), bob.address);90    });91  });92});