-
This is the code of the test I have written function testGovernanceUpdatesBox() public {
uint256 valueTostore = 888;
string memory description = "store 1 in box";
bytes memory encodedFunctionCall = abi.encodeWithSignature("changeNum(uint256)", valueTostore);
// Propose to the DAO
callDatas.push(encodedFunctionCall);
values.push(0);
targets.push(address(box));
uint256 proposalId = governor.propose(targets, values, callDatas, description);
console.log("Proposal State:", uint256(governor.state(proposalId)));
// View the state
vm.warp(block.timestamp + VOTING_DELAY + 1);
vm.roll(block.number + VOTING_DELAY + 1);
console.log("Proposal State:", uint256(governor.state(proposalId)));
//Vote
string memory reason = "I wanna make this test pass";
uint8 voteType = 1;
vm.prank(USER);
governor.castVoteWithReason(proposalId, voteType, reason);
vm.warp(block.timestamp + VOTING_PERIOD + 1);
vm.roll(block.number + VOTING_PERIOD + 1);
// Queue
bytes32 descriptionHash = keccak256(abi.encodePacked(description));
governor.queue(targets, values, callDatas, descriptionHash);
vm.warp(block.timestamp + VOTING_PERIOD + 1);
vm.roll(block.number + VOTING_PERIOD + 1);
//Execute
governor.execute(targets, values, callDatas, descriptionHash);
assert(box.getNumber() == valueTostore);
console.log("Box Value:", box.getNumber());
}
} This is the error I have getting: [⠒] Compiling...
[⠰] Compiling 1 files with Solc 0.8.26
[⠔] Solc 0.8.26 finished in 7.29s
Compiler run successful!
Ran 1 test for test/MyGovernorTest.t.sol:MyGovernorTest
[FAIL: GovernorUnexpectedProposalState(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], 0, 0x0000000000000000000000000000000000000000000000000000000000000002)] testGovernanceUpdatesBox() (gas: 230520)
Logs:
Proposal State: 0
Proposal State: 0
Traces:
[6997238] MyGovernorTest::setUp()
├─ [1557333] → new GovToken@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
│ └─ ← [Return] 7547 bytes of code
├─ [96990] GovToken::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 100000000000000000000 [1e20])
│ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 100000000000000000000 [1e20])
│ └─ ← [Stop]
├─ [0] VM::startPrank(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ └─ ← [Return]
├─ [70235] GovToken::delegate(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ ├─ emit DelegateChanged(delegator: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], fromDelegate: 0x0000000000000000000000000000000000000000, toDelegate: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ ├─ emit DelegateVotesChanged(delegate: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], previousVotes: 0, newVotes: 100000000000000000000 [1e20])
│ └─ ← [Stop]
├─ [1385126] → new TimeLock@0x7BD1119CEC127eeCDBa5DCA7d1Bd59986f6d7353
│ ├─ emit RoleGranted(role: 0x0000000000000000000000000000000000000000000000000000000000000000, account: TimeLock: [0x7BD1119CEC127eeCDBa5DCA7d1Bd59986f6d7353], sender: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ ├─ emit RoleGranted(role: 0x0000000000000000000000000000000000000000000000000000000000000000, account: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], sender: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ ├─ emit MinDelayChange(oldDuration: 0, newDuration: 3600)
│ └─ ← [Return] 6550 bytes of code
├─ [3460150] → new MyGovernor@0x5929B14F2984bBE5309c2eC9E7819060C31c970f
│ ├─ emit VotingDelaySet(oldVotingDelay: 0, newVotingDelay: 7200)
│ ├─ emit VotingPeriodSet(oldVotingPeriod: 0, newVotingPeriod: 50400 [5.04e4])
│ ├─ emit ProposalThresholdSet(oldProposalThreshold: 0, newProposalThreshold: 0)
│ ├─ [423] GovToken::clock() [staticcall]
│ │ └─ ← [Return] 1
│ ├─ emit QuorumNumeratorUpdated(oldQuorumNumerator: 0, newQuorumNumerator: 4)
│ ├─ emit TimelockChange(oldTimelock: 0x0000000000000000000000000000000000000000, newTimelock: TimeLock: [0x7BD1119CEC127eeCDBa5DCA7d1Bd59986f6d7353])
│ └─ ← [Return] 16662 bytes of code
├─ [284] TimeLock::PROPOSER_ROLE() [staticcall]
│ └─ ← [Return] 0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1
├─ [285] TimeLock::EXECUTOR_ROLE() [staticcall]
│ └─ ← [Return] 0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63
├─ [260] TimeLock::DEFAULT_ADMIN_ROLE() [staticcall]
│ └─ ← [Return] 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [27564] TimeLock::grantRole(0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1, MyGovernor: [0x5929B14F2984bBE5309c2eC9E7819060C31c970f])
│ ├─ emit RoleGranted(role: 0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1, account: MyGovernor: [0x5929B14F2984bBE5309c2eC9E7819060C31c970f], sender: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ └─ ← [Stop]
├─ [27564] TimeLock::grantRole(0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63, 0x0000000000000000000000000000000000000000)
│ ├─ emit RoleGranted(role: 0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63, account: 0x0000000000000000000000000000000000000000, sender: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ └─ ← [Stop]
├─ [5577] TimeLock::revokeRole(0x0000000000000000000000000000000000000000000000000000000000000000, user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ ├─ emit RoleRevoked(role: 0x0000000000000000000000000000000000000000000000000000000000000000, account: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], sender: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ └─ ← [Stop]
├─ [0] VM::stopPrank()
│ └─ ← [Return]
├─ [140325] → new Box@0x2e234DAe75C793f67A35089C9d99245E1C58470b
│ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: MyGovernorTest: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496])
│ └─ ← [Return] 582 bytes of code
├─ [2360] Box::transferOwnership(TimeLock: [0x7BD1119CEC127eeCDBa5DCA7d1Bd59986f6d7353])
│ ├─ emit OwnershipTransferred(previousOwner: MyGovernorTest: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], newOwner: TimeLock: [0x7BD1119CEC127eeCDBa5DCA7d1Bd59986f6d7353])
│ └─ ← [Stop]
└─ ← [Stop]
[230520] MyGovernorTest::testGovernanceUpdatesBox()
├─ [44308] MyGovernor::propose([0x2e234DAe75C793f67A35089C9d99245E1C58470b], [0], [0x2b3113370000000000000000000000000000000000000000000000000000000000000378], "store 1 in box")
│ ├─ [423] GovToken::clock() [staticcall]
│ │ └─ ← [Return] 1
│ ├─ emit ProposalCreated(proposalId: 89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], proposer: MyGovernorTest: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], targets: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], values: [0], signatures: [""], calldatas: [0x2b3113370000000000000000000000000000000000000000000000000000000000000378], voteStart: 7201, voteEnd: 57601 [5.76e4], description: "store 1 in box")
│ └─ ← [Return] 89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76]
├─ [2098] MyGovernor::state(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76]) [staticcall]
│ ├─ [423] GovToken::clock() [staticcall]
│ │ └─ ← [Return] 1
│ └─ ← [Return] 0
├─ [0] console::log("Proposal State:", 0) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::warp(3)
│ └─ ← [Return]
├─ [0] VM::roll(3)
│ └─ ← [Return]
├─ [2098] MyGovernor::state(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76]) [staticcall]
│ ├─ [423] GovToken::clock() [staticcall]
│ │ └─ ← [Return] 3
│ └─ ← [Return] 0
├─ [0] console::log("Proposal State:", 0) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::prank(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
│ └─ ← [Return]
├─ [3017] MyGovernor::castVoteWithReason(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], 1, "I wanna make this test pass")
│ ├─ [423] GovToken::clock() [staticcall]
│ │ └─ ← [Return] 3
│ └─ ← [Revert] GovernorUnexpectedProposalState(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], 0, 0x0000000000000000000000000000000000000000000000000000000000000002)
└─ ← [Revert] GovernorUnexpectedProposalState(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], 0, 0x0000000000000000000000000000000000000000000000000000000000000002)
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 5.39ms (1.00ms CPU time)
Ran 1 test suite in 2.04s (5.39ms CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)
Failing tests:
Encountered 1 failing test in test/MyGovernorTest.t.sol:MyGovernorTest
[FAIL: GovernorUnexpectedProposalState(89607897455185585357498873665714134756598187173001886731714074496488858308207 [8.96e76], 0, 0x0000000000000000000000000000000000000000000000000000000000000002)] testGovernanceUpdatesBox() (gas: 230520)
Encountered a total of 1 failing tests, 0 tests succeeded |
Beta Was this translation helpful? Give feedback.
Answered by
EngrPips
Jan 8, 2025
Replies: 1 comment 4 replies
-
Hey @Ifra001, Please show your test file fully. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, why is your
voting_delay
1I have it has 7200 in my test which works fine. Can you change that and retry the process? Don't forget to delete the cache folder if you have any and also run
forge clean
before retrying.