Skip to content

Commit

Permalink
chore: update ds-test to old version (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
edag94 authored Apr 7, 2022
1 parent f71c269 commit d42c3fa
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions contracts/DSTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.5.0;
pragma solidity >=0.4.23;

contract DSTest {
event log (string);
Expand All @@ -36,51 +36,16 @@ contract DSTest {
event log_named_string (string key, string val);

bool public IS_TEST = true;
bool private _failed;
bool public failed;

address constant HEVM_ADDRESS =
address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));

modifier mayRevert() { _; }
modifier testopts(string memory) { _; }

function failed() public returns (bool) {
if (_failed) {
return _failed;
} else {
bool globalFailed = false;
if (hasHEVMContext()) {
(, bytes memory retdata) = HEVM_ADDRESS.call(
abi.encodePacked(
bytes4(keccak256("load(address,bytes32)")),
abi.encode(HEVM_ADDRESS, bytes32("failed"))
)
);
globalFailed = abi.decode(retdata, (bool));
}
return globalFailed;
}
}

function fail() internal {
if (hasHEVMContext()) {
HEVM_ADDRESS.call(
abi.encodePacked(
bytes4(keccak256("store(address,bytes32,bytes32)")),
abi.encode(HEVM_ADDRESS, bytes32("failed"), bytes32(uint256(0x01)))
)
);

}
_failed = true;
}

function hasHEVMContext() internal view returns (bool) {
uint256 hevmCodeSize = 0;
assembly {
hevmCodeSize := extcodesize(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D)
}
return hevmCodeSize > 0;
failed = true;
}

modifier logs_gas() {
Expand Down

0 comments on commit d42c3fa

Please sign in to comment.