git.delta.rocks / unique-network / refs/commits / ed03202113fd

difftreelog

fix use playgrounds in eth scheduler test

Daniel Shiposha2022-09-23parent: #0320222.patch.diff
in: master

1 file changed

modifiedtests/src/.outdated/eth/scheduling.test.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from '../../deprecated-helpers/eth/helpers';18import {subToEth} from './util/helpers';
19import {makeScheduledId, scheduleAfter, waitNewBlocks, requirePallets, Pallets} from '../../deprecated-helpers/helpers';19import {waitNewBlocks, Pallets} from '../util/helpers';
2020import {EthUniqueHelper, itEth} from './util/playgrounds';
21// TODO mrshiposha update this test in #58121
22describe.skip('Scheduing EVM smart contracts', () => {22describe('Scheduing EVM smart contracts', () => {
23 before(async function() {
24 await requirePallets(this, [Pallets.Scheduler]);
25 });
2623
27 itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {24 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {
25 const alice = privateKey('//Alice');
26
28 const scheduledId = await makeScheduledId();27 const scheduledId = await helper.arrange.makeScheduledId();
28
29 const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);29 const deployer = await helper.eth.createAccountWithBalance(alice);
30 const flipper = await deployFlipper(web3, deployer);30 const flipper = await helper.eth.deployFlipper(deployer);
31
31 const initialValue = await flipper.methods.getValue().call();32 const initialValue = await flipper.methods.getValue().call();
32 const alice = privateKeyWrapper('//Alice');
33 await transferBalanceToEth(api, alice, subToEth(alice.address));33 await helper.eth.transferBalanceFromSubstrate(alice, subToEth(alice.address));
3434
35 {
36 const tx = api.tx.evm.call(35 const waitForBlocks = 4;
36 const periodic = {
37 period: 2,
38 repetitions: 2,
39 };
40
41 await helper.scheduler.scheduleAfter<EthUniqueHelper>(scheduledId, waitForBlocks, {periodic})
42 .eth.callEVM(
37 subToEth(alice.address),43 alice,
38 flipper.options.address,44 flipper.options.address,
39 flipper.methods.flip().encodeABI(),45 flipper.methods.flip().encodeABI(),
40 '0',46 '0',
41 GAS_ARGS.gas,
42 await web3.eth.getGasPrice(),
43 null,
44 null,
45 [],
46 );47 );
47 const waitForBlocks = 4;48
48 const periodBlocks = 2;
49 const repetitions = 2;
50
51 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);49 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);
61 50
62 await waitNewBlocks(waitForBlocks + 1);51 await waitNewBlocks(waitForBlocks + 1);
63 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);52 expect(await flipper.methods.getValue().call()).to.be.not.equal(initialValue);
64 53
65 await waitNewBlocks(periodBlocks);54 await waitNewBlocks(periodic.period);
66 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);55 expect(await flipper.methods.getValue().call()).to.be.equal(initialValue);
67 }
68 });56 });
69});57});
7058