Governor.t.sol 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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(string memory description, address proposer, bool includeProposer) public {
  9. if (includeProposer) {
  10. description = string.concat(description, "#proposer=", Strings.toHexString(proposer));
  11. }
  12. assertTrue(_isValidDescriptionForProposer(proposer, description));
  13. }
  14. function testInvalidDescriptionForProposer(
  15. string memory description,
  16. address commitProposer,
  17. address actualProposer
  18. ) public {
  19. vm.assume(commitProposer != actualProposer);
  20. description = string.concat(description, "#proposer=", Strings.toHexString(commitProposer));
  21. assertFalse(_isValidDescriptionForProposer(actualProposer, description));
  22. }
  23. // We don't need to truly implement implement the missing functions because we are just testing
  24. // internal helpers.
  25. function clock() public pure override returns (uint48) {}
  26. // solhint-disable-next-line func-name-mixedcase
  27. function CLOCK_MODE() public pure override returns (string memory) {}
  28. // solhint-disable-next-line func-name-mixedcase
  29. function COUNTING_MODE() public pure virtual override returns (string memory) {}
  30. function votingDelay() public pure virtual override returns (uint256) {}
  31. function votingPeriod() public pure virtual override returns (uint256) {}
  32. function quorum(uint256) public pure virtual override returns (uint256) {}
  33. function hasVoted(uint256, address) public pure virtual override returns (bool) {}
  34. function _quorumReached(uint256) internal pure virtual override returns (bool) {}
  35. function _voteSucceeded(uint256) internal pure virtual override returns (bool) {}
  36. function _getVotes(address, uint256, bytes memory) internal pure virtual override returns (uint256) {}
  37. function _countVote(uint256, address, uint8, uint256, bytes memory) internal virtual override {}
  38. }