Skip to content

Commit

Permalink
All tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Feb 1, 2024
1 parent d63c7d4 commit 1a475e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/lib/V2DutchOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ library CosignerExtraDataLib {
uint256 bytesOffset = 33;

if (hasExclusiveFiller(extraData)) {
// an address is 20 bytes long
require(extraData.length >= bytesOffset + 20);
// + 20 bytes for address, - 32 bytes for the length offset
require(extraData.length >= bytesOffset - 12);
assembly {
// it loads a full 32 bytes, shift right 96 bits so only the address remains
filler := shr(96, mload(add(extraData, bytesOffset)))
Expand All @@ -132,8 +132,8 @@ library CosignerExtraDataLib {
}

if (hasInputOverride(extraData)) {
// a uint256 is 32 bytes long, so we just load the next 32 bytes
require(extraData.length >= bytesOffset + 32);
// + 32 bytes for uint256, - 32 bytes for the length offset
require(extraData.length >= bytesOffset);
assembly {
inputOverride := mload(add(extraData, bytesOffset))
}
Expand All @@ -148,7 +148,7 @@ library CosignerExtraDataLib {
}
bytesOffset += 32;

// each element of the array is 32 bytes
// each element of the array is 32 bytes, - 32 bytes for the length offset
require(extraData.length == bytesOffset + (length - 1) * 32);
outputOverrides = new uint256[](length);

Expand Down
3 changes: 2 additions & 1 deletion test/reactors/V2DutchOrderReactor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ contract V2DutchOrderTest is PermitSignature, DeployPermit2, BaseDutchOrderReact
}

function testEncoding() public {
bytes memory encodedBytes = encodeExtraCosignerData(address(1111111111111111), 22222222222222, ArrayBuilder.fill(3, 5));
bytes memory encodedBytes =
encodeExtraCosignerData(address(1111111111111111), 22222222222222, ArrayBuilder.fill(3, 5));
assertTrue(encodedBytes.hasExclusiveFiller());
assertTrue(encodedBytes.hasInputOverride());
assertTrue(encodedBytes.hasOutputOverrides());
Expand Down

0 comments on commit 1a475e2

Please sign in to comment.