Skip to content

Commit

Permalink
Test TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJem committed Sep 25, 2024
1 parent 131581e commit b471433
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 16 deletions.
20 changes: 19 additions & 1 deletion test/modules/auctions/GDA/auction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: capacity within bounds

function test_minPriceGreaterThanDecayTargetPrice_reverts()
public
givenMinPrice(4e18)
Expand Down Expand Up @@ -176,7 +178,9 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

function test_minPriceGreaterThanMin_reverts()
// TODO: min price within bounds of decay target

function test_minPriceGreaterThanMax_reverts()
public
givenDecayTarget(20e16) // 20% decay from 5e18 is 4e18
givenMinPrice(35e17 + 1) // 30% decrease (10% more than decay) from 5e18 is 3.5e18, we go slightly higher
Expand All @@ -190,6 +194,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: min price within bounds of equilibrium price

function test_decayTargetLessThanMinimum_reverts()
public
givenDecayTarget(1e16 - 1) // slightly less than 1%
Expand All @@ -216,6 +222,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: decay target within bounds

function test_decayPeriodLessThanMinimum_reverts()
public
givenDecayPeriod(uint48(6 hours) - 1)
Expand All @@ -242,6 +250,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: decay period within bounds

function testFuzz_minPriceNonZero_durationGreaterThanLimit_reverts(
uint8 decayTarget_,
uint8 decayHours_
Expand Down Expand Up @@ -287,6 +297,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: min price zero, duration greater than log

function testFuzz_minPriceNonZero_durationEqualToLimit_succeeds(
uint8 decayTarget_,
uint8 decayHours_
Expand Down Expand Up @@ -372,6 +384,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: min price not zero, duration greater than exponent

function testFuzz_minPriceZero_durationEqualToLimit_succeeds(
uint8 decayTarget_,
uint8 decayHours_
Expand Down Expand Up @@ -431,6 +445,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: min price not zero, eq price times emissions zero

function test_minPriceNonZero_MinPriceTimesEmissionsZero_reverts()
public
givenMinPrice(1e9) // Smallest value for min price is 10^(quoteDecimals / 2)
Expand All @@ -451,6 +467,8 @@ contract GdaCreateAuctionTest is GdaTest {
_createAuctionLot();
}

// TODO: min price zero, min price times emissions zero

function _assertAuctionData() internal {
// Calculate the decay constant from the input parameters
uint256 quoteTokenScale = 10 ** _quoteTokenDecimals;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/auctions/GDA/cancelAuction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract GdaCancelAuctionTest is GdaTest {
// [X] when the auction has been cancelled
// [X] it reverts
// [X] when the auction has started
// [X] it reverts
// [X] it updates the conclusion, capacity and status
// [X] it updates the conclusion, capacity and status

function test_notParent_reverts() public {
Expand Down
31 changes: 21 additions & 10 deletions test/modules/auctions/GDA/maxAmountAccepted.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
using {PRBMath.mulDiv} for uint256;
// [X] when the lot ID is invalid
// [X] it reverts
// [X] it returns the price for the remaining capacity of the lot
// [X] given the minimum price is not zero
// [X] given the quote token decimals are smaller than the base token decimals
// [X] it correctly handles the scaling
// [X] given the quote token decimals are larger than the base token decimals
// [X] it correctly handles the scaling
// [X] it returns the price for the remaining capacity of the lot
// [X] given the minimum price is zero
// [X] given the quote token decimals are smaller than the base token decimals
// [X] it correctly handles the scaling
// [X] given the quote token decimals are larger than the base token decimals
// [X] it correctly handles the scaling
// [X] it returns the price for the remaining capacity of the lot

function testFuzz_lotIdInvalid_reverts(
uint96 lotId_
Expand All @@ -23,7 +34,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
_module.maxAmountAccepted(lotId_);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_success(
function testFuzz_minPriceNonZero_success(
uint128 capacity_,
uint128 price_
)
Expand All @@ -42,7 +53,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_success_smallerQuoteDecimals(
function testFuzz_minPriceNonZero_success_smallerQuoteDecimals(
uint128 capacity_,
uint128 price_
)
Expand All @@ -62,7 +73,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_success_smallerBaseDecimals(
function testFuzz_minPriceNonZero_success_smallerBaseDecimals(
uint128 capacity_,
uint128 price_
)
Expand All @@ -82,7 +93,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_success_bothSmallerDecimals(
function testFuzz_minPriceNonZero_success_bothSmallerDecimals(
uint96 capacity_,
uint96 price_
)
Expand All @@ -103,7 +114,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceZero_success(
function testFuzz_minPriceZero_success(
uint128 capacity_,
uint128 price_
)
Expand All @@ -122,7 +133,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_quoteDecimalsSmaller_success(
function testFuzz_minPriceNonZero_quoteDecimalsSmaller_success(
uint128 capacity_,
uint128 price_
)
Expand All @@ -142,7 +153,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceZero_quoteDecimalsSmaller_success(
function testFuzz_minPriceZero_quoteDecimalsSmaller_success(
uint128 capacity_,
uint128 price_
)
Expand All @@ -162,7 +173,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceNonZero_quoteDecimalsLarger_success(
function testFuzz_minPriceNonZero_quoteDecimalsLarger_success(
uint128 capacity_,
uint128 price_
)
Expand All @@ -182,7 +193,7 @@ contract GdaMaxAmountAcceptedTest is GdaTest {
assertEq(expectedAmount, maxAmountAccepted);
}

function testFuzz_maxAmountAccepted_minPriceZero_quoteDecimalsLarger_success(
function testFuzz_minPriceZero_quoteDecimalsLarger_success(
uint128 capacity_,
uint128 price_
)
Expand Down
9 changes: 6 additions & 3 deletions test/modules/auctions/GDA/maxPayout.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ contract GdaMaxPayoutTest is GdaTest {
using {PRBMath.mulDiv} for uint256;
// [X] when the lot ID is invalid
// [X] it reverts
// [X] it returns the remaining capacity of the lot
// [X] given the minimum price is zero
// [X] it returns the remaining capacity of the lot
// [X] given the minimum price is not zero
// [X] it returns the remaining capacity of the lot

function testFuzz_lotIdInvalid_reverts(
uint96 lotId_
Expand All @@ -22,15 +25,15 @@ contract GdaMaxPayoutTest is GdaTest {
_module.maxPayout(lotId_);
}

function testFuzz_maxPayout_success(
function testFuzz_minPriceNotZero_success(
uint128 capacity_
) public givenLotCapacity(capacity_) validateCapacity givenLotIsCreated {
uint256 maxPayout = _module.maxPayout(_lotId);
uint256 expectedMaxPayout = capacity_;
assertEq(expectedMaxPayout, maxPayout);
}

function testFuzz_maxPayout_minPriceZero_success(
function testFuzz_minPriceZero_success(
uint128 capacity_
) public givenLotCapacity(capacity_) validateCapacity givenMinPrice(0) givenLotIsCreated {
uint256 maxPayout = _module.maxPayout(_lotId);
Expand Down
1 change: 0 additions & 1 deletion test/modules/auctions/GDA/payoutFor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ contract GdaPayoutForTest is GdaTest {
// [X] it returns zero
// [X] when large, reasonable values are used
// [X] it does not overflow
// TODO can we fuzz this better?

function testFuzz_lotIdInvalid_reverts(
uint96 lotId_
Expand Down
3 changes: 3 additions & 0 deletions test/modules/auctions/GDA/priceFor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ contract GdaPriceForTest is GdaTest {
// TODO can we fuzz this better? maybe use some external calculations to compare the values?
// Otherwise, we're just recreating the same calculations here and not really validating anything

// TODO: handles quote token decimals greater than base token decimals
// TODO: handles quote token decimals less than base token decimals

function testFuzz_lotIdInvalid_reverts(
uint96 lotId_
) public {
Expand Down

0 comments on commit b471433

Please sign in to comment.