Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/capacitors/HashChainCapacitor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract HashChainCapacitor is BaseCapacitor {
address owner_,
uint256 maxPacketLength_
) BaseCapacitor(socket_, owner_) {
if (maxPacketLength > MAX_LEN) revert InvalidPacketLength();
if (maxPacketLength_ > MAX_LEN) revert InvalidPacketLength();
maxPacketLength = maxPacketLength_;
}

Expand All @@ -72,7 +72,7 @@ contract HashChainCapacitor is BaseCapacitor {
function updateMaxPacketLength(
uint256 maxPacketLength_
) external onlyOwner {
if (maxPacketLength > MAX_LEN) revert InvalidPacketLength();
if (maxPacketLength_ > MAX_LEN) revert InvalidPacketLength();
if (maxPacketLength_ < maxPacketLength) {
uint64 lastPackedMsgIndex = messagePacked;
uint64 packetCount = _nextPacketCount;
Expand Down
21 changes: 21 additions & 0 deletions test/capacitors/HashChainCapacitor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,27 @@ contract HashChainCapacitorTest is Setup {
assertEq(nextPacketId, packetId_, "packetId Invalid");
}

function testRevertOversizedConstructorPacketLength() external {
vm.expectRevert(HashChainCapacitor.InvalidPacketLength.selector);
new HashChainCapacitor(_socket, _socketOwner, 11);
}

function testRevertOversizedUpdatePacketLength() external {
hoax(_socketOwner);
vm.expectRevert(HashChainCapacitor.InvalidPacketLength.selector);
_hcCapacitor.updateMaxPacketLength(11);
}

function testAcceptBoundaryPacketLength() external {
hoax(_socketOwner);
_hcCapacitor.updateMaxPacketLength(10);
assertEq(
_hcCapacitor.getMaxPacketLength(),
10,
"Boundary length should be accepted"
);
}

function _assertPacketById(bytes32 root_, uint64 packetCount_) private {
bytes32 root = _hcCapacitor.getRootByCount(packetCount_);
bytes32 packedRoot = root_;
Expand Down