Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating committed Jan 2, 2024
1 parent 19d92a0 commit 06c241b
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 29 deletions.
3 changes: 2 additions & 1 deletion script/WormholeL2FlexibleVotingDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ contract WormholeL2FlexibleVotingDeploy is Script, ScriptConstants {
l1BlockAddress,
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId,
vm.envOr("CONTRACT_OWNER", msg.sender)
vm.envOr("CONTRACT_OWNER", msg.sender),
uint32(vm.envOr("CAST_WINDOW", uint256(1200)))
);

vm.broadcast();
Expand Down
2 changes: 1 addition & 1 deletion src/L2GovernorMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract contract L2GovernorMetadata {
/// @param _l1BlockAddress The address of the L1Block contract.
constructor(address _l1BlockAddress, uint32 castWindow) {
L1_BLOCK = IL1Block(_l1BlockAddress);
CAST_VOTE_WINDOW = castWindow;
CAST_VOTE_WINDOW = castWindow;
}

/// @notice Add proposal to internal storage.
Expand Down
5 changes: 2 additions & 3 deletions src/L2VoteAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ abstract contract L2VoteAggregator is EIP712, L2GovernorMetadata, L2CountingFrac
function proposalL1VoteActive(uint256 proposalId) public view returns (bool active) {
L2GovernorMetadata.Proposal memory proposal = getProposal(proposalId);

return L1_BLOCK.number() <= proposal.voteEnd
&& L1_BLOCK.number() >= proposal.voteStart && !proposal.isCanceled;
return L1_BLOCK.number() <= proposal.voteEnd && L1_BLOCK.number() >= proposal.voteStart
&& !proposal.isCanceled;
}

}
5 changes: 3 additions & 2 deletions src/WormholeL2VoteAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ contract WormholeL2VoteAggregator is WormholeSender, L2VoteAggregator, WormholeL
address _l1BlockAddress,
uint16 _sourceChain,
uint16 _targetChain,
address _owner
address _owner,
uint32 castWindow
)
L2VoteAggregator(_votingToken)
WormholeSender(_sourceChain, _targetChain)
WormholeL2GovernorMetadata(_relayer, _owner, _l1BlockAddress)
WormholeL2GovernorMetadata(_relayer, _owner, _l1BlockAddress, castWindow)
{}

/// @notice Wormhole-specific implementation of `_bridgeVote`.
Expand Down
4 changes: 2 additions & 2 deletions src/optimized/WormholeL2GovernorMetadataOptimized.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ contract WormholeL2GovernorMetadataOptimized is WormholeL2GovernorMetadata {
/// @notice The ID of the proposal mapped to an internal proposal ID.
mapping(uint256 governorProposalId => uint16) public optimizedProposalIds;

constructor(address _relayer, address _owner, address _l1BlockAddress)
WormholeL2GovernorMetadata(_relayer, _owner, _l1BlockAddress)
constructor(address _relayer, address _owner, address _l1BlockAddress, uint32 castWindow)
WormholeL2GovernorMetadata(_relayer, _owner, _l1BlockAddress, castWindow)
{}

/// @inheritdoc L2GovernorMetadata
Expand Down
6 changes: 4 additions & 2 deletions src/optimized/WormholeL2VoteAggregatorCalldataCompressor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ contract WormholeL2VoteAggregatorCalldataCompressor is WormholeL2VoteAggregator
address _l1BlockAddress,
uint16 _sourceChain,
uint16 _targetChain,
address _owner
address _owner,
uint32 castWindow
)
WormholeL2VoteAggregator(
_votingToken,
_relayer,
_l1BlockAddress,
_sourceChain,
_targetChain,
_owner
_owner,
castWindow
)
{}

