git.delta.rocks / unique-network / refs/commits / 081791eb4c21

difftreelog

source

tests/src/.outdated/setContractSponsoringRateLimit.test.ts3.3 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 '../deprecated-helpers/contracthelpers';21import {22  enableContractSponsoringExpectSuccess,23  findUnusedAddress,24  setContractSponsoringRateLimitExpectFailure,25  setContractSponsoringRateLimitExpectSuccess,26} from '../deprecated-helpers/helpers';2728// todo:playgrounds skipped~postponed test29describe.skip('Integration Test setContractSponsoringRateLimit', () => {30  it('ensure sponsored contract can\'t be called twice without pause for free', async () => {31    await usingApi(async (api, privateKeyWrapper) => {32      const user = await findUnusedAddress(api, privateKeyWrapper);3334      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);35      await enableContractSponsoringExpectSuccess(deployer, flipper.address, true);36      await setContractSponsoringRateLimitExpectSuccess(deployer, flipper.address, 10);37      await toggleFlipValueExpectSuccess(user, flipper);38      await toggleFlipValueExpectFailure(user, flipper);39    });40  });4142  it('ensure sponsored contract can be called twice with pause for free', async () => {43    await usingApi(async (api, privateKeyWrapper) => {44      const user = await findUnusedAddress(api, privateKeyWrapper);4546      const [flipper, deployer] = await deployFlipper(api, privateKeyWrapper);47      await enableContractSponsoringExpectSuccess(deployer, flipper.address, true);48      await setContractSponsoringRateLimitExpectSuccess(deployer, flipper.address, 1);49      await toggleFlipValueExpectSuccess(user, flipper);50      await waitNewBlocks(api, 1);51      await toggleFlipValueExpectSuccess(user, flipper);52    });53  });54});5556describe.skip('Negative Integration Test setContractSponsoringRateLimit', () => {57  let alice: IKeyringPair;5859  before(async () => {60    await usingApi(async (api, privateKeyWrapper) => {61      alice = privateKeyWrapper('//Alice');62    });63  });6465  it('fails when called for non-contract address', async () => {66    await usingApi(async (api, privateKeyWrapper) => {67      const user = await findUnusedAddress(api, privateKeyWrapper);6869      await setContractSponsoringRateLimitExpectFailure(alice, user.address, 1);70    });71  });7273  it('fails when called by non-owning user', async () => {74    await usingApi(async (api, privateKeyWrapper) => {75      const [flipper] = await deployFlipper(api, privateKeyWrapper);7677      await setContractSponsoringRateLimitExpectFailure(alice, flipper.address, 1);78    });79  });80});