Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Dec 24, 2024
1 parent 3833fb9 commit df68c21
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions test/concrete/ob/OrderBook.clear.mock.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {LibNamespace} from "rain.interpreter.interface/lib/ns/LibNamespace.sol";
import {StateNamespace} from "rain.interpreter.interface/interface/IInterpreterV3.sol";
import {LibFixedPointDecimalArithmeticOpenZeppelin} from
"rain.math.fixedpoint/lib/LibFixedPointDecimalArithmeticOpenZeppelin.sol";
import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol";
import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol";

/// @title OrderBookClearTest
/// Tests clearing an order.
Expand Down Expand Up @@ -87,8 +87,6 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
uint256 expectedBobOutput;
uint256 expectedAliceInput;
uint256 expectedBobInput;
uint256 expectedAliceBounty;
uint256 expectedBobBounty;
}

function doClear(DoClear memory clear) internal {
Expand Down Expand Up @@ -206,14 +204,14 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
iOrderbook.vaultBalance(
clear.bob, clear.bobConfig.validInputs[0].token, clear.bobConfig.validInputs[0].vaultId
),
clear.expectedAliceOutput,
clear.expectedBobInput,
// clear.expectedBobOutput.fixedPointMul(clear.orderStackBob[0], Math.Rounding.Up),
"Bob input vault"
);

assertEq(
iOrderbook.vaultBalance(clear.bountyBot, clear.aliceConfig.validOutputs[0].token, clear.aliceBountyVaultId),
0,
clear.expectedAliceOutput - clear.expectedBobInput,
"Alice bounty"
);
assertEq(
Expand All @@ -223,7 +221,7 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
);
assertEq(
iOrderbook.vaultBalance(clear.bountyBot, clear.bobConfig.validOutputs[0].token, clear.bobBountyVaultId),
clear.expectedBobOutput - clear.expectedAliceOutput.fixedPointMul(clear.orderStackAlice[0], Math.Rounding.Up),
clear.expectedBobOutput - clear.expectedAliceInput,
"Bob bounty"
);
assertEq(
Expand Down Expand Up @@ -270,9 +268,7 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
0.5e18,
0.5e18,
0.495e18,
0.495e18,
0.005e18,
0.005e18
0.495e18
)
);
}
Expand Down Expand Up @@ -325,15 +321,16 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
// Alice is outputting 1 so bob will output enough to match this
// according to his own IO ratio.
uint256(1e18).fixedPointDiv(bobIORatio, Math.Rounding.Down).min(1e18),
// Expected input for Alice is aliceOutput * aliceIORatio
uint256(1e18).fixedPointMul(aliceIORatio, Math.Rounding.Up),
uint256(1e18).fixedPointMul(bobIORatio, Math.Rounding.Up),
5e17,
4e17
// Expected output for Bob is bob's output * bobIORatio
uint256(1e18).fixedPointDiv(bobIORatio, Math.Rounding.Down).min(1e18).fixedPointMul(
bobIORatio, Math.Rounding.Up
)
)
);
}


/// forge-config: default.fuzz.runs = 100
function testClear2ZeroRatioAliceOnly(
address alice,
Expand Down Expand Up @@ -373,8 +370,6 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
0.5e18,
0.5e18,
0,
0.5e18,
0,
0.5e18
)
);
Expand Down Expand Up @@ -419,8 +414,6 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
0.5e18,
0.5e18,
0.5e18,
0,
0.5e18,
0
)
);
Expand Down Expand Up @@ -467,9 +460,7 @@ contract OrderBookClearTest is OrderBookExternalMockTest {
0.5e18,
0.5e18,
0,
0,
0.5e18,
0.5e18
0
)
);
}
Expand Down

0 comments on commit df68c21

Please sign in to comment.