diff --git a/src/L2VetoAggregation.sol b/src/L2VetoAggregation.sol index 370caf8..ecf0607 100644 --- a/src/L2VetoAggregation.sol +++ b/src/L2VetoAggregation.sol @@ -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 @@ -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. @@ -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); @@ -128,4 +129,10 @@ contract L2VetoAggregation is NonblockingLzApp { _nativeFee: address(this).balance }); } + + function getProposal( + uint256 _proposal + ) external view returns (Proposal memory) { + return liveProposals[_proposal]; + } } diff --git a/src/lzApp/LzApp.sol b/src/lzApp/LzApp.sol index 0c97842..ad2aec1 100644 --- a/src/lzApp/LzApp.sol +++ b/src/lzApp/LzApp.sol @@ -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"; diff --git a/test/OptimisticTokenVotingPlugin.t.sol b/test/OptimisticTokenVotingPlugin.t.sol index ac22142..f31edc1 100644 --- a/test/OptimisticTokenVotingPlugin.t.sol +++ b/test/OptimisticTokenVotingPlugin.t.sol @@ -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 @@ -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,