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

difftreelog

source

tests/src/setContractSponsoringRateLimit.test.ts3.2 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 {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});