Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrower95 committed Dec 9, 2024
1 parent da34781 commit 8505714
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/utils/ZEnvHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,30 +232,29 @@ library ZEnvHelpers {
return vm.envBool(envvar);
}

function __markDirty(State storage s, string memory key) internal {
if (s._dirty[key] == Cleanliness.UNCHANGED) {
s._modifiedKeys.push(key);
}
s._dirty[key] = Cleanliness.DIRTY;
}

function clean(State storage s, string memory key) private {
require(s._dirty[key] == Cleanliness.DIRTY, string.concat(key, ": key was unchanged."));
s._dirty[key] = Cleanliness.UPTODATE;
}

/**
* Asserts that a contract was deployed, via deploySingleton/deployInstance/deployContract.
*/
function assertDeployed(State storage s, string[] memory contractNames) public onlyTest {
for (uint256 i = 0; i < contractNames.length; i++) {
clean(s, contractNames[i]);
}
}

/**
* Asserts that an environment variable was updated, i.e via `zUpdate*(...)`
*/
function assertUpdated(State storage s, string[] memory environmentParameters) public onlyTest {
for (uint256 i = 0; i < environmentParameters.length; i++) {
clean(s, environmentParameters[i]);
}
}

/**
* Asserts that there are no;
* - un-asserted changes to the state,
* - un-asserted deployments.
*/
function assertClean(State storage s) public onlyTest {
for (uint256 i = 0; i < s._modifiedKeys.length; i++) {
string memory message = string.concat(s._modifiedKeys[i], ": key was not asserted");
Expand All @@ -265,6 +264,20 @@ library ZEnvHelpers {
delete s._modifiedKeys;
}

///////////////////////////////////////////////////// private methods

function __markDirty(State storage s, string memory key) internal {
if (s._dirty[key] == Cleanliness.UNCHANGED) {
s._modifiedKeys.push(key);
}
s._dirty[key] = Cleanliness.DIRTY;
}

function clean(State storage s, string memory key) private {
require(s._dirty[key] == Cleanliness.DIRTY, string.concat(key, ": key was unchanged."));
s._dirty[key] = Cleanliness.UPTODATE;
}

modifier onlyTest() {
require(vm.envBool("ZEUS_TEST"), "not a zeus test");
_;
Expand Down

0 comments on commit 8505714

Please sign in to comment.