Lesson 14: Foundry DAO #2385
Answered
by
ArnaudBand
ArnaudBand
asked this question in
Q&A
-
|
I got an error when I was running the test function testGovernanceUpdatesBox() public {
uint256 valueToStore = 777;
string memory description = "Store 1 in Box";
bytes memory encodedFunctionCall = abi.encodeWithSignature("store(uint256)", valueToStore);
targets.push(address(box));
values.push(0);
calldatas.push(encodedFunctionCall);
// 1. Propose to the DAO
vm.prank(USER);
token.delegate(USER);
uint256 proposalId = governor.propose(targets, values, calldatas, description);
console.log("Proposal State:", uint256(governor.state(proposalId)));
vm.warp(block.timestamp + VOTING_DELAY + 1);
vm.roll(block.number + VOTING_DELAY + 1);
console.log("Proposal State:", uint256(governor.state(proposalId)));
// 2. Vote
string memory reason = "I like 777";
// 0 = Against, 1 = For, 2 = Abstain for this example
uint8 voteWay = 1;
vm.prank(VOTER);
governor.castVoteWithReason(proposalId, voteWay, reason);
vm.warp(block.timestamp + VOTING_PERIOD + 1);
vm.roll(block.number + VOTING_PERIOD + 1);
console.log("Proposal State:", uint256(governor.state(proposalId)));
// 3. Queue
bytes32 descriptionHash = keccak256(abi.encodePacked(description));
governor.queue(targets, values, calldatas, descriptionHash);
vm.roll(block.number + MINI_DELAY + 1);
vm.warp(block.timestamp + MINI_DELAY + 1);
// 4. Execute
governor.execute(targets, values, calldatas, descriptionHash);
assert(box.getNumber() == valueToStore);
}
and here the error: function setUp() public {
token = new GovernToken();
token.mint(USER, INITIAL_SUPPLY);
vm.startBroadcast(USER);
token.delegate(USER);
console.log('The balance of USER',token.balanceOf(USER));
timelock = new TimeLock(MINI_DELAY, proposers, executors);
governor = new MyGovernor(token, timelock);
bytes32 proposerRole = timelock.PROPOSER_ROLE();
bytes32 executorRole = timelock.EXECUTOR_ROLE();
bytes32 adminRole = timelock.DEFAULT_ADMIN_ROLE();
timelock.grantRole(proposerRole, address(governor));
timelock.grantRole(executorRole, address(governor));
timelock.revokeRole(adminRole, USER);
vm.stopBroadcast();
box = new Box();
box.transferOwnership(address(timelock));
} |
Beta Was this translation helpful? Give feedback.
Answered by
ArnaudBand
Sep 4, 2024
Replies: 2 comments
-
|
Apologize, I found the error. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ArnaudBand
-
|
Interesting. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Apologize, I found the error.