-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup natspec in InterfaceResolver, add unit tests
- Loading branch information
1 parent
953172f
commit 4b12718
Showing
4 changed files
with
82 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {ERC165} from "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol"; | ||
import {UpgradeableL2ResolverBase} from "./UpgradeableL2ResolverBase.t.sol"; | ||
import {ResolverBase} from "src/L2/resolver/ResolverBase.sol"; | ||
import {InterfaceResolver} from "src/L2/resolver/InterfaceResolver.sol"; | ||
|
||
contract SetInterface is UpgradeableL2ResolverBase { | ||
Counter counter; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
counter = new Counter(); | ||
} | ||
|
||
function test_reverts_forUnauthorizedUser() public { | ||
vm.expectRevert(abi.encodeWithSelector(ResolverBase.NotAuthorized.selector, node, notUser)); | ||
vm.prank(notUser); | ||
resolver.setInterface(node, type(ICounter).interfaceId, address(counter)); | ||
} | ||
|
||
function test_setsTheInterface_whenTheAddressIsSpecifiedExplicitly() public { | ||
vm.prank(user); | ||
resolver.setInterface(node, type(ICounter).interfaceId, address(counter)); | ||
assertEq(resolver.interfaceImplementer(node, type(ICounter).interfaceId), address(counter)); | ||
} | ||
|
||
function test_returnsTheInterface_whenTheAddressIsSetToTheAddrProfile() public { | ||
vm.prank(user); | ||
resolver.setAddr(node, address(counter)); | ||
assertEq(resolver.interfaceImplementer(node, type(ICounter).interfaceId), address(counter)); | ||
} | ||
} | ||
|
||
interface ICounter { | ||
function set(uint x) external; | ||
} | ||
|
||
contract Counter is ICounter, ERC165 { | ||
uint public x; | ||
function set(uint x_) external { | ||
x = x_; | ||
} | ||
/// @notice ERC-165 compliance. | ||
function supportsInterface(bytes4 interfaceID) public view virtual override returns (bool) { | ||
return interfaceID == type(ICounter).interfaceId || super.supportsInterface(interfaceID); | ||
} | ||
} |
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