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
tests: add CurtaGolf unit tests
  • Loading branch information
fiveoutofnine committed Dec 3, 2023
commit 39364aa34e0382843bd226eb0330b45d7997f473
5 changes: 5 additions & 0 deletions src/CurtaGolf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ contract CurtaGolf is ICurtaGolf, KingERC721, Owned {

// Commit the key.
getCommit[_key] = Commit({ player: msg.sender, timestamp: uint96(block.timestamp) });

// Emit event.
emit CommitSolution(msg.sender, _key);
}

/// @inheritdoc ICurtaGolf
Expand Down Expand Up @@ -229,6 +232,8 @@ contract CurtaGolf is ICurtaGolf, KingERC721, Owned {

/// @inheritdoc KingERC721
function tokenURI(uint256 _id) public view override returns (string memory) {
require(_ownerOf[_id] != address(0), "NOT_MINTED");

return "TODO";
}
}
19 changes: 9 additions & 10 deletions src/interfaces/ICurtaGolf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,9 @@ interface ICurtaGolf {
event AddCourse(uint32 indexed id, ICourse indexed course);

/// @notice Emitted when a commit for a solution is made.
/// @param courseId The ID of the course.
/// @param player The address of the player.
/// @param key The key of the commit.
event CommitSolution(uint32 indexed courseId, address indexed player, bytes32 key);

/// @notice Emitted when a valid submission is made.
/// @param courseId The ID of the course.
/// @param recipient The address of the recipient.
/// @param target The address of the deployed solution.
event SubmitSolution(
uint32 indexed courseId, address indexed recipient, address indexed target
);
event CommitSolution(address indexed player, bytes32 indexed key);

/// @notice Emitted when new allowed opcodes are set for a course.
/// @param courseId The ID of the course.
Expand All @@ -97,6 +88,14 @@ interface ICurtaGolf {
/// @param purityChecker The address of the new purity checker.
event SetPurityChecker(IPurityChecker indexed purityChecker);

/// @notice Emitted when a valid submission is made.
/// @param courseId The ID of the course.
/// @param recipient The address of the recipient.
/// @param target The address of the deployed solution.
event SubmitSolution(
uint32 indexed courseId, address indexed recipient, address indexed target
);

/// @notice Emitted when a course gets a new King.
/// @param courseId The ID of the course.
/// @param recipient The address of the recipient.
Expand Down
5 changes: 3 additions & 2 deletions src/utils/PurityChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { IPurityChecker } from "../interfaces/IPurityChecker.sol";
/// 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) {
assembly ("memory-safe") {
return _allowedOpcodes > 0;
/* assembly ("memory-safe") {
function isPush(opcode) -> ret {
ret := and(gt(opcode, 0x5f), lt(opcode, 0x80))
}
Expand Down Expand Up @@ -41,6 +42,6 @@ contract PurityChecker is IPurityChecker {
}
}
satisfied := perform(_code, _allowedOpcodes)
}
} */
}
}
Loading