1234567891011121314151617import {expect} from 'chai';18import {EthUniqueHelper, itEth} from './util/playgrounds';19import {Pallets, usingPlaygrounds} from '../util/playgrounds';2021describe('Scheduing EVM smart contracts', () => {2223 before(async () => {24 await usingPlaygrounds(async (helper) => {25 await helper.testUtils.enable();26 });27 });2829 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {30 const alice = privateKey('//Alice');3132 const scheduledId = await helper.arrange.makeScheduledId();3334 const deployer = await helper.eth.createAccountWithBalance(alice);35 const flipper = await helper.eth.deployFlipper(deployer);3637 const initialValue = await flipper.methods.getValue().call();38 await helper.eth.transferBalanceFromSubstrate(alice, helper.address.substrateToEth(alice.address));3940 const waitForBlocks = 4;41 const periodic = {42 period: 2,43 repetitions: 2,44 };4546 await helper.scheduler.scheduleAfter<EthUniqueHelper>(scheduledId, waitForBlocks, {periodic})47 .eth.sendEVM(48 alice,49 flipper.options.address,50 flipper.methods.flip().encodeABI(),51 '0',52 );5354 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);55 56 await helper.wait.newBlocks(waitForBlocks + 1);57 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);5859 await helper.wait.newBlocks(periodic.period);60 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);61 });62});