diff --git a/test/AuctionHouse/sendPayout.t.sol b/test/AuctionHouse/sendPayout.t.sol index 9a945b6b..e67c8a90 100644 --- a/test/AuctionHouse/sendPayout.t.sol +++ b/test/AuctionHouse/sendPayout.t.sol @@ -244,9 +244,9 @@ contract SendPayoutTest is Test, Permit2User { // ========== Derivative flow ========== // // [ ] given the base token is a derivative - // [ ] given a condenser is set - // [ ] given the derivative parameters are invalid - // [ ] it reverts + // [X] given a condenser is set + // [X] given the derivative parameters are invalid + // [X] it reverts // [X] it uses the condenser to determine derivative parameters // [ ] given a condenser is not set // [ ] given the derivative is wrapped @@ -294,7 +294,7 @@ contract SendPayoutTest is Test, Permit2User { } modifier givenDerivativeParamsAreInvalid() { - derivativeParams = abi.encode(0); + derivativeParams = abi.encode("one", "two", uint256(2)); routingParams.derivativeParams = derivativeParams; _; } @@ -352,6 +352,20 @@ contract SendPayoutTest is Test, Permit2User { ); } + function test_derivative_condenser_invalidParams_reverts() + public + givenAuctionHasDerivative + givenDerivativeHasCondenser + givenDerivativeParamsAreInvalid + { + // Expect revert while decoding parameters + vm.expectRevert(); + + // Call + vm.prank(USER); + auctionHouse.sendPayout(lotId, RECIPIENT, payoutAmount, routingParams, auctionOutput); + } + function test_derivative_condenser() public givenAuctionHasDerivative diff --git a/test/modules/Condenser/MockCondenserModule.sol b/test/modules/Condenser/MockCondenserModule.sol index 1afd34ca..90711d29 100644 --- a/test/modules/Condenser/MockCondenserModule.sol +++ b/test/modules/Condenser/MockCondenserModule.sol @@ -30,10 +30,12 @@ contract MockCondenserModule is CondenserModule { abi.decode(auctionOutput_, (MockAtomicAuctionModule.Output)); // Get derivative params - (uint256 derivativeTokenId) = abi.decode(derivativeConfig_, (uint256)); + if (derivativeConfig_.length != 64) revert(""); + MockDerivativeModule.Params memory originalDerivativeParams = + abi.decode(derivativeConfig_, (MockDerivativeModule.Params)); MockDerivativeModule.Params memory derivativeParams = MockDerivativeModule.Params({ - tokenId: derivativeTokenId, + tokenId: originalDerivativeParams.tokenId, multiplier: auctionOutput.multiplier }); diff --git a/test/modules/Derivative/MockDerivativeModule.sol b/test/modules/Derivative/MockDerivativeModule.sol index b31aa58f..711f5c30 100644 --- a/test/modules/Derivative/MockDerivativeModule.sol +++ b/test/modules/Derivative/MockDerivativeModule.sol @@ -9,6 +9,8 @@ import {DerivativeModule} from "src/modules/Derivative.sol"; import {MockERC6909} from "solmate/test/utils/mocks/MockERC6909.sol"; +import {console2} from "forge-std/console2.sol"; + contract MockDerivativeModule is DerivativeModule { bool internal validateFails; MockERC6909 internal derivativeToken; @@ -41,6 +43,8 @@ contract MockDerivativeModule is DerivativeModule { uint256 amount_, bool wrapped_ ) external virtual override returns (uint256, address, uint256) { + if (params_.length != 64) revert(""); + // TODO wrapping Params memory params = abi.decode(params_, (Params));