Skip to content

Commit

Permalink
wip on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Nov 22, 2023
1 parent 3b1a331 commit b73aa67
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/concrete/OrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ contract OrderBook is IOrderBookV3, ReentrancyGuard, Multicall, OrderBookV3Flash
.interpreter
.eval2(order.evaluable.store, LibNamespace.qualifyNamespace(namespace, address(this)), _calculateOrderDispatch(order.evaluable.expression), context, new uint256[](0));

Output18Amount orderOutputMax18 = Output18Amount.wrap(calculateOrderStack[calculateOrderStack.length - 2]);
uint256 orderIORatio = calculateOrderStack[calculateOrderStack.length - 1];
Output18Amount orderOutputMax18 = Output18Amount.wrap(calculateOrderStack[1]);
uint256 orderIORatio = calculateOrderStack[0];

{
// The order owner can't send more than the smaller of their vault
Expand Down
10 changes: 5 additions & 5 deletions test/concrete/OrderBook.addOrder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract OrderBookAddOrderTest is OrderBookExternalRealTest {
/// No handle IO reverts.
function testAddOrderRealNoHandleIOReverts(address owner, OrderConfigV2 memory config) public {
LibTestAddOrder.conformConfig(config, iDeployer);
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iDeployer)).parse(":;");
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iParser)).parse(":;");
config.evaluableConfig.bytecode = bytecode;
config.evaluableConfig.constants = constants;
vm.expectRevert(abi.encodeWithSelector(OrderNoHandleIO.selector, owner));
Expand All @@ -32,7 +32,7 @@ contract OrderBookAddOrderTest is OrderBookExternalRealTest {
// /// A stack of 0 for calculate order reverts.
// function testAddOrderRealZeroStackCalculateReverts(address owner, OrderConfigV2 memory config) public {
// LibTestAddOrder.conformConfig(config, iDeployer);
// (bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iDeployer)).parse(":;:;");
// (bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iParser)).parse(":;:;");
// config.evaluableConfig.constants = constants;
// config.evaluableConfig.bytecode = bytecode;
// vm.expectRevert(abi.encodeWithSelector(EntrypointMinOutputs.selector, 0, 0, 2));
Expand All @@ -44,7 +44,7 @@ contract OrderBookAddOrderTest is OrderBookExternalRealTest {
// function testAddOrderRealOneStackCalculateReverts(address owner, OrderConfigV2 memory config) public {
// LibTestAddOrder.conformConfig(config, iDeployer);
// (bytes memory bytecode, uint256[] memory constants) =
// IParserV1(address(iDeployer)).parse("_:block-timestamp();:;");
// IParserV1(address(iParser)).parse("_:block-timestamp();:;");
// config.evaluableConfig.constants = constants;
// config.evaluableConfig.bytecode = bytecode;
// vm.expectRevert(abi.encodeWithSelector(EntrypointMinOutputs.selector, 0, 1, 2));
Expand All @@ -56,7 +56,7 @@ contract OrderBookAddOrderTest is OrderBookExternalRealTest {
function testAddOrderRealTwoStackCalculateReverts(address owner, OrderConfigV2 memory config) public {
LibTestAddOrder.conformConfig(config, iDeployer);
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse("_ _:block-timestamp() chain-id();:;");
IParserV1(address(iParser)).parse("_ _:block-timestamp() chain-id();:;");
config.evaluableConfig.constants = constants;
config.evaluableConfig.bytecode = bytecode;
vm.prank(owner);
Expand All @@ -67,7 +67,7 @@ contract OrderBookAddOrderTest is OrderBookExternalRealTest {
function testAddOrderRealThreeStackCalculate(address owner, OrderConfigV2 memory config) public {
LibTestAddOrder.conformConfig(config, iDeployer);
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse("_ _ _:block-timestamp() chain-id() block-number();:;");
IParserV1(address(iParser)).parse("_ _ _:block-timestamp() chain-id() block-number();:;");
config.evaluableConfig.constants = constants;
config.evaluableConfig.bytecode = bytecode;
vm.prank(owner);
Expand Down
2 changes: 1 addition & 1 deletion test/concrete/OrderBook.clear.handleIO.revert.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract OrderBookClearHandleIORevertTest is OrderBookExternalRealTest {
iOrderbook.deposit(outputToken, vaultId, type(uint256).max);
assertEq(iOrderbook.vaultBalance(owner, outputToken, vaultId), type(uint256).max);

(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iDeployer)).parse(rainString);
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iParser)).parse(rainString);
EvaluableConfigV3 memory evaluableConfig = EvaluableConfigV3(iDeployer, bytecode, constants);
config = OrderConfigV2(validInputs, validOutputs, evaluableConfig, "");

Expand Down
2 changes: 1 addition & 1 deletion test/concrete/OrderBook.takeOrder.handleIO.revert.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract OrderBookTakeOrderHandleIORevertTest is OrderBookExternalRealTest {
TakeOrderConfigV2[] memory orders = new TakeOrderConfigV2[](configs.length);

for (uint256 i = 0; i < configs.length; i++) {
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iDeployer)).parse(configs[i]);
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iParser)).parse(configs[i]);
EvaluableConfigV3 memory evaluableConfig = EvaluableConfigV3(iDeployer, bytecode, constants);
config = OrderConfigV2(validInputs, validOutputs, evaluableConfig, "");

Expand Down
2 changes: 1 addition & 1 deletion test/concrete/OrderBook.takeOrder.maximumInput.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract OrderBookTakeOrderMaximumInputTest is OrderBookExternalRealTest {
OrderConfigV2 memory orderConfig;
{
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse(testOrders[i].orderString);
IParserV1(address(iParser)).parse(testOrders[i].orderString);
IO[] memory inputs = new IO[](1);
inputs[0] = IO(address(iToken0), 18, vaultId);
IO[] memory outputs = new IO[](1);
Expand Down
2 changes: 1 addition & 1 deletion test/concrete/OrderBook.takeOrder.precision.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract OrderBookTakeOrderPrecisionTest is OrderBookExternalRealTest {
validOutputs[0] = IO(outputToken, outputTokenDecimals, vaultId);
// These numbers are known to cause large rounding errors if the
// precision is not handled correctly.
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iDeployer)).parse(rainString);
(bytes memory bytecode, uint256[] memory constants) = IParserV1(address(iParser)).parse(rainString);
EvaluableConfigV3 memory evaluableConfig = EvaluableConfigV3(iDeployer, bytecode, constants);
config = OrderConfigV2(validInputs, validOutputs, evaluableConfig, "");
// Etch with invalid.
Expand Down
8 changes: 4 additions & 4 deletions test/concrete/OrderBookV3FlashLender.reentrant.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ contract OrderBookV3FlashLenderReentrant is OrderBookExternalRealTest {
function testReenterAddOrder(uint256 loanAmount, OrderConfigV2 memory config) external {
LibTestAddOrder.conformConfig(config, iDeployer);
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse("_ _:max-int-value() 1e18;:;");
IParserV1(address(iParser)).parse("_ _:max-int-value() 1e18;:;");
config.evaluableConfig.bytecode = bytecode;
config.evaluableConfig.constants = constants;
// Create a flash borrower.
Expand All @@ -122,7 +122,7 @@ contract OrderBookV3FlashLenderReentrant is OrderBookExternalRealTest {
function testReenterTakeOrder(uint256 loanAmount, OrderConfigV2 memory config) external {
LibTestAddOrder.conformConfig(config, iDeployer);
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse("_ _:max-int-value() 1e18;:;");
IParserV1(address(iParser)).parse("_ _:max-int-value() 1e18;:;");
config.evaluableConfig.bytecode = bytecode;
config.evaluableConfig.constants = constants;

Expand Down Expand Up @@ -155,12 +155,12 @@ contract OrderBookV3FlashLenderReentrant is OrderBookExternalRealTest {

LibTestAddOrder.conformConfig(aliceConfig, iDeployer);
(bytes memory bytecode, uint256[] memory constants) =
IParserV1(address(iDeployer)).parse("_ _:max-int-value() 1e18;:;");
IParserV1(address(iParser)).parse("_ _:max-int-value() 1e18;:;");
aliceConfig.evaluableConfig.bytecode = bytecode;
aliceConfig.evaluableConfig.constants = constants;

LibTestAddOrder.conformConfig(bobConfig, iDeployer);
(bytecode, constants) = IParserV1(address(iDeployer)).parse("_ _:max-int-value() 1e18;:;");
(bytecode, constants) = IParserV1(address(iParser)).parse("_ _:max-int-value() 1e18;:;");
bobConfig.evaluableConfig.bytecode = bytecode;
bobConfig.evaluableConfig.constants = constants;

Expand Down
4 changes: 1 addition & 3 deletions test/util/abstract/ArbTest.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: CAL
pragma solidity =0.8.19;

import "forge-std/Test.sol";
import {Test, console2} from "forge-std/Test.sol";
import "openzeppelin-contracts/contracts/proxy/Clones.sol";

import "test/util/lib/LibTestConstants.sol";
Expand Down Expand Up @@ -35,7 +35,6 @@ abstract contract ArbTest is Test {
address iArb;

constructor(ArbTestConstructorConfig memory config) {
console2.log("constructor");
iDeployer = config.deployer;
iImplementation = config.implementation;
iArb = Clones.clone(iImplementation);
Expand All @@ -49,7 +48,6 @@ abstract contract ArbTest is Test {
internal
returns (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config)
{
console2.log("bcc");
deployer = address(uint160(uint256(keccak256("deployer.rain.test"))));
// All non-mocked calls will revert.
vm.etch(deployer, REVERTING_MOCK_BYTECODE);
Expand Down

0 comments on commit b73aa67

Please sign in to comment.