mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-10-01 01:06:17 -04:00
fix tests
This commit is contained in:
parent
9009b9c56d
commit
010837f92b
@ -56,6 +56,8 @@ contract ERC20Mixer is Mixer {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
require(success, "not enough allowed tokens");
|
require(success, "not enough allowed tokens");
|
||||||
|
|
||||||
|
// if contract returns some data let's make sure that is `true` according to standard
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
assembly {
|
assembly {
|
||||||
success := mload(add(data, 0x20))
|
success := mload(add(data, 0x20))
|
||||||
@ -75,6 +77,8 @@ contract ERC20Mixer is Mixer {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
require(success, "not enough tokens");
|
require(success, "not enough tokens");
|
||||||
|
|
||||||
|
// if contract returns some data let's make sure that is `true` according to standard
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
assembly {
|
assembly {
|
||||||
success := mload(add(data, 0x20))
|
success := mload(add(data, 0x20))
|
||||||
|
@ -29,7 +29,7 @@ contract Mixer is MerkleTreeWithHistory {
|
|||||||
uint256 public mixDenomination;
|
uint256 public mixDenomination;
|
||||||
|
|
||||||
event Deposit(uint256 indexed commitment, uint256 leafIndex, uint256 timestamp);
|
event Deposit(uint256 indexed commitment, uint256 leafIndex, uint256 timestamp);
|
||||||
event Withdraw(address to, uint256 nullifierHash, address relayer, uint256 fee);
|
event Withdraw(address to, uint256 nullifierHash, address indexed relayer, uint256 fee);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@dev The constructor
|
@dev The constructor
|
||||||
|
@ -127,7 +127,7 @@ contract('ERC20Mixer', accounts => {
|
|||||||
// public
|
// public
|
||||||
root,
|
root,
|
||||||
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
|
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
|
||||||
relayer: operator,
|
relayer,
|
||||||
receiver,
|
receiver,
|
||||||
fee,
|
fee,
|
||||||
|
|
||||||
@ -160,15 +160,15 @@ contract('ERC20Mixer', accounts => {
|
|||||||
const balanceRecieverAfter = await token.balanceOf(toHex(receiver.toString()))
|
const balanceRecieverAfter = await token.balanceOf(toHex(receiver.toString()))
|
||||||
const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString()))
|
const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString()))
|
||||||
const feeBN = toBN(fee.toString())
|
const feeBN = toBN(fee.toString())
|
||||||
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(value)))
|
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination)))
|
||||||
balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore))
|
balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore).add(feeBN))
|
||||||
ethBalanceOperatorAfter.should.be.eq.BN(toBN(ethBalanceOperatorBefore))
|
ethBalanceOperatorAfter.should.be.eq.BN(toBN(ethBalanceOperatorBefore))
|
||||||
balanceRecieverAfter.should.be.eq.BN(toBN(balanceRecieverBefore).add(toBN(tokenDenomination).sub(feeBN)))
|
balanceRecieverAfter.should.be.eq.BN(toBN(balanceRecieverBefore).add(toBN(tokenDenomination).sub(feeBN)))
|
||||||
ethBalanceRecieverAfter.should.be.eq.BN(toBN(ethBalanceRecieverBefore).add(toBN(value)))
|
ethBalanceRecieverAfter.should.be.eq.BN(toBN(ethBalanceRecieverBefore).add(toBN(value)))
|
||||||
|
|
||||||
logs[0].event.should.be.equal('Withdraw')
|
logs[0].event.should.be.equal('Withdraw')
|
||||||
logs[0].args.nullifierHash.should.be.eq.BN(toBN(input.nullifierHash.toString()))
|
logs[0].args.nullifierHash.should.be.eq.BN(toBN(input.nullifierHash.toString()))
|
||||||
logs[0].args.relayer.should.be.eq.BN(operator)
|
logs[0].args.relayer.should.be.eq.BN(relayer)
|
||||||
logs[0].args.fee.should.be.eq.BN(feeBN)
|
logs[0].args.fee.should.be.eq.BN(feeBN)
|
||||||
isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000'))
|
isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000'))
|
||||||
isSpent.should.be.equal(true)
|
isSpent.should.be.equal(true)
|
||||||
|
@ -190,6 +190,15 @@ contract('MerkleTreeWithHistory', accounts => {
|
|||||||
error = await merkleTreeWithHistory.insert(1).should.be.rejected
|
error = await merkleTreeWithHistory.insert(1).should.be.rejected
|
||||||
error.reason.should.be.equal('Merkle tree is full')
|
error.reason.should.be.equal('Merkle tree is full')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it.skip('mimc gas', async () => {
|
||||||
|
levels = 6
|
||||||
|
zeroValue = 1337
|
||||||
|
merkleTreeWithHistory = await MerkleTreeWithHistory.new(levels, zeroValue)
|
||||||
|
|
||||||
|
const gas = await merkleTreeWithHistory.hashLeftRight.estimateGas(zeroValue, zeroValue)
|
||||||
|
console.log('gas', gas - 21000)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user