1234567891011121314151617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {21 deployFlipper,22} from './util/contracthelpers';23import {24 getGenericResult,25} from './util/helpers';2627chai.use(chaiAsPromised);28const expect = chai.expect;2930describe.skip('Integration Test addToContractAllowList', () => {3132 it('Add an address to a contract allow list', async () => {33 await usingApi(async (api, privateKeyWrapper) => {34 const bob = privateKeyWrapper('//Bob');35 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);3637 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();38 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);39 const addEvents = await submitTransactionAsync(deployer, addTx);40 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();4142 expect(getGenericResult(addEvents).success).to.be.true;43 expect(allowListedBefore).to.be.false;44 expect(allowListedAfter).to.be.true;45 });46 });4748 it('Adding same address to allow list repeatedly should not produce errors', async () => {49 await usingApi(async (api, privateKeyWrapper) => {50 const bob = privateKeyWrapper('//Bob');51 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);5253 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();54 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);55 const addEvents = await submitTransactionAsync(deployer, addTx);56 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();57 const addAgainEvents = await submitTransactionAsync(deployer, addTx);58 const allowListedAgainAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();5960 expect(getGenericResult(addEvents).success).to.be.true;61 expect(allowListedBefore).to.be.false;62 expect(allowListedAfter).to.be.true;63 expect(getGenericResult(addAgainEvents).success).to.be.true;64 expect(allowListedAgainAfter).to.be.true;65 });66 });67});6869describe.skip('Negative Integration Test addToContractAllowList', () => {7071 it('Add an address to a allow list of a non-contract', async () => {72 await usingApi(async (api, privateKeyWrapper) => {73 const alice = privateKeyWrapper('//Bob');74 const bob = privateKeyWrapper('//Bob');75 const charlieGuineaPig = privateKeyWrapper('//Charlie');7677 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();78 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);79 await expect(submitTransactionExpectFailAsync(alice, addTx)).to.be.rejected;80 const allowListedAfter = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();8182 expect(allowListedBefore).to.be.false;83 expect(allowListedAfter).to.be.false;84 });85 });8687 it('Add to a contract allow list using a non-owner address', async () => {88 await usingApi(async (api, privateKeyWrapper) => {89 const bob = privateKeyWrapper('//Bob');90 const [contract] = await deployFlipper(api, privateKeyWrapper);9192 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();93 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);94 await expect(submitTransactionExpectFailAsync(bob, addTx)).to.be.rejected;95 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();9697 expect(allowListedBefore).to.be.false;98 expect(allowListedAfter).to.be.false;99 });100 });101102});