|
| 1 | +// SPDX-License-Identifier: MPL-2.0 |
| 2 | +pragma solidity ^0.8.20; |
| 3 | + |
| 4 | +import "forge-std/Test.sol"; |
| 5 | +import "../HelperContractOwnable.sol"; |
| 6 | +import {RuleEngineOwnableExposed} from "src/mocks/RuleEngineExposed.sol"; |
| 7 | + |
| 8 | +/** |
| 9 | + * @title Coverage tests for RuleEngineOwnable (supportsInterface fallback, _msgData) |
| 10 | + */ |
| 11 | +contract RuleEngineOwnableCoverageTest is Test, HelperContractOwnable { |
| 12 | + RuleEngineOwnableExposed public ruleEngineOwnableExposed; |
| 13 | + |
| 14 | + // Known interface IDs |
| 15 | + bytes4 constant RULE_ENGINE_ID = 0x20c49ce7; |
| 16 | + bytes4 constant ERC1404_EXTEND_ID = 0x78a8de7d; |
| 17 | + bytes4 constant ERC173_ID = 0x7f5828d0; |
| 18 | + bytes4 constant ERC165_ID = 0x01ffc9a7; |
| 19 | + bytes4 constant INVALID_ID = 0xffffffff; |
| 20 | + |
| 21 | + function setUp() public { |
| 22 | + ruleEngineMock = new RuleEngineOwnable( |
| 23 | + OWNER_ADDRESS, |
| 24 | + ZERO_ADDRESS, |
| 25 | + ZERO_ADDRESS |
| 26 | + ); |
| 27 | + ruleEngineOwnableExposed = new RuleEngineOwnableExposed( |
| 28 | + OWNER_ADDRESS, |
| 29 | + ZERO_ADDRESS, |
| 30 | + ZERO_ADDRESS |
| 31 | + ); |
| 32 | + } |
| 33 | + |
| 34 | + /*////////////////////////////////////////////////////////////// |
| 35 | + SUPPORTS INTERFACE |
| 36 | + //////////////////////////////////////////////////////////////*/ |
| 37 | + |
| 38 | + function testSupportsRuleEngineInterface() public view { |
| 39 | + assertTrue(ruleEngineMock.supportsInterface(RULE_ENGINE_ID)); |
| 40 | + } |
| 41 | + |
| 42 | + function testSupportsERC1404ExtendInterface() public view { |
| 43 | + assertTrue(ruleEngineMock.supportsInterface(ERC1404_EXTEND_ID)); |
| 44 | + } |
| 45 | + |
| 46 | + function testSupportsERC173Interface() public view { |
| 47 | + assertTrue(ruleEngineMock.supportsInterface(ERC173_ID)); |
| 48 | + } |
| 49 | + |
| 50 | + function testSupportsERC165ViaAccessControlFallback() public view { |
| 51 | + // This hits line 61: AccessControl.supportsInterface(interfaceId) |
| 52 | + assertTrue(ruleEngineMock.supportsInterface(ERC165_ID)); |
| 53 | + } |
| 54 | + |
| 55 | + function testDoesNotSupportInvalidInterface() public view { |
| 56 | + // Falls through all checks including AccessControl.supportsInterface → false |
| 57 | + assertFalse(ruleEngineMock.supportsInterface(INVALID_ID)); |
| 58 | + } |
| 59 | + |
| 60 | + /*////////////////////////////////////////////////////////////// |
| 61 | + MSG DATA |
| 62 | + //////////////////////////////////////////////////////////////*/ |
| 63 | + |
| 64 | + function testMsgDataReturnsCalldata() public view { |
| 65 | + bytes memory data = ruleEngineOwnableExposed.exposedMsgData(); |
| 66 | + // Should return the calldata (selector of exposedMsgData) |
| 67 | + assertEq(data.length, 4); |
| 68 | + assertEq(bytes4(data), ruleEngineOwnableExposed.exposedMsgData.selector); |
| 69 | + } |
| 70 | +} |
0 commit comments