Skip to content
Discussion options

You must be logged in to vote

The reason nothing works: that branch is unreachable on the contract under test. clock() returns Time.timestamp() and CLOCK_MODE() compares it against Time.timestamp() — the two are always equal, so no state manipulation can make them diverge, and mockCallRevert can't cover it because it never executes the function body (the branch is never evaluated by the EVM).

The standard pattern for defensive-but-dead branches: deploy a test harness that inherits the contract under test and overrides only clock(), so the comparison genuinely fails and the real code path executes:

import {ERC20Votes} from "openzeppelin/token/ERC20/extensions/ERC20Votes.sol";

contract InconsistentClock is ERC20Votes {…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Niferu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants