Skip to content

Commit

Permalink
tests(dopedao): add lifecycle integration tests (#13)
Browse files Browse the repository at this point in the history
* oz bravo lifecycle

* test compare executing with eth

* remove console log

* update tests

* fix: upstream oz fix

taken from OpenZeppelin/openzeppelin-contracts@01f2ff1

Co-authored-by: Dennison Bertram <[email protected]>
  • Loading branch information
tarrencev and crazyrabbitLTC authored Sep 18, 2021
1 parent d87e975 commit e5ac92b
Show file tree
Hide file tree
Showing 11 changed files with 677 additions and 88 deletions.
24 changes: 18 additions & 6 deletions contracts/governance/DopeDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
GovernorTimelockCompound(_timelock)
{}

function votingDelay() public pure override returns (uint256) {
function votingDelay() public pure virtual override returns (uint256) {
return 13091; // 2 days (in blocks)
}

function votingPeriod() public pure override returns (uint256) {
function votingPeriod() public pure virtual override returns (uint256) {
return 45818; // 1 week (in blocks)
}

function quorum(uint256 blockNumber) public pure override returns (uint256) {
function quorum(uint256 blockNumber) public pure virtual override returns (uint256) {
return 500; // DOPE DAO NFT TOKENS
}

function proposalThreshold() public pure override returns (uint256) {
function proposalThreshold() public pure virtual override returns (uint256) {
return 50; // DOPE DAO NFT TOKENS
}

Expand Down Expand Up @@ -63,9 +63,14 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
bytes32 /*descriptionHash*/
) internal override(Governor, GovernorTimelockCompound) {
super._execute(proposalId, targets, values, calldatas, descriptionHash);
uint256 eta = proposalEta(proposalId);
require(eta > 0, "GovernorTimelockCompound: proposal not yet queued");
Address.sendValue(payable(timelock()), msg.value);
for (uint256 i = 0; i < targets.length; ++i) {
ICompoundTimelock(payable(timelock())).executeTransaction(targets[i], values[i], "", calldatas[i], eta);
}
}

function _cancel(
Expand All @@ -89,4 +94,11 @@ contract DopeDAO is Governor, GovernorCompatibilityBravo, GovernorVotesComp, Gov
{
return super.supportsInterface(interfaceId);
}

/**
* @dev Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
*/
receive() external payable virtual {
require(_executor() == address(this));
}
}
Loading

0 comments on commit e5ac92b

Please sign in to comment.