Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests #9

Merged
merged 10 commits into from
Dec 4, 2023
Prev Previous commit
Next Next commit
chore: run forge fmt src
  • Loading branch information
fiveoutofnine committed Dec 3, 2023
commit 1d2bc99630df225e7f502b07c4a53b7d3ce9d7b4
4 changes: 3 additions & 1 deletion src/CurtaGolf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ contract CurtaGolf is ICurtaGolf, KingERC721, Owned {
/// @inheritdoc ICurtaGolf
function setAllowedOpcodes(uint32 _courseId, uint256 _allowedOpcodes) external onlyOwner {
// Revert if the course does not exist.
if (address(getCourse[_courseId].course) == address(0)) revert CourseDoesNotExist(_courseId);
if (address(getCourse[_courseId].course) == address(0)) {
revert CourseDoesNotExist(_courseId);
}

// Set allowed opcodes for the course.
allowedOpcodes[_courseId] = _allowedOpcodes;
Expand Down
7 changes: 6 additions & 1 deletion src/utils/PurityChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { IPurityChecker } from "../interfaces/IPurityChecker.sol";
/// @notice A purity checker checks whether a given contract is pure, i.e. that
/// it's restricted to a set of instructions/opcodes, by analyzing its bytecode.
contract PurityChecker is IPurityChecker {
function check(bytes memory _code, uint256 _allowedOpcodes) external pure override returns (bool satisfied) {
function check(bytes memory _code, uint256 _allowedOpcodes)
external
pure
override
returns (bool satisfied)
{
return _allowedOpcodes > 0;
/* assembly ("memory-safe") {
function isPush(opcode) -> ret {
Expand Down