diff --git a/test/L1VotePool.t.sol b/test/L1VotePool.t.sol index 3ab2fcc5..72d70793 100644 --- a/test/L1VotePool.t.sol +++ b/test/L1VotePool.t.sol @@ -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, @@ -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); @@ -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); } @@ -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); @@ -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, @@ -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"); @@ -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, @@ -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"); @@ -361,9 +363,7 @@ contract _ReceiveCastVoteWormholeMessages is L1VotePoolTest { bytes32(uint256(uint160(address(l2VoteAggregator)))), L2_CHAIN.wormholeChainId, bytes32(""), - false + false ); } - - }