difftreelog
fix use playgrounds in eth scheduler test
in: master
1 file changed
tests/src/.outdated/eth/scheduling.test.tsdiffbeforeafterboth1// 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 {expect} from 'chai';18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from '../../deprecated-helpers/eth/helpers';19import {makeScheduledId, scheduleAfter, waitNewBlocks, requirePallets, Pallets} from '../../deprecated-helpers/helpers';2021// TODO mrshiposha update this test in #58122describe.skip('Scheduing EVM smart contracts', () => {23 before(async function() {24 await requirePallets(this, [Pallets.Scheduler]);25 });2627 itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {28 const scheduledId = await makeScheduledId();29 const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);30 const flipper = await deployFlipper(web3, deployer);31 const initialValue = await flipper.methods.getValue().call();32 const alice = privateKeyWrapper('//Alice');33 await transferBalanceToEth(api, alice, subToEth(alice.address));3435 {36 const tx = api.tx.evm.call(37 subToEth(alice.address),38 flipper.options.address,39 flipper.methods.flip().encodeABI(),40 '0',41 GAS_ARGS.gas,42 await web3.eth.getGasPrice(),43 null,44 null,45 [],46 );47 const waitForBlocks = 4;48 const periodBlocks = 2;49 const repetitions = 2;5051 await expect(scheduleAfter(52 api,53 tx,54 alice,55 waitForBlocks,56 scheduledId,57 periodBlocks,58 repetitions,59 )).to.not.be.rejected;60 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);61 62 await waitNewBlocks(waitForBlocks + 1);63 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);64 65 await waitNewBlocks(periodBlocks);66 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);67 }68 });69});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 {expect} from 'chai';18import {subToEth} from './util/helpers';19import {waitNewBlocks, Pallets} from '../util/helpers';20import {EthUniqueHelper, itEth} from './util/playgrounds';2122describe('Scheduing EVM smart contracts', () => {2324 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {25 const alice = privateKey('//Alice');2627 const scheduledId = await helper.arrange.makeScheduledId();2829 const deployer = await helper.eth.createAccountWithBalance(alice);30 const flipper = await helper.eth.deployFlipper(deployer);3132 const initialValue = await flipper.methods.getValue().call();33 await helper.eth.transferBalanceFromSubstrate(alice, subToEth(alice.address));3435 const waitForBlocks = 4;36 const periodic = {37 period: 2,38 repetitions: 2,39 };4041 await helper.scheduler.scheduleAfter<EthUniqueHelper>(scheduledId, waitForBlocks, {periodic})42 .eth.callEVM(43 alice,44 flipper.options.address,45 flipper.methods.flip().encodeABI(),46 '0',47 );4849 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);50 51 await waitNewBlocks(waitForBlocks + 1);52 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);5354 await waitNewBlocks(periodic.period);55 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);56 });57});