Skip to content

Commit

Permalink
All tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating committed Sep 12, 2023
1 parent 009171c commit 3f0cb5d
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions test/L1VotePool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ import {console2} from "forge-std/console2.sol";
contract L1VotePoolHarness is L1VotePool, Test {
constructor(address _relayer, address _governor) WormholeBase(_relayer) L1VotePool(_governor) {}

function _jumpToActiveProposal(uint256 proposalId) public {
uint256 _deadline = governor.proposalDeadline(proposalId);
vm.roll(_deadline - 1);
}

/// @dev We need this function because when we call `performDelivery` the proposal is not active,
/// and it does
/// not seem configurable in
function receiveWormholeMessages(
bytes memory payload,
bytes[] memory additionalVaas,
Expand Down Expand Up @@ -48,7 +56,6 @@ contract L1VotePoolHarness is L1VotePool, Test {
);
}


function _createExampleProposal(address l1Erc20) internal returns (uint256) {
bytes memory proposalCalldata = abi.encode(FakeERC20.mint.selector, address(governor), 100_000);

Expand Down Expand Up @@ -84,17 +91,12 @@ contract L1VotePoolHarness is L1VotePool, Test {
return _proposalId;
}

function _jumpToActiveProposal(uint256 proposalId) internal {
uint256 _deadline = governor.proposalDeadline(proposalId);
vm.roll(_deadline - 1);
}

function _jumpToProposalEnd(uint256 proposalId) external {
function _jumpToProposalEnd(uint256 proposalId) external {
uint256 _deadline = governor.proposalDeadline(proposalId);
vm.roll(_deadline);
}

function _jumpToProposalEnd(uint256 proposalId, uint32 additionalBlocks) external {
function _jumpToProposalEnd(uint256 proposalId, uint32 additionalBlocks) external {
uint256 _deadline = governor.proposalDeadline(proposalId);
vm.roll(_deadline + additionalBlocks);
}
Expand Down Expand Up @@ -278,6 +280,7 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
vm.roll(block.number + 1); // To checkpoint erc20 mint
uint256 _proposalId =
l1VotePool.createProposalVote(address(l1Erc20), _l2Against, _l2InFavor, _l2Abstain);
l1VotePool._jumpToActiveProposal(_proposalId);

vm.prank(L1_CHAIN.wormholeRelayer);
vm.expectRevert(L1VotePool.InvalidProposalVote.selector);
Expand All @@ -286,11 +289,12 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
new bytes[](0),
bytes32(uint256(uint160(address(l2VoteAggregator)))),
L2_CHAIN.wormholeChainId,
bytes32("")
bytes32(""),
false
);
}

function testFuzz_RevertWhen_VoteBeforeProposalStart(
function testFuzz_RevertWhen_VoteBeforeProposalStart(
uint32 _l2Against,
uint32 _l2InFavor,
uint32 _l2Abstain,
Expand All @@ -310,9 +314,8 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
l1Erc20.mint(address(this), uint96(_l2Against) + uint96(_l2InFavor) + uint96(_l2Abstain));
l1Erc20.delegate(address(l1VotePool));

uint256 _proposalId =
l1VotePool.createProposalVote(address(l1Erc20));
console2.logString("vote created");
uint256 _proposalId = l1VotePool.createProposalVote(address(l1Erc20));
console2.logString("vote created");

vm.prank(L1_CHAIN.wormholeRelayer);
vm.expectRevert("Governor: vote not currently active");
Expand All @@ -322,11 +325,11 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
bytes32(uint256(uint160(address(l2VoteAggregator)))),
L2_CHAIN.wormholeChainId,
bytes32(""),
false
false
);
}

function testFuzz_RevertWhen_VoteAfterProposalEnd(
function testFuzz_RevertWhen_VoteAfterProposalEnd(
uint32 _l2Against,
uint32 _l2InFavor,
uint32 _l2Abstain,
Expand All @@ -346,12 +349,11 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
l1Erc20.mint(address(this), uint96(_l2Against) + uint96(_l2InFavor) + uint96(_l2Abstain));
l1Erc20.delegate(address(l1VotePool));

console2.logString("Proposal block");
console2.logUint(block.number);
uint256 _proposalId =
l1VotePool.createProposalVote(address(l1Erc20));
l1VotePool._jumpToProposalEnd(_proposalId, 1);
console2.logString("vote created");
console2.logString("Proposal block");
console2.logUint(block.number);
uint256 _proposalId = l1VotePool.createProposalVote(address(l1Erc20));
l1VotePool._jumpToProposalEnd(_proposalId, 1);
console2.logString("vote created");

vm.prank(L1_CHAIN.wormholeRelayer);
vm.expectRevert("Governor: vote not currently active");
Expand All @@ -361,9 +363,7 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest {
bytes32(uint256(uint160(address(l2VoteAggregator)))),
L2_CHAIN.wormholeChainId,
bytes32(""),
false
false
);
}


}

0 comments on commit 3f0cb5d

Please sign in to comment.