difftreelog
Merge pull request #292 from UniqueNetwork/test/fix-sponsoring-tests
in: master
Fix sponsoring tests
2 files changed
tests/src/eth/allowlist.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';2import {contractHelpers, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';334describe('EVM allowlist', () => {4describe('EVM allowlist', () => {5 itWeb3('Contract allowlist can be toggled', async ({api, web3}) => {5 itWeb3('Contract allowlist can be toggled', async ({api, web3}) => {6 const owner = await createEthAccountWithBalance(api, web3);6 const owner = await createEthAccountWithBalance(api, web3);7 const flipper = await deployFlipper(web3, owner);7 const flipper = await deployFlipper(web3, owner);8 const randomUser = createEthAccount(web3);9810 const helpers = contractHelpers(web3, owner);9 const helpers = contractHelpers(web3, owner);111012 // Any user is allowed by default11 // Any user is allowed by default13 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;12 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;14 expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;151316 // Enable14 // Enable17 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});15 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});18 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true;16 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true;19 expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.false;201721 // Disable18 // Disable22 await helpers.methods.toggleAllowlist(flipper.options.address, false).send({from: owner});19 await helpers.methods.toggleAllowlist(flipper.options.address, false).send({from: owner});23 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;20 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;24 expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;25 });21 });262227 itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {23 itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth113 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);113 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);114 expect(originalFlipperBalance).to.be.not.equal('0');114 expect(originalFlipperBalance).to.be.not.equal('0');115115116 await flipper.methods.flip().send({from: caller});116 await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/InvalidTransaction::Payment/);117 expect(await flipper.methods.getValue().call()).to.be.true;117 expect(await flipper.methods.getValue().call()).to.be.false;118118119 // Balance should be taken from flipper instead of caller119 // Balance should be taken from flipper instead of caller120 const balanceAfter = await web3.eth.getBalance(flipper.options.address);120 const balanceAfter = await web3.eth.getBalance(flipper.options.address);