difftreelog
add test `Gas price boundaries`
in: master
1 file changed
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth403 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equal('7200');403 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equal('7200');404 });404 });405406 itEth('Gas price boundaries', async ({helper}) => {407 const owner = await helper.eth.createAccountWithBalance(donor);408 const sponsor = await helper.eth.createAccountWithBalance(donor);409 const caller = await helper.eth.createAccountWithBalance(donor);410 const helpers = await helper.ethNativeContract.contractHelpers(owner);411 const flipper = await helper.eth.deployFlipper(owner);412413 await helpers.methods.setSponsor(flipper.options.address, sponsor).send();414 await helpers.methods.confirmSponsorship(flipper.options.address).send({from: sponsor});415416 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: owner});417 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});418419 let sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));420 let callerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(caller));421422 let expectValue = await flipper.methods.getValue().call();423424 const flip = async (gasPrice: bigint, shouldPass = true) => {425 await flipper.methods.flip().send({from: caller, gasPrice: gasPrice});426 expectValue = !expectValue;427 expect(await flipper.methods.getValue().call()).to.be.eq(expectValue);428 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));429 const callerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(caller));430 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.eq(shouldPass);431 expect(callerBalanceAfter === callerBalanceBefore).to.be.eq(shouldPass);432 sponsorBalanceBefore = sponsorBalanceAfter;433 callerBalanceBefore = callerBalanceAfter;434 };435436 const gasPrice = BigInt(await helper.eth.getGasPrice());437 await flip(gasPrice);438 await flip(gasPrice * 2n);439 await flip(gasPrice * 21n / 10n);440 await flip(gasPrice * 22n / 10n, false);441 });405});442});406443407describe('Sponsoring Fee Limit', () => {444describe('Sponsoring Fee Limit', () => {