1234567891011121314151617import {expect} from 'chai';18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';19import {scheduleExpectSuccess, waitNewBlocks} from '../util/helpers';2021describe('Scheduing EVM smart contracts', () => {22 itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {23 const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);24 const flipper = await deployFlipper(web3, deployer);25 const initialValue = await flipper.methods.getValue().call();26 const alice = privateKeyWrapper('//Alice');27 await transferBalanceToEth(api, alice, subToEth(alice.address));2829 {30 const tx = api.tx.evm.call(31 subToEth(alice.address),32 flipper.options.address,33 flipper.methods.flip().encodeABI(),34 '0',35 GAS_ARGS.gas,36 await web3.eth.getGasPrice(),37 null,38 null,39 [],40 );41 const waitForBlocks = 4;42 const periodBlocks = 2;4344 await scheduleExpectSuccess(tx, alice, waitForBlocks, '0x' + '0'.repeat(32), periodBlocks, 2);45 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);46 47 await waitNewBlocks(waitForBlocks - 1);48 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);49 50 await waitNewBlocks(periodBlocks);51 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);52 }53 });54});