Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Fix binary search (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
naszam authored Feb 13, 2023
1 parent 82d733c commit 2d96dfe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/DssSpell.t.base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,17 @@ contract DssSpellTestBase is Config, DssTest {
uint256 high = block.number;
uint256 mid;

while (low != high) {
mid = (low + high) / 2;
while (low < high) {
mid = (low & high) + (low ^ high) / 2; // rounds down
vm.rollFork(mid);
if (_isContractDeployed(_spell)) {
high = mid - 1;
high = mid;
} else {
low = mid + 1;
}
}

vm.rollFork(low + 1);
vm.rollFork(low);
}

function _isContractDeployed(address _spell) internal view returns (bool) {
Expand Down

0 comments on commit 2d96dfe

Please sign in to comment.