check that eth value in ERC20 deposit is zero

This commit is contained in:
poma 2019-11-02 11:39:07 +03:00
parent bec65f217f
commit b578213b0c
2 changed files with 9 additions and 0 deletions

View File

@ -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);
}

View File

@ -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', () => {