1234567891011121314151617import {expect} from 'chai';1819import {EthUniqueHelper, itEth} from './util/playgrounds';20import {Pallets} 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, helper.address.substrateToEth(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.sendEVM(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 helper.wait.newBlocks(waitForBlocks + 1);52 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);5354 await helper.wait.newBlocks(periodic.period);55 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);56 });57});