From 8505714b9d6b518b97e240f7b0bec4b8a48c9fe2 Mon Sep 17 00:00:00 2001 From: Justin Brower Date: Mon, 9 Dec 2024 17:45:04 -0500 Subject: [PATCH] add comments --- src/utils/ZEnvHelpers.sol | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/utils/ZEnvHelpers.sol b/src/utils/ZEnvHelpers.sol index c7df177..42d4e41 100644 --- a/src/utils/ZEnvHelpers.sol +++ b/src/utils/ZEnvHelpers.sol @@ -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"); @@ -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"); _;