Skip to content

Commit

Permalink
Bugfix CryticAsserts log emission (#8)
Browse files Browse the repository at this point in the history
* Bugfix CryticAsserts log emission

* chore: forge fmt

* chore: slither

* chore: slither
  • Loading branch information
aviggiano authored Apr 3, 2024
1 parent ff089ff commit 1548edc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
36 changes: 24 additions & 12 deletions src/CryticAsserts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,45 @@ contract CryticAsserts is Asserts {
event Log(string);

function gt(uint256 a, uint256 b, string memory reason) internal virtual override {
emit Log(reason);
assert(a > b);
if (!(a > b)) {
emit Log(reason);
assert(false);
}
}

function gte(uint256 a, uint256 b, string memory reason) internal virtual override {
emit Log(reason);
assert(a >= b);
if (!(a >= b)) {
emit Log(reason);
assert(false);
}
}

function lt(uint256 a, uint256 b, string memory reason) internal virtual override {
emit Log(reason);
assert(a < b);
if (!(a < b)) {
emit Log(reason);
assert(false);
}
}

function lte(uint256 a, uint256 b, string memory reason) internal virtual override {
emit Log(reason);
assert(a <= b);
if (!(a <= b)) {
emit Log(reason);
assert(false);
}
}

function eq(uint256 a, uint256 b, string memory reason) internal virtual override {
emit Log(reason);
assert(a == b);
if (!(a == b)) {
emit Log(reason);
assert(false);
}
}

function t(bool b, string memory reason) internal virtual override {
emit Log(reason);
assert(b);
if (!b) {
emit Log(reason);
assert(false);
}
}

function between(uint256 value, uint256 low, uint256 high) internal virtual override returns (uint256) {
Expand Down
15 changes: 7 additions & 8 deletions src/Hevm.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// slither-disable-start shadowing-local

interface IHevm {
// Set block.timestamp to newTimestamp
function warp(uint256 newTimestamp) external;
Expand All @@ -22,18 +24,13 @@ interface IHevm {
function store(address where, bytes32 slot, bytes32 value) external;

// Signs data (privateKey, digest) => (r, v, s)
function sign(
uint256 privateKey,
bytes32 digest
) external returns (uint8 r, bytes32 v, bytes32 s);
function sign(uint256 privateKey, bytes32 digest) external returns (uint8 r, bytes32 v, bytes32 s);

// Gets address for a given private key
function addr(uint256 privateKey) external returns (address addr);

// Performs a foreign function call via terminal
function ffi(
string[] calldata inputs
) external returns (bytes memory result);
function ffi(string[] calldata inputs) external returns (bytes memory result);

// Performs the next smart contract call with specified `msg.sender`
function prank(address newSender) external;
Expand All @@ -52,3 +49,5 @@ interface IHevm {
}

IHevm constant vm = IHevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);

// slither-disable-end shadowing-local

0 comments on commit 1548edc

Please sign in to comment.