cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
18 stars 38 forks source link

Define base contract for testing ERC-165 contracts #188

Closed guidanoli closed 7 months ago

guidanoli commented 8 months ago

📚 Context

ERC-165 defines an interface for checking if a contract implements a given interface or not. On @cartesi/rollups v2.0.0, several contracts will implement ERC-165. With this, we need to test if these contracts are implementing it properly. Testing it is pretty straightforward, given that the interface only specifies one function, supportsInterface. We just need to make sure this function returns true for the interface ID of IERC165 and all the other supported interfaces (depends on the contract) and does not support all others, including 0xffffffff.

✔️ Solution

Define an abstract contract for testing ERC-165 contracts. This contract should inherit from the Test contract from the forge-std library, and define two virtual functions. One provides the IERC165 contract, and the other, the list of supported interface IDs (besides ERC165, obviously).