diff --git a/src/main/test/HashValidationZoneOfferer.sol b/src/main/test/HashValidationZoneOfferer.sol index 61ff8d7..279ae64 100644 --- a/src/main/test/HashValidationZoneOfferer.sol +++ b/src/main/test/HashValidationZoneOfferer.sol @@ -58,6 +58,7 @@ contract HashValidationZoneOfferer is error IncorrectSeaportBalance( uint256 expectedBalance, uint256 actualBalance ); + error HashValidationZoneOffererAuthorizeOrderReverts(); error HashValidationZoneOffererValidateOrderReverts(); error HashValidationZoneOffererRatifyOrderReverts(); @@ -219,18 +220,26 @@ contract HashValidationZoneOfferer is bool public called = false; uint256 public callCount = 0; - mapping(bytes32 => OffererZoneFailureReason) public failureReasons; + mapping(bytes32 => OffererZoneFailureReason) public authorizeFailureReasons; + mapping(bytes32 => OffererZoneFailureReason) public validateFailureReasons; - function setFailureReason( + function setAuthorizeFailureReason( bytes32 orderHash, OffererZoneFailureReason newFailureReason ) external { - failureReasons[orderHash] = newFailureReason; + authorizeFailureReasons[orderHash] = newFailureReason; + } + + function setValidateFailureReason( + bytes32 orderHash, + OffererZoneFailureReason newFailureReason + ) external { + validateFailureReasons[orderHash] = newFailureReason; } function authorizeOrder(ZoneParameters calldata zoneParameters) public - returns (bytes4) + returns (bytes4 authorizeOrderReturnValue) { // Get the orderHash from zoneParameters bytes32 orderHash = zoneParameters.orderHash; @@ -258,7 +267,17 @@ contract HashValidationZoneOfferer is // Emit a DataHash event with the hash of msg.data emit AuthorizeOrderDataHash(calldataHash); - return this.authorizeOrder.selector; + if ( + authorizeFailureReasons[orderHash] + == OffererZoneFailureReason.Zone_authorizeInvalidMagicValue + ) { + authorizeOrderReturnValue = bytes4(0x12345678); + } else { + // Return the selector of authorizeOrder as the magic value. + authorizeOrderReturnValue = this.authorizeOrder.selector; + } + + return authorizeOrderReturnValue; } /** @@ -277,7 +296,7 @@ contract HashValidationZoneOfferer is // Get the orderHash from zoneParameters bytes32 orderHash = zoneParameters.orderHash; - if (failureReasons[orderHash] == OffererZoneFailureReason.Zone_reverts) + if (validateFailureReasons[orderHash] == OffererZoneFailureReason.Zone_reverts) { revert HashValidationZoneOffererValidateOrderReverts(); } @@ -323,8 +342,8 @@ contract HashValidationZoneOfferer is callCount++; if ( - failureReasons[orderHash] - == OffererZoneFailureReason.Zone_InvalidMagicValue + validateFailureReasons[orderHash] + == OffererZoneFailureReason.Zone_validateInvalidMagicValue ) { validOrderMagicValue = bytes4(0x12345678); } else { diff --git a/src/main/test/OffererZoneFailureReason.sol b/src/main/test/OffererZoneFailureReason.sol index c4ce07d..9a6484a 100644 --- a/src/main/test/OffererZoneFailureReason.sol +++ b/src/main/test/OffererZoneFailureReason.sol @@ -12,5 +12,6 @@ enum OffererZoneFailureReason { ContractOfferer_IncorrectMaximumSpent, // incorrect (too many, wrong token, etc.) maximum spent items ContractOfferer_InvalidMagicValue, // Offerer did not return correct magic value Zone_reverts, // Zone validateOrder call reverts - Zone_InvalidMagicValue // Zone validateOrder call returns invalid magic value + Zone_authorizeInvalidMagicValue, // Zone authorizeOrder call returns invalid magic value + Zone_validateInvalidMagicValue // Zone validateOrder call returns invalid magic value } diff --git a/test/foundry/new/helpers/FuzzMutationSelectorLib.sol b/test/foundry/new/helpers/FuzzMutationSelectorLib.sol index 632361a..e34c9b2 100644 --- a/test/foundry/new/helpers/FuzzMutationSelectorLib.sol +++ b/test/foundry/new/helpers/FuzzMutationSelectorLib.sol @@ -103,8 +103,9 @@ enum Failure { InvalidContractOrder_ExcessMaximumSpent, // too many maximum spent items InvalidContractOrder_IncorrectMaximumSpent, // incorrect (too many, wrong token, etc.) maximum spent items InvalidContractOrder_InvalidMagicValue, // Offerer did not return correct magic value - InvalidRestrictedOrder_reverts, // Zone validateOrder call reverts - InvalidRestrictedOrder_InvalidMagicValue, // Zone validateOrder call returns invalid magic value + InvalidRestrictedOrder_validateReverts, // Zone validateOrder call reverts + InvalidRestrictedOrder_authorizeInvalidMagicValue, // Zone authorizeOrder call returns invalid magic value + InvalidRestrictedOrder_validateInvalidMagicValue, // Zone validateOrder call returns invalid magic value NoContract, // Trying to transfer a token at an address that has no contract UnusedItemParameters_Token, // Native item with non-zero token UnusedItemParameters_Identifier, // Native or ERC20 item with non-zero identifier @@ -346,8 +347,9 @@ library FuzzMutationSelectorLib { .ineligibleWhenNotActiveTimeOrNotContractOrderOrNoConsideration ); - failuresAndFilters[i++] = Failure.InvalidRestrictedOrder_reverts.and( - Failure.InvalidRestrictedOrder_InvalidMagicValue + failuresAndFilters[i++] = Failure.InvalidRestrictedOrder_authorizeInvalidMagicValue.and( + Failure.InvalidRestrictedOrder_validateReverts) + .and(Failure.InvalidRestrictedOrder_validateInvalidMagicValue ).withOrder( MutationFilters.ineligibleWhenNotAvailableOrNotRestrictedOrder ); @@ -873,7 +875,7 @@ library FailureDetailsLib { .HashValidationZoneOffererValidateOrderReverts .selector .withOrder( - "InvalidRestrictedOrder_reverts", + "InvalidRestrictedOrder_validateReverts", FuzzMutations.mutation_invalidRestrictedOrderReverts.selector ); @@ -881,12 +883,24 @@ library FailureDetailsLib { .InvalidRestrictedOrder .selector .withOrder( - "InvalidRestrictedOrder_InvalidMagicValue", + "InvalidRestrictedOrder_authorizeInvalidMagicValue", FuzzMutations - .mutation_invalidRestrictedOrderInvalidMagicValue + .mutation_invalidRestrictedOrderAuthorizeInvalidMagicValue .selector, details_withOrderHash ); + + failureDetailsArray[i++] = ZoneInteractionErrors + .InvalidRestrictedOrder + .selector + .withOrder( + "InvalidRestrictedOrder_validateInvalidMagicValue", + FuzzMutations + .mutation_invalidRestrictedOrderValidateInvalidMagicValue + .selector, + details_withOrderHash + ); + failureDetailsArray[i++] = TokenTransferrerErrors .NoContract .selector diff --git a/test/foundry/new/helpers/FuzzMutations.sol b/test/foundry/new/helpers/FuzzMutations.sol index cb1aacf..1592eb2 100644 --- a/test/foundry/new/helpers/FuzzMutations.sol +++ b/test/foundry/new/helpers/FuzzMutations.sol @@ -1939,14 +1939,14 @@ contract FuzzMutations is Test, FuzzExecutor { bytes32 orderHash = mutationState.selectedOrderHash; // This mutation triggers a revert by setting a failure reason that gets - // stored in the HashCalldataContractOfferer. + // stored in the HashValidationZoneOfferer. HashValidationZoneOfferer(payable(order.parameters.zone)) - .setFailureReason(orderHash, OffererZoneFailureReason.Zone_reverts); + .setValidateFailureReason(orderHash, OffererZoneFailureReason.Zone_reverts); exec(context); } - function mutation_invalidRestrictedOrderInvalidMagicValue( + function mutation_invalidRestrictedOrderAuthorizeInvalidMagicValue( FuzzTestContext memory context, MutationState memory mutationState ) external { @@ -1954,10 +1954,27 @@ contract FuzzMutations is Test, FuzzExecutor { bytes32 orderHash = mutationState.selectedOrderHash; // This mutation triggers a revert by setting a failure reason that gets - // stored in the HashCalldataContractOfferer. + // stored in the HashValidationZone. HashValidationZoneOfferer(payable(order.parameters.zone)) - .setFailureReason( - orderHash, OffererZoneFailureReason.Zone_InvalidMagicValue + .setAuthorizeFailureReason( + orderHash, OffererZoneFailureReason.Zone_authorizeInvalidMagicValue + ); + + exec(context); + } + + function mutation_invalidRestrictedOrderValidateInvalidMagicValue( + FuzzTestContext memory context, + MutationState memory mutationState + ) external { + AdvancedOrder memory order = mutationState.selectedOrder; + bytes32 orderHash = mutationState.selectedOrderHash; + + // This mutation triggers a revert by setting a failure reason that gets + // stored in the HashValidationZone. + HashValidationZoneOfferer(payable(order.parameters.zone)) + .setValidateFailureReason( + orderHash, OffererZoneFailureReason.Zone_validateInvalidMagicValue ); exec(context);