Skip to content

Commit

Permalink
fix: fixing l2vetoaggregator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgj94 committed Mar 23, 2024
1 parent e2ae5f2 commit 699186c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/L2VetoAggregation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {NonblockingLzApp} from "./lzApp/NonblockingLzApp.sol";
contract L2VetoAggregation is NonblockingLzApp {
struct Proposal {
uint256 startDate;
uint256 endDate;
uint64 endDate;
}

/// @notice A container for the majority voting bridge settings that will be required when bridging and receiving the proposals from other chains
Expand Down Expand Up @@ -60,9 +60,10 @@ contract L2VetoAggregation is NonblockingLzApp {
__LzApp_init(bridgeSettings.bridge);

bytes memory remoteAddresses = abi.encodePacked(
_bridgeSettings.l1Plugin
_bridgeSettings.l1Plugin,
address(this)
);
setTrustedRemoteAddress(_bridgeSettings.chainId, remoteAddresses);
setTrustedRemote(_bridgeSettings.chainId, remoteAddresses);
}

// This function is called when data is received. It overrides the equivalent function in the parent contract.
Expand All @@ -78,9 +79,9 @@ contract L2VetoAggregation is NonblockingLzApp {
_msgSender() == address(this),
"NonblockingLzApp: caller must be LzApp"
);
(uint256 proposalId, uint256 startDate, uint256 endDate) = abi.decode(
(uint256 proposalId, uint256 startDate, uint64 endDate) = abi.decode(
_payload,
(uint256, uint256, uint256)
(uint256, uint256, uint64)
);

liveProposals[proposalId] = Proposal(startDate, endDate);
Expand Down Expand Up @@ -128,4 +129,10 @@ contract L2VetoAggregation is NonblockingLzApp {
_nativeFee: address(this).balance
});
}

function getProposal(
uint256 _proposal
) external view returns (Proposal memory) {
return liveProposals[_proposal];
}
}
1 change: 1 addition & 0 deletions src/lzApp/LzApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pragma solidity ^0.8.0;

import {Test, console2} from "forge-std/Test.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@layerzero/lzApp/interfaces/ILayerZeroReceiver.sol";
import "@layerzero/lzApp/interfaces/ILayerZeroUserApplicationConfig.sol";
Expand Down
30 changes: 30 additions & 0 deletions test/OptimisticTokenVotingPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ contract OptimisticTokenVotingPluginTest is Test {

// Alice can create proposals on the plugin
dao.grant(address(plugin), alice, plugin.PROPOSER_PERMISSION_ID());

L2VetoAggregation.BridgeSettings
memory l2bridgeSettings = L2VetoAggregation.BridgeSettings(
1,
l2EndpointMock,
address(plugin)
);
l2VetoAggregation.initialize(l2bridgeSettings);
}

// Initialize
Expand Down Expand Up @@ -1964,6 +1972,28 @@ contract OptimisticTokenVotingPluginTest is Test {
);
}

// Crosschain Functionality Testing Starts Here
function test_L2VoteAggregatorCreatesProposal() public {
dao.grant(address(plugin), bob, plugin.PROPOSER_PERMISSION_ID());

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

IDAO.Action[] memory actions = new IDAO.Action[](0);
uint64 endDate = uint64(block.timestamp + 10 days);
uint256 proposalId = plugin.createProposal{value: 1 ether}(
"",
actions,
0,
0,
0
);
assertEq(proposalId, 0);
L2VetoAggregation.Proposal memory l2proposal = l2VetoAggregation
.getProposal(proposalId);
assertEq(l2proposal.endDate, endDate);
}

// HELPERS
function createProxyAndCall(
address _logic,
Expand Down

0 comments on commit 699186c

Please sign in to comment.