1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import usingApi from './substrate/substrate-api';19import waitNewBlocks from './substrate/wait-new-blocks';20import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';21import {22 enableContractSponsoringExpectSuccess,23 findUnusedAddress,24 setContractSponsoringRateLimitExpectFailure,25 setContractSponsoringRateLimitExpectSuccess,26} from './util/helpers';2728describe.skip('Integration Test setContractSponsoringRateLimit', () => {29 it('ensure sponsored contract can\'t be called twice without pause for free', async () => {30 await usingApi(async (api, privateKeyWrapper) => {31 const user = await findUnusedAddress(api, privateKeyWrapper);3233 const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);34 await enableContractSponsoringExpectSuccess(deployer, flipper.address, true);35 await setContractSponsoringRateLimitExpectSuccess(deployer, flipper.address, 10);36 await toggleFlipValueExpectSuccess(user, flipper);37 await toggleFlipValueExpectFailure(user, flipper);38 });39 });4041 it('ensure sponsored contract can be called twice with pause for free', async () => {42 await usingApi(async (api, privateKeyWrapper) => {43 const user = await findUnusedAddress(api, privateKeyWrapper);4445 const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);46 await enableContractSponsoringExpectSuccess(deployer, flipper.address, true);47 await setContractSponsoringRateLimitExpectSuccess(deployer, flipper.address, 1);48 await toggleFlipValueExpectSuccess(user, flipper);49 await waitNewBlocks(api, 1);50 await toggleFlipValueExpectSuccess(user, flipper);51 });52 });53});5455describe.skip('Negative Integration Test setContractSponsoringRateLimit', () => {56 let alice: IKeyringPair;5758 before(async () => {59 await usingApi(async (api, privateKeyWrapper) => {60 alice = privateKeyWrapper('//Alice');61 });62 });6364 it('fails when called for non-contract address', async () => {65 await usingApi(async (api, privateKeyWrapper) => {66 const user = await findUnusedAddress(api, privateKeyWrapper);6768 await setContractSponsoringRateLimitExpectFailure(alice, user.address, 1);69 });70 });7172 it('fails when called by non-owning user', async () => {73 await usingApi(async (api, privateKeyWrapper) => {74 const [flipper] = await deployFlipper(api, privateKeyWrapper);7576 await setContractSponsoringRateLimitExpectFailure(alice, flipper.address, 1);77 });78 });79});