Skip to content

Commit

Permalink
test: update tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedali8 committed Aug 6, 2023
1 parent 627a251 commit 826e927
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/hooks/OwnerOfHook.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ contract OwnerOfHookTest is DSTest {

test_setOwnerOfHook();
erc721Mock.mint(DEFAULT_BUYER_ADDRESS, tokenId);

assertEq(DEFAULT_BUYER_ADDRESS, erc721Mock.ownerOf(tokenId));

hookMock.setHooksEnabled(true);
hookMock.setRevertOwnerOfOverrideHook(true);
vm.expectRevert(OwnerOfHookMock.OwnerOfHook_Executed.selector);
erc721Mock.ownerOf(tokenId);
}
Expand Down
10 changes: 8 additions & 2 deletions test/utils/hooks/OwnerOfHookMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ contract OwnerOfHookMock is IOwnerOfHook {
/// @notice hook was executed
error OwnerOfHook_Executed();

bool public revertOwnerOfOverrideHook;
bool public hooksEnabled;
address public fixedOwner;

function setRevertOwnerOfOverrideHook(bool _enabled) public {
revertOwnerOfOverrideHook = _enabled;
}

/// @notice toggle ownerOf hook.
function setHooksEnabled(bool _enabled) public {
hooksEnabled = _enabled;
Expand All @@ -31,7 +36,8 @@ contract OwnerOfHookMock is IOwnerOfHook {
/// @notice custom implementation for ownerOf Hook.
function ownerOfOverrideHook(
uint256
) external view override returns (address) {
revert OwnerOfHook_Executed();
) external view override returns (address, bool) {
if (revertOwnerOfOverrideHook) revert OwnerOfHook_Executed();
return (address(0), true); // run super
}
}

0 comments on commit 826e927

Please sign in to comment.