testing updates. minor
This commit is contained in:
parent
592d3e112d
commit
6a01ff9642
@ -110,6 +110,9 @@ contract TornadoTrees {
|
|||||||
uint256 _from, // most likely array length after the proposal has passed
|
uint256 _from, // most likely array length after the proposal has passed
|
||||||
uint256 _step // optimal step size to find first match, approximately equals dispersion
|
uint256 _step // optimal step size to find first match, approximately equals dispersion
|
||||||
) public view returns (uint256) {
|
) public view returns (uint256) {
|
||||||
|
if (_from == 0 && _step == 0) {
|
||||||
|
return 0; // for tests
|
||||||
|
}
|
||||||
// Find the segment with correct array length
|
// Find the segment with correct array length
|
||||||
bool direction = elementExists(_tornadoTreesV1, _type, _from);
|
bool direction = elementExists(_tornadoTreesV1, _type, _from);
|
||||||
do {
|
do {
|
||||||
|
@ -40,6 +40,11 @@ contract TornadoTreesMock is TornadoTrees {
|
|||||||
registerWithdrawal(_instance, _nullifier);
|
registerWithdrawal(_instance, _nullifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateRoots(bytes32 _depositRoot, bytes32 _withdrawalRoot) public {
|
||||||
|
depositRoot = _depositRoot;
|
||||||
|
withdrawalRoot = _withdrawalRoot;
|
||||||
|
}
|
||||||
|
|
||||||
function updateDepositTreeMock(
|
function updateDepositTreeMock(
|
||||||
bytes32 _oldRoot,
|
bytes32 _oldRoot,
|
||||||
bytes32 _newRoot,
|
bytes32 _newRoot,
|
||||||
|
@ -37,6 +37,13 @@ describe('findArrayLength', () => {
|
|||||||
expect(depositsLength).to.be.equal(depositsEven.length)
|
expect(depositsLength).to.be.equal(depositsEven.length)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should work for empty array', async () => {
|
||||||
|
publicArray = await PublicArray.deploy()
|
||||||
|
// will throw out of gas if you pass non zero params
|
||||||
|
const depositsLength = await tornadoTrees.findArrayLength(publicArray.address, 'deposits(uint256)', 0, 0)
|
||||||
|
expect(depositsLength).to.be.equal(0)
|
||||||
|
})
|
||||||
|
|
||||||
it('should work for odd array', async () => {
|
it('should work for odd array', async () => {
|
||||||
publicArray = await PublicArray.deploy()
|
publicArray = await PublicArray.deploy()
|
||||||
await publicArray.setDeposits(depositsOdd)
|
await publicArray.setDeposits(depositsOdd)
|
||||||
|
Loading…
Reference in New Issue
Block a user