mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 01:37:07 +01:00
ETHMixer refund test
This commit is contained in:
parent
63771560c6
commit
a13a7306e2
@ -24,8 +24,9 @@ contract ETHMixer is Mixer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal {
|
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal {
|
||||||
|
// sanity checks
|
||||||
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
|
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
|
||||||
require(_refund == 0, "Message value is supposed to be zero for ETH mixer");
|
require(_refund == 0, "Refund value is supposed to be zero for ETH mixer");
|
||||||
|
|
||||||
_receiver.transfer(denomination - _fee);
|
_receiver.transfer(denomination - _fee);
|
||||||
if (_fee > 0) {
|
if (_fee > 0) {
|
||||||
|
@ -404,6 +404,33 @@ contract('ETHMixer', accounts => {
|
|||||||
// should work with original values
|
// should work with original values
|
||||||
await mixer.withdraw(originalProof, originalPublicSignals, { from: relayer }).should.be.fulfilled
|
await mixer.withdraw(originalProof, originalPublicSignals, { from: relayer }).should.be.fulfilled
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should reject with non zero refund', async () => {
|
||||||
|
const deposit = generateDeposit()
|
||||||
|
await tree.insert(deposit.commitment)
|
||||||
|
await mixer.deposit(toBN(deposit.commitment.toString()), { value, from: sender })
|
||||||
|
|
||||||
|
const { root, path_elements, path_index } = await tree.path(0)
|
||||||
|
|
||||||
|
const input = stringifyBigInts({
|
||||||
|
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
|
||||||
|
root,
|
||||||
|
nullifier: deposit.nullifier,
|
||||||
|
relayer: operator,
|
||||||
|
receiver,
|
||||||
|
fee,
|
||||||
|
refund: bigInt(1),
|
||||||
|
secret: deposit.secret,
|
||||||
|
pathElements: path_elements,
|
||||||
|
pathIndex: path_index,
|
||||||
|
})
|
||||||
|
|
||||||
|
const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key)
|
||||||
|
const { proof, publicSignals } = websnarkUtils.toSolidityInput(proofData)
|
||||||
|
|
||||||
|
const error = await mixer.withdraw(proof, publicSignals, { from: relayer }).should.be.rejected
|
||||||
|
error.reason.should.be.equal('Refund value is supposed to be zero for ETH mixer')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#changeOperator', () => {
|
describe('#changeOperator', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user