generated from defientco/CRE8ORS_DROP_CONTRACT
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I add fuzzing to afterTokenTransfers hooks.
- Loading branch information
1 parent
ee6aee3
commit b742345
Showing
4 changed files
with
103 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.15; | ||
|
||
import {Vm} from "forge-std/Vm.sol"; | ||
import {DSTest} from "ds-test/test.sol"; | ||
import {ERC721ACHMock} from "./ERC721ACHMock.sol"; | ||
import {IERC721A} from "lib/ERC721A/contracts/IERC721A.sol"; | ||
import {BeforeTokenTransfersHookMock} from "../utils/hooks/BeforeTokenTransfersHookMock.sol"; | ||
import {IERC721ACH} from "../../src/interfaces/IERC721ACH.sol"; | ||
|
||
contract HookUtils is DSTest { | ||
address public constant DEFAULT_OWNER_ADDRESS = address(0xC0FFEE); | ||
address public constant DEFAULT_BUYER_ADDRESS = address(0xBABE); | ||
|
||
Vm public constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function _assumeNotNull(address _wallet) internal pure { | ||
vm.assume(_wallet != address(0)); | ||
} | ||
|
||
function _assumeGtZero(uint256 _num) internal pure { | ||
vm.assume(_num > 0); | ||
} | ||
|
||
function _assertNormalTransfer( | ||
address _target, | ||
address _from, | ||
address _to, | ||
uint256 _tokenId | ||
) public { | ||
vm.prank(_from); | ||
ERC721ACHMock(_target).transferFrom(_from, _to, _tokenId); | ||
|
||
_assertOwner(_target, _to, _tokenId); | ||
} | ||
|
||
function _assertOwner( | ||
address _target, | ||
address _owner, | ||
uint256 _token | ||
) internal { | ||
assertEq(_owner, ERC721ACHMock(_target).ownerOf(_token)); | ||
} | ||
|
||
function _assertTransferRevert( | ||
address _target, | ||
address _from, | ||
address _to, | ||
uint256 _tokenId, | ||
bytes4 _err | ||
) internal { | ||
vm.prank(_from); | ||
vm.expectRevert(_err); | ||
ERC721ACHMock(_target).transferFrom(_from, _to, _tokenId); | ||
} | ||
} |