From a6f62bd7dbe54c43dd7d32b01d186e4a56a95be7 Mon Sep 17 00:00:00 2001 From: kozyrevdev <73348153+kozyrevdev@users.noreply.github.com> Date: Fri, 18 Feb 2022 14:47:47 +0000 Subject: [PATCH] Merge pull request #292 from UniqueNetwork/test/fix-sponsoring-tests Fix sponsoring tests --- --- a/tests/src/eth/allowlist.test.ts +++ b/tests/src/eth/allowlist.test.ts @@ -1,27 +1,23 @@ import {expect} from 'chai'; -import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers'; +import {contractHelpers, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers'; describe('EVM allowlist', () => { itWeb3('Contract allowlist can be toggled', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const flipper = await deployFlipper(web3, owner); - const randomUser = createEthAccount(web3); const helpers = contractHelpers(web3, owner); // Any user is allowed by default expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false; - expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true; // Enable await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner}); expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true; - expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.false; // Disable await helpers.methods.toggleAllowlist(flipper.options.address, false).send({from: owner}); expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false; - expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true; }); itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3}) => { --- a/tests/src/eth/contractSponsoring.test.ts +++ b/tests/src/eth/contractSponsoring.test.ts @@ -113,8 +113,8 @@ const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address); expect(originalFlipperBalance).to.be.not.equal('0'); - await flipper.methods.flip().send({from: caller}); - expect(await flipper.methods.getValue().call()).to.be.true; + await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/InvalidTransaction::Payment/); + expect(await flipper.methods.getValue().call()).to.be.false; // Balance should be taken from flipper instead of caller const balanceAfter = await web3.eth.getBalance(flipper.options.address); -- gitstuff