Skip to content

Commit

Permalink
TD-1326: chore: fix _validateSubstandard4 logic and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen-imtb committed Apr 3, 2024
1 parent ce47a09 commit e5390f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/trading/seaport/zones/ImmutableSignedZoneV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ contract ImmutableSignedZoneV2 is
}

uint256 expectedOrderHashesSize = uint256(bytes32(context[33:65]));
uint256 substandardIndexEnd = 65 + (expectedOrderHashesSize * 32);
uint256 substandardIndexEnd = 64 + (expectedOrderHashesSize * 32);
bytes32[] memory expectedOrderHashes = abi.decode(context[1:substandardIndexEnd + 1], (bytes32[]));

// revert if any order hashes in substandard data are not present in zoneParameters.orderHashes
Expand Down
28 changes: 28 additions & 0 deletions test/trading/seaport/zones/ImmutableSignedZoneV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,34 @@ contract ImmutableSignedZoneV2Test is Test {
zone.exposed_validateSubstandard4(context, zoneParameters);
}

function test_validateSubstandard4_returnsLengthOfSubstandardSegmentOnSuccess() public {
ImmutableSignedZoneV2Harness zone = new ImmutableSignedZoneV2Harness(
"MyZoneName",
"https://www.immutable.com",
"https://www.immutable.com/docs",
address(0x2)
);
bytes32[] memory orderHashes = new bytes32[](1);
orderHashes[0] = bytes32(0x43592598d0419e49d268e9b553427fd7ba1dd091eaa3f6127161e44afb7b40f9);
ZoneParameters memory zoneParameters = ZoneParameters({
orderHash: bytes32(0),
fulfiller: address(0x2),
offerer: address(0x3),
offer: new SpentItem[](0),
consideration: new ReceivedItem[](0),
extraData: new bytes(0),
orderHashes: orderHashes,
startTime: 0,
endTime: 0,
zoneHash: bytes32(0)
});

bytes memory context = abi.encodePacked(bytes1(0x04), bytes32(uint256(32)), bytes32(uint256(1)), bytes32(0x43592598d0419e49d268e9b553427fd7ba1dd091eaa3f6127161e44afb7b40f9));
uint256 substandardLengthResult = zone.exposed_validateSubstandard4(context, zoneParameters);
// bytes1 + bytes32 + bytes32 + bytes32 = 97
assertEq(substandardLengthResult, 97);
}

/* _validateSubstandard6 - N */

/* _deriveReceivedItemsHash - N */
Expand Down

0 comments on commit e5390f9

Please sign in to comment.