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

Commit

Permalink
Infoless deploy test caching (#168)
Browse files Browse the repository at this point in the history
* add block start point caching

* check low block first

* don't write or roll a second time if low is correct'

* move file var to function

* forgot memory
  • Loading branch information
iamchrissmith authored Feb 21, 2023
1 parent 2d96dfe commit 11cc64f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ out = 'out'
libs = ['lib']
fs_permissions = [
{ access = "read", path = "./lib/dss-test/script/input/"},
{ access = "read", path = "./out/ArbitrumDomain.sol/ArbSysOverride.json"}
{ access = "read", path = "./out/ArbitrumDomain.sol/ArbSysOverride.json"},
{ access = "read-write", path = "./spellblock.txt"}
]

[rpc_endpoints]
Expand Down
1 change: 1 addition & 0 deletions spellblock.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8451434
25 changes: 15 additions & 10 deletions src/DssSpell.t.base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,26 @@ contract DssSpellTestBase is Config, DssTest {
return;
}

uint256 low = 5273074; // MCD_VAT Deployed Aug-06-2021 04:26:38 PM +UTC
string memory spellBlockPath = "./spellblock.txt";

uint256 low = vm.parseUint(vm.readLine(spellBlockPath));
uint256 high = block.number;
uint256 mid;

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

vm.rollFork(low);
}

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

0 comments on commit 11cc64f

Please sign in to comment.