Skip to content

Commit

Permalink
test: adding tests for the full happy path for crosschain voting
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgj94 committed Mar 24, 2024
1 parent c01df99 commit 73d169e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/L2VetoAggregation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,8 @@ contract L2VetoAggregation is NonblockingLzApp {
) external view returns (Proposal memory) {
return liveProposals[_proposal];
}

function getVotingToken() public view returns (IVotesUpgradeable) {
return votingToken;
}
}
19 changes: 14 additions & 5 deletions test/OptimisticTokenVotingPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,17 @@ contract OptimisticTokenVotingPluginTest is Test {
}

// Crosschain Functionality Testing Starts Here
function test_L2VoteAggregatorCreatesProposal() public {
function test_CroscchainHappyPath() public {
dao.grant(address(plugin), bob, plugin.PROPOSER_PERMISSION_ID());
IVotesUpgradeable _token = l2VetoAggregation.getVotingToken();
ERC20VotesMock(address(_token)).mint(bob, 1 ether);

vm.stopPrank();
vm.startPrank(bob);

ERC20VotesMock(address(_token)).delegate(bob);
vm.roll(block.number + 10);

IDAO.Action[] memory actions = new IDAO.Action[](0);
uint64 endDate = uint64(block.timestamp + 10 days);
uint256 proposalId = plugin.createProposal{value: 1 ether}(
Expand All @@ -1997,14 +2002,18 @@ contract OptimisticTokenVotingPluginTest is Test {
L2VetoAggregation.Proposal memory l2proposal = l2VetoAggregation
.getProposal(proposalId);
assertEq(l2proposal.endDate, endDate);
assertEq(l2proposal.vetoes, 0);

vm.warp(1 days);
l2VetoAggregation.veto(proposalId);

l2proposal = l2VetoAggregation.getProposal(proposalId);
assertEq(l2proposal.vetoes, 0);

vm.warp(10 days);
assertEq(l2proposal.vetoes, 1 ether);
vm.warp(9 days);
l2VetoAggregation.bridgeResults{value: 0.1 ether}(proposalId);

(, , , uint256 vetoTally, , uint256 _allowFailureMap) = plugin
.getProposal(proposalId);
assertEq(vetoTally, 1 ether, "Vetos were not bridged");
}

// HELPERS
Expand Down

0 comments on commit 73d169e

Please sign in to comment.