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;293031describe.skip('Integration Test addToContractAllowList', () => {3233 it('Add an address to a contract allow list', async () => {34 await usingApi(async (api, privateKeyWrapper) => {35 const bob = privateKeyWrapper('//Bob');36 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);3738 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();39 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);40 const addEvents = await submitTransactionAsync(deployer, addTx);41 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();4243 expect(getGenericResult(addEvents).success).to.be.true;44 expect(allowListedBefore).to.be.false;45 expect(allowListedAfter).to.be.true;46 });47 });4849 it('Adding same address to allow list repeatedly should not produce errors', async () => {50 await usingApi(async (api, privateKeyWrapper) => {51 const bob = privateKeyWrapper('//Bob');52 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);5354 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();55 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);56 const addEvents = await submitTransactionAsync(deployer, addTx);57 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();58 const addAgainEvents = await submitTransactionAsync(deployer, addTx);59 const allowListedAgainAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();6061 expect(getGenericResult(addEvents).success).to.be.true;62 expect(allowListedBefore).to.be.false;63 expect(allowListedAfter).to.be.true;64 expect(getGenericResult(addAgainEvents).success).to.be.true;65 expect(allowListedAgainAfter).to.be.true;66 });67 });68});6970describe.skip('Negative Integration Test addToContractAllowList', () => {7172 it('Add an address to a allow list of a non-contract', async () => {73 await usingApi(async (api, privateKeyWrapper) => {74 const alice = privateKeyWrapper('//Bob');75 const bob = privateKeyWrapper('//Bob');76 const charlieGuineaPig = privateKeyWrapper('//Charlie');7778 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();79 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);80 await expect(submitTransactionExpectFailAsync(alice, addTx)).to.be.rejected;81 const allowListedAfter = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();8283 expect(allowListedBefore).to.be.false;84 expect(allowListedAfter).to.be.false;85 });86 });8788 it('Add to a contract allow list using a non-owner address', async () => {89 await usingApi(async (api, privateKeyWrapper) => {90 const bob = privateKeyWrapper('//Bob');91 const [contract] = await deployFlipper(api, privateKeyWrapper);9293 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();94 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);95 await expect(submitTransactionExpectFailAsync(bob, addTx)).to.be.rejected;96 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();9798 expect(allowListedBefore).to.be.false;99 expect(allowListedAfter).to.be.false;100 });101 });102103});