Governor.t.sol 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {Test} from "forge-std/Test.sol";
  4. import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
  5. import {Governor} from "@openzeppelin/contracts/governance/Governor.sol";
  6. contract GovernorInternalTest is Test, Governor {
  7. constructor() Governor("") {}
  8. function testValidDescriptionForProposer(
  9. string memory description,
  10. address proposer,
  11. bool includeProposer
  12. ) public view {
  13. if (includeProposer) {
  14. description = string.concat(description, "#proposer=", Strings.toHexString(proposer));
  15. }
  16. assertTrue(_isValidDescriptionForProposer(proposer, description));
  17. }
  18. function testInvalidDescriptionForProposer(
  19. string memory description,
  20. address commitProposer,
  21. address actualProposer
  22. ) public view {
  23. vm.assume(commitProposer != actualProposer);
  24. description = string.concat(description, "#proposer=", Strings.toHexString(commitProposer));
  25. assertFalse(_isValidDescriptionForProposer(actualProposer, description));
  26. }
  27. // We don't need to truly implement the missing functions because we are just testing
  28. // internal helpers.
  29. function clock() public pure override returns (uint48) {}
  30. // solhint-disable-next-line func-name-mixedcase
  31. function CLOCK_MODE() public pure override returns (string memory) {}
  32. // solhint-disable-next-line func-name-mixedcase
  33. function COUNTING_MODE() public pure virtual override returns (string memory) {}
  34. function votingDelay() public pure virtual override returns (uint256) {}
  35. function votingPeriod() public pure virtual override returns (uint256) {}
  36. function quorum(uint256) public pure virtual override returns (uint256) {}
  37. function hasVoted(uint256, address) public pure virtual override returns (bool) {}
  38. function _quorumReached(uint256) internal pure virtual override returns (bool) {}
  39. function _voteSucceeded(uint256) internal pure virtual override returns (bool) {}
  40. function _getVotes(address, uint256, bytes memory) internal pure virtual override returns (uint256) {}
  41. function _countVote(uint256, address, uint8, uint256, bytes memory) internal virtual override returns (uint256) {}
  42. }