Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Nov 22, 2023
1 parent 006881b commit 13e7e6b
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 103 deletions.
142 changes: 70 additions & 72 deletions .gas-snapshot

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion script/DeployGenericPoolOrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
pragma solidity =0.8.19;

import {Script, console2} from "forge-std/Script.sol";
import {GenericPoolOrderBookV3FlashBorrower, DeployerDiscoverableMetaV3ConstructionConfig} from "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol";
import {
GenericPoolOrderBookV3FlashBorrower,
DeployerDiscoverableMetaV3ConstructionConfig
} from "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol";

/// @title DeployGenericPoolOrderBookV3FlashBorrower
/// @notice A script that deploys a `GenericPoolOrderBookV3FlashBorrower`. This
Expand Down
4 changes: 3 additions & 1 deletion src/abstract/OrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {ON_FLASH_LOAN_CALLBACK_SUCCESS} from "../interface/ierc3156/IERC3156Flas
import {IOrderBookV3, TakeOrdersConfigV2, NoOrders} from "../interface/unstable/IOrderBookV3.sol";
import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/ICloneableV2.sol";
import {
IInterpreterV2, SourceIndexV2, DEFAULT_STATE_NAMESPACE
IInterpreterV2,
SourceIndexV2,
DEFAULT_STATE_NAMESPACE
} from "rain.interpreter/src/interface/unstable/IInterpreterV2.sol";
import {IERC3156FlashBorrower} from "../interface/ierc3156/IERC3156FlashBorrower.sol";
import {IInterpreterStoreV1} from "rain.interpreter/src/interface/IInterpreterStoreV1.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/concrete/GenericPoolOrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "src/abstract/OrderBookV3FlashBorrower.sol";
/// @dev Metadata hash for `DeployerDiscoverableMetaV1`.
/// - ABI for GenericPoolOrderBookV3FlashBorrower
/// - Interpreter caller metadata V1 for GenericPoolOrderBookV3FlashBorrower
bytes32 constant CALLER_META_HASH = bytes32(0xc527f81e4dac946943b3ffe7a99d82535b44a79eb92692159566eea43659365e);
bytes32 constant CALLER_META_HASH = bytes32(0x5307fcdf3fa283e1e7d5d58baaa516cdefb10aba9eb23211d9cfb11afd6e4b4c);

/// @title GenericPoolOrderBookV3FlashBorrower
/// Implements the OrderBookV3FlashBorrower interface for a external liquidity
Expand Down
17 changes: 11 additions & 6 deletions src/concrete/OrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
LibMeta
} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {LibBytecode} from "rain.interpreter/src/lib/bytecode/LibBytecode.sol";
import {SourceIndexV2, StateNamespace, IInterpreterV2} from "rain.interpreter/src/interface/unstable/IInterpreterV2.sol";
import {
SourceIndexV2, StateNamespace, IInterpreterV2
} from "rain.interpreter/src/interface/unstable/IInterpreterV2.sol";
import {
IOrderBookV3,
NoOrders,
Expand Down Expand Up @@ -297,10 +299,7 @@ contract OrderBook is IOrderBookV3, ReentrancyGuard, Multicall, OrderBookV3Flash
(IInterpreterV2 interpreter, IInterpreterStoreV1 store, address expression, bytes memory io) = config
.evaluableConfig
.deployer
.deployExpression2(
config.evaluableConfig.bytecode,
config.evaluableConfig.constants
);
.deployExpression2(config.evaluableConfig.bytecode, config.evaluableConfig.constants);
{
uint256 calculateInputs;
uint256 calculateOutputs;
Expand Down Expand Up @@ -742,7 +741,13 @@ contract OrderBook is IOrderBookV3, ReentrancyGuard, Multicall, OrderBookV3Flash
(uint256[] memory calculateOrderStack, uint256[] memory calculateOrderKVs) = order
.evaluable
.interpreter
.eval2(order.evaluable.store, LibNamespace.qualifyNamespace(namespace, address(this)), _calculateOrderDispatch(order.evaluable.expression), context, new uint256[](0));
.eval2(
order.evaluable.store,
LibNamespace.qualifyNamespace(namespace, address(this)),
_calculateOrderDispatch(order.evaluable.expression),
context,
new uint256[](0)
);

Output18Amount orderOutputMax18 = Output18Amount.wrap(calculateOrderStack[1]);
uint256 orderIORatio = calculateOrderStack[0];
Expand Down
8 changes: 5 additions & 3 deletions src/interface/unstable/IOrderBookV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
pragma solidity ^0.8.18;

import "../ierc3156/IERC3156FlashLender.sol";
import {IExpressionDeployerV3, EvaluableV2} from "lib/rain.interpreter/src/lib/caller/LibEvaluable.sol";
import {
IExpressionDeployerV3, EvaluableV2
} from "lib/rain.interpreter/src/lib/caller/LibEvaluable.sol";
import {EvaluableConfigV3, IInterpreterCallerV2, SignedContextV1} from "lib/rain.interpreter/src/interface/IInterpreterCallerV2.sol";
EvaluableConfigV3,
IInterpreterCallerV2,
SignedContextV1
} from "lib/rain.interpreter/src/interface/IInterpreterCallerV2.sol";

/// Import unmodified structures from older versions of `IOrderBook`.
import {IO, ClearConfig, ClearStateChange} from "../deprecated/IOrderBookV2.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest {
);
}

