From b578213b0c2e7b2867c1d4416bf1511b2357cdd6 Mon Sep 17 00:00:00 2001 From: poma Date: Sat, 2 Nov 2019 11:39:07 +0300 Subject: [PATCH] check that eth value in ERC20 deposit is zero --- contracts/ERC20Mixer.sol | 1 + test/ERC20Mixer.test.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/contracts/ERC20Mixer.sol b/contracts/ERC20Mixer.sol index 5941f0e..fdee640 100644 --- a/contracts/ERC20Mixer.sol +++ b/contracts/ERC20Mixer.sol @@ -28,6 +28,7 @@ contract ERC20Mixer is Mixer { } function _processDeposit() internal { + require(msg.value == 0, "ETH value is supposed to be 0 for ETH mixer"); safeErc20TransferFrom(msg.sender, address(this), denomination); } diff --git a/test/ERC20Mixer.test.js b/test/ERC20Mixer.test.js index 8e0d42d..8818a79 100644 --- a/test/ERC20Mixer.test.js +++ b/test/ERC20Mixer.test.js @@ -102,6 +102,14 @@ contract('ERC20Mixer', accounts => { logs[0].args.commitment.should.be.eq.BN(toBN(commitment)) logs[0].args.leafIndex.should.be.eq.BN(toBN(0)) }) + + it('should not allow to send ether on deposit', async () => { + const commitment = 43 + await token.approve(mixer.address, tokenDenomination) + + let error = await mixer.deposit(commitment, { from: sender, value: 1e6 }).should.be.rejected + error.reason.should.be.equal('ETH value is supposed to be 0 for ETH mixer') + }) }) describe('#withdraw', () => {