proposer vote for automatically
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
2f8aedb6e3
commit
f878ae44dd
@ -137,6 +137,7 @@ contract GhostGovernor is
|
||||
}
|
||||
|
||||
proposalId = _propose(targets, values, calldatas, description, proposer);
|
||||
_countVote(proposalId, proposer, 1, proposerVotes, "");
|
||||
|
||||
lockedAmounts[proposalId] += proposerVotes;
|
||||
activeProposedLock = proposerVotes;
|
||||
|
||||
@ -168,10 +168,12 @@ contract GhostGovernorTest is Test {
|
||||
|
||||
assertEq(uint8(governor.state(proposalId)), uint8(IGovernor.ProposalState.Active));
|
||||
_castVoteWrapper(proposalId, bob, 1, true, true);
|
||||
assertEq(uint8(governor.state(proposalId)), uint8(IGovernor.ProposalState.Active));
|
||||
_castVoteWrapper(proposalId, carol, 1, true, true);
|
||||
assertEq(uint8(governor.state(proposalId)), uint8(IGovernor.ProposalState.Succeeded));
|
||||
|
||||
vm.expectRevert();
|
||||
vm.prank(carol);
|
||||
governor.castVote(proposalId, 0);
|
||||
|
||||
vm.expectRevert();
|
||||
vm.prank(dave);
|
||||
governor.castVote(proposalId, 0);
|
||||
@ -219,16 +221,15 @@ contract GhostGovernorTest is Test {
|
||||
assertEq(governor.lockedAmounts(proposalId), amount);
|
||||
assertEq(ghst.balanceOf(alice), 0);
|
||||
|
||||
_castVoteWrapper(proposalId, alice, 1, false, false);
|
||||
(uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) = governor.proposalVotes(proposalId);
|
||||
assertEq(againstVotes, 0);
|
||||
assertEq(forVotes, 0);
|
||||
assertEq(forVotes, amount);
|
||||
assertEq(abstainVotes, 0);
|
||||
|
||||
_castVoteWrapper(proposalId, bob, 1, true, true);
|
||||
(againstVotes, forVotes, abstainVotes) = governor.proposalVotes(proposalId);
|
||||
assertEq(againstVotes, 0);
|
||||
assertEq(forVotes, 2 * amount);
|
||||
assertEq(forVotes, 3 * amount);
|
||||
assertEq(abstainVotes, 0);
|
||||
|
||||
assertEq(ghst.balanceOf(alice), 0);
|
||||
@ -254,7 +255,7 @@ contract GhostGovernorTest is Test {
|
||||
(proposalId,,,,) = _proposeDummy(bob, 420);
|
||||
_waitForActive(proposalId);
|
||||
|
||||
_castVoteWrapper(proposalId, alice, 1, false, true);
|
||||
_castVoteWrapper(proposalId, alice, 1, true, true);
|
||||
_castVoteWrapper(proposalId, carol, 1, true, true);
|
||||
|
||||
vm.roll(block.number + 3);
|
||||
@ -375,9 +376,9 @@ contract GhostGovernorTest is Test {
|
||||
assertEq(governor.voteOf(proposalId, eve), 0);
|
||||
|
||||
vm.roll(governor.proposalDeadline(proposalId));
|
||||
_castVoteWrapper(proposalId, bob, 1, false, false);
|
||||
_castVoteWrapper(proposalId, bob, 1, false, true);
|
||||
vm.roll(governor.proposalDeadline(proposalId));
|
||||
_castVoteWrapper(proposalId, carol, 0, false, false);
|
||||
_castVoteWrapper(proposalId, carol, 0, true, false);
|
||||
vm.roll(governor.proposalDeadline(proposalId));
|
||||
_castVoteWrapper(proposalId, dave, 1, true, false);
|
||||
vm.roll(governor.proposalDeadline(proposalId));
|
||||
@ -492,6 +493,27 @@ contract GhostGovernorTest is Test {
|
||||
assertEq(ghst.totalSupply(), 200);
|
||||
}
|
||||
|
||||
function test_proposeAutoForVote() public {
|
||||
vm.startPrank(init);
|
||||
ghst.mint(alice, PROPOSAL_THRESHOLD);
|
||||
ghst.mint(bob, 69 * PROPOSAL_THRESHOLD);
|
||||
vm.stopPrank();
|
||||
|
||||
vm.roll(block.number + 1);
|
||||
(uint256 proposalId,,,,) = _proposeDummy(alice, 69);
|
||||
|
||||
(uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) = governor.proposalVotes(proposalId);
|
||||
assertEq(forVotes, PROPOSAL_THRESHOLD);
|
||||
assertEq(againstVotes, 0);
|
||||
assertEq(abstainVotes, 0);
|
||||
|
||||
vm.roll(block.number + 1);
|
||||
|
||||
vm.expectRevert();
|
||||
vm.prank(alice);
|
||||
governor.castVote(proposalId, 1);
|
||||
}
|
||||
|
||||
function _proposeDummy(address who, uint256 index)
|
||||
private
|
||||
returns (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user