function testGenericPoolTakeOrdersSender(OrderV2 memory order, uint256 inputIOIndex, uint256 outputIOIndex) public {
function testGenericPoolTakeOrdersSender(OrderV2 memory order, uint256 inputIOIndex, uint256 outputIOIndex)
public
{
TakeOrderConfigV2[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex);

GenericPoolOrderBookV3ArbOrderTaker(iArb).arb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest {
);
}

function testTakeOrdersSender(OrderV2 memory order, uint256 inputIOIndex, uint256 outputIOIndex) public {
function testGenericPoolOrderBookV3FlashBorrowerTakeOrdersSender(
OrderV2 memory order,
uint256 inputIOIndex,
uint256 outputIOIndex
) public {
TakeOrderConfigV2[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex);

GenericPoolOrderBookV3FlashBorrower(iArb).arb(
Expand All @@ -37,7 +41,7 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest {
);
}

function testMinimumOutput(
function testGenericPoolOrderBookV3FlashBorrowerMinimumOutput(
OrderV2 memory order,
uint256 inputIOIndex,
uint256 outputIOIndex,
Expand Down
4 changes: 1 addition & 3 deletions test/concrete/OrderBook.clear.handleIO.revert.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
pragma solidity =0.8.19;

import {Vm} from "forge-std/Vm.sol";
import {
OrderBookExternalRealTest
} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {OrderBookExternalRealTest} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {ClearConfig, OrderV2, TakeOrderConfigV2, IO, OrderConfigV2} from "src/interface/unstable/IOrderBookV3.sol";
import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter/src/interface/IInterpreterCallerV2.sol";
import {IParserV1} from "rain.interpreter/src/interface/IParserV1.sol";
Expand Down
11 changes: 8 additions & 3 deletions test/concrete/OrderBook.takeOrder.handleIO.revert.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
pragma solidity =0.8.19;

import {Vm} from "forge-std/Vm.sol";
import {OrderBookExternalRealTest} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {
OrderBookExternalRealTest
} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {ClearConfig, OrderV2, TakeOrderConfigV2, IO, OrderConfigV2, TakeOrdersConfigV2} from "src/interface/unstable/IOrderBookV3.sol";
ClearConfig,
OrderV2,
TakeOrderConfigV2,
IO,
OrderConfigV2,
TakeOrdersConfigV2
} from "src/interface/unstable/IOrderBookV3.sol";
import {EnsureFailed} from "rain.interpreter/src/lib/op/logic/LibOpEnsureNP.sol";
import {IParserV1} from "rain.interpreter/src/interface/IParserV1.sol";
import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter/src/interface/IInterpreterCallerV2.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/concrete/OrderBook.takeOrder.precision.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity =0.8.19;

import {Vm} from "forge-std/Test.sol";
import {OrderBookExternalRealTest} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {
OrderBookExternalRealTest
} from "test/util/abstract/OrderBookExternalRealTest.sol";
import {OrderV2, TakeOrdersConfigV2, TakeOrderConfigV2, IO, OrderConfigV2} from "src/interface/unstable/IOrderBookV3.sol";
OrderV2, TakeOrdersConfigV2, TakeOrderConfigV2, IO, OrderConfigV2
} from "src/interface/unstable/IOrderBookV3.sol";
import {IParserV1} from "rain.interpreter/src/interface/IParserV1.sol";
import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter/src/interface/IInterpreterCallerV2.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest {
);
}

function testRouteProcessorTakeOrdersSender(OrderV2 memory order, uint256 inputIOIndex, uint256 outputIOIndex) public {
function testRouteProcessorTakeOrdersSender(OrderV2 memory order, uint256 inputIOIndex, uint256 outputIOIndex)
public
{
TakeOrderConfigV2[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex);

RouteProcessorOrderBookV3ArbOrderTaker(iArb).arb(
Expand Down
11 changes: 7 additions & 4 deletions test/util/abstract/IOrderBookV3Stub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ abstract contract IOrderBookV3Stub is IOrderBookV3 {
}

/// @inheritdoc IOrderBookV3
function clear(OrderV2 memory, OrderV2 memory, ClearConfig calldata, SignedContextV1[] memory, SignedContextV1[] memory)
external
pure
{
function clear(
OrderV2 memory,
OrderV2 memory,
ClearConfig calldata,
SignedContextV1[] memory,
SignedContextV1[] memory
) external pure {
revert("clear");
}

Expand Down
3 changes: 2 additions & 1 deletion test/util/abstract/OrderBookExternalMockTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {IOrderBookV3, OrderConfigV2, OrderV2} from "src/interface/unstable/IOrde
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {LibOrder} from "src/lib/LibOrder.sol";
import {OrderBook} from "src/concrete/OrderBook.sol";
import {DeployerDiscoverableMetaV3ConstructionConfig} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";
import {DeployerDiscoverableMetaV3ConstructionConfig} from
"rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol";

/// @title OrderBookExternalTest
/// Abstract contract that performs common setup needed for testing an orderbook
Expand Down
5 changes: 4 additions & 1 deletion test/util/abstract/OrderBookExternalRealTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ pragma solidity =0.8.19;
import {Test, Vm, console2} from "forge-std/Test.sol";
import {RainterpreterNPE2} from "rain.interpreter/src/concrete/RainterpreterNPE2.sol";
import {RainterpreterStoreNPE2} from "rain.interpreter/src/concrete/RainterpreterStoreNPE2.sol";
import {RainterpreterExpressionDeployerNPE2, RainterpreterExpressionDeployerNPE2ConstructionConfig} from "rain.interpreter/src/concrete/RainterpreterExpressionDeployerNPE2.sol";
import {
RainterpreterExpressionDeployerNPE2,
RainterpreterExpressionDeployerNPE2ConstructionConfig
} from "rain.interpreter/src/concrete/RainterpreterExpressionDeployerNPE2.sol";
import {LibAllStandardOpsNP} from "rain.interpreter/src/lib/op/LibAllStandardOpsNP.sol";
import {REVERTING_MOCK_BYTECODE} from "test/util/lib/LibTestConstants.sol";
import {ORDER_BOOK_META_PATH} from "test/util/lib/LibOrderBookConstants.sol";
Expand Down

0 comments on commit 13e7e6b

Please sign in to comment.