Expand Down
3 changes: 2 additions & 1 deletion test/L2VoteAggregator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ contract CastVoteWithReasonAndParams is L2VoteAggregatorTest {
uint128 amount = uint128(againstVotes) + forVotes + abstainVotes;
vm.assume(againstVotes != 0);
vm.assume(abstainVotes != 0);
bytes memory firstVoteData = abi.encodePacked(uint128(againstVotes), uint128(forVotes), uint128(0));
bytes memory firstVoteData =
abi.encodePacked(uint128(againstVotes), uint128(forVotes), uint128(0));
bytes memory secondVoteData = abi.encodePacked(uint128(0), uint128(0), uint128(abstainVotes));

l2Erc20.mint(address(this), amount);
Expand Down
5 changes: 3 additions & 2 deletions test/WormholeL1GovernorMetadataBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ contract L1GovernorMetadataBridgeTest is TestConstants, WormholeRelayerBasicTest

function setUpTarget() public override {
L1BlockMock _mockL1Block = new L1BlockMock();
l2GovernorMetadata =
new WormholeL2GovernorMetadata(L2_CHAIN.wormholeRelayer, msg.sender, address(_mockL1Block));
l2GovernorMetadata = new WormholeL2GovernorMetadata(
L2_CHAIN.wormholeRelayer, msg.sender, address(_mockL1Block), 1200
);
vm.prank(l2GovernorMetadata.owner());
l2GovernorMetadata.setRegisteredSender(
L1_CHAIN.wormholeChainId, bytes32(uint256(uint160(address(l1GovernorMetadataBridge))))
Expand Down
3 changes: 2 additions & 1 deletion test/WormholeL1VotePool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ contract WormholeL1VotePoolTest is TestConstants, WormholeRelayerBasicTest {
L2_CHAIN.wormholeRelayer,
address(l1Block),
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId
L1_CHAIN.wormholeChainId,
1200
);
}

Expand Down
7 changes: 4 additions & 3 deletions test/WormholeL2GovernorMetadata.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ contract L2GovernorMetadataTest is TestConstants {

function setUp() public {
mockL1Block = new L1BlockMock();
l2GovernorMetadata =
new WormholeL2GovernorMetadata(L2_CHAIN.wormholeRelayer, msg.sender, address(mockL1Block));
l2GovernorMetadata = new WormholeL2GovernorMetadata(
L2_CHAIN.wormholeRelayer, msg.sender, address(mockL1Block), 1200
);
vm.prank(l2GovernorMetadata.owner());
l2GovernorMetadata.setRegisteredSender(
L1_CHAIN.wormholeChainId, MOCK_WORMHOLE_SERIALIZED_ADDRESS
Expand Down Expand Up @@ -65,7 +66,7 @@ contract L2GovernorMetadataTest is TestConstants {

contract Constructor is L2GovernorMetadataTest {
function testFuzz_CorrectlySetsAllArgs(address wormholeCore) public {
new WormholeL2GovernorMetadata(wormholeCore, msg.sender, address(ARBITRARY_ADDRESS));
new WormholeL2GovernorMetadata(wormholeCore, msg.sender, address(ARBITRARY_ADDRESS), 1200);
// nothing to assert as there are no constructor args set
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/WormholeL2VoteAggregator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ contract L2VoteAggregatorTest is TestConstants, WormholeRelayerBasicTest {
L2_CHAIN.wormholeRelayer,
address(l1Block),
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId
L1_CHAIN.wormholeChainId,
1200
);
}

Expand All @@ -73,7 +74,8 @@ contract Constructor is L2VoteAggregatorTest {
L2_CHAIN.wormholeRelayer,
address(l1Block),
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId
L1_CHAIN.wormholeChainId,
1200
);

assertEq(address(l1Block), address(l2VoteAggregator.L1_BLOCK()));
Expand Down
6 changes: 4 additions & 2 deletions test/harness/WormholeL2VoteAggregatorHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ contract WormholeL2VoteAggregatorHarness is WormholeL2VoteAggregator, GovernorMe
address _relayer,
address _l1BlockAddress,
uint16 _sourceChain,
uint16 _targetChain
uint16 _targetChain,
uint32 _castWindow
)
WormholeL2VoteAggregator(
_votingToken,
_relayer,
_l1BlockAddress,
_sourceChain,
_targetChain,
msg.sender
msg.sender,
_castWindow
)
{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {WormholeL2GovernorMetadataOptimized} from

contract WormholeL2GovernorMetadataOptimizedHarness is WormholeL2GovernorMetadataOptimized {
constructor(address _core, address _owner, address _l1BlockAddress)
WormholeL2GovernorMetadataOptimized(_core, _owner, _l1BlockAddress)
WormholeL2GovernorMetadataOptimized(_core, _owner, _l1BlockAddress, 1200)
{}

function exposed_addProposal(
Expand Down
6 changes: 4 additions & 2 deletions test/mock/GovernorMetadataMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract contract GovernorMetadataMockBase is L2GovernorMetadata {
}

contract GovernorMetadataMock is GovernorMetadataMockBase, WormholeL2GovernorMetadata {
constructor(address _core) WormholeL2GovernorMetadata(_core, msg.sender, address(0x1b)) {
constructor(address _core) WormholeL2GovernorMetadata(_core, msg.sender, address(0x1b), 1200) {
_proposals[1] =
Proposal({voteStart: block.number, voteEnd: block.number + 3000, isCanceled: false});
}
Expand All @@ -55,7 +55,9 @@ contract GovernorMetadataOptimizedMock is
GovernorMetadataMockBase,
WormholeL2GovernorMetadataOptimized
{
constructor(address _core) WormholeL2GovernorMetadataOptimized(_core, msg.sender, address(0x1b)) {}
constructor(address _core)
WormholeL2GovernorMetadataOptimized(_core, msg.sender, address(0x1b), 1200)
{}

function _addProposal(uint256 proposalId, uint256 voteStart, uint256 voteEnd, bool isCanceled)
internal
Expand Down
12 changes: 8 additions & 4 deletions test/optimized/WormholeL2VoteAggregatorCalldataCompressor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ contract WormholeL2VoteAggregatorCalldataCompressorHarness is
address _relayer,
address _l1BlockAddress,
uint16 _sourceChain,
uint16 _targetChain
uint16 _targetChain,
uint32 _castWindow
)
WormholeL2VoteAggregatorCalldataCompressor(
_votingToken,
_relayer,
_l1BlockAddress,
_sourceChain,
_targetChain,
msg.sender
msg.sender,
_castWindow
)
{}

Expand Down Expand Up @@ -91,14 +93,16 @@ contract WormholeL2ERC20CalldataCompressorTest is Test, TestConstants {
address(l1Block),
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId,
msg.sender
msg.sender,
1200
);
routerHarness = new WormholeL2VoteAggregatorCalldataCompressorHarness(
address(l2Erc20),
L2_CHAIN.wormholeRelayer,
address(l1Block),
L2_CHAIN.wormholeChainId,
L1_CHAIN.wormholeChainId
L1_CHAIN.wormholeChainId,
1200
);
}

Expand Down

0 comments on commit 06c241b

Please sign in to comment.