Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions test/concrete/raindex/RaindexV6.contextWordEntrypoints.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
}

/// `CLEARER` clears an ACTOR order whose calculate source is `calculate` and
/// handle source is `handle` against a TAKER order.
function doClear(string memory calculate, string memory handle) public {
/// handle source is `handle` against a TAKER order whose calculate source is
/// `bobCalculate` and handle source is `bobHandle`.
function doClear(string memory calculate, string memory handle, string memory bobCalculate, string memory bobHandle)
public
{
vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20.transferFrom.selector), abi.encode(true));
vm.mockCall(address(iToken1), abi.encodeWithSelector(IERC20.transferFrom.selector), abi.encode(true));
vm.prank(ACTOR);
Expand All @@ -200,7 +203,13 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
VAULT_ID
);
OrderV4 memory bob = LibTestTakeOrder.addOrderWithExpression(
vm, TAKER, "_ _:1 1;:;", address(iToken1), VAULT_ID, address(iToken0), VAULT_ID
vm,
TAKER,
bytes(string.concat("using-words-from ", address(iSubParser).toHexString(), "\n", bobCalculate, bobHandle)),
address(iToken1),
VAULT_ID,
address(iToken0),
VAULT_ID
);
vm.prank(CLEARER);
iRaindex.clear3(alice, bob, ClearConfigV2(0, 0, 0, 0, 0, 0), new SignedContextV1[](0), new SignedContextV1[](0));
Expand Down Expand Up @@ -379,11 +388,29 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
checks[4] = Check("order-clearer()", CLEARER.toHexString());
}

function bobClearChecks() internal view returns (Check[] memory checks) {
checks = new Check[](5);
checks[0] = raindexCheck();
checks[1] = senderCheck(CLEARER);
checks[2] = Check("order-owner()", TAKER.toHexString());
checks[3] = Check("order-counterparty()", ACTOR.toHexString());
checks[4] = Check("order-clearer()", CLEARER.toHexString());
}

function testClearCalculateContextWords() external {
this.doClear(string.concat("_ _:1 1,", ensures(clearChecks())), ":;");
this.doClear(string.concat("_ _:1 1,", ensures(clearChecks())), ":;", "_ _:1 1;", ":;");
}

function testClearHandleIOContextWords() external {
this.doClear("_ _:1 1;", ensures(clearChecks()));
this.doClear("_ _:1 1;", ensures(clearChecks()), "_ _:1 1;", ":;");
}

function testClearBothOrdersContextWords() external {
this.doClear(
string.concat("_ _:1 1,", ensures(clearChecks())),
ensures(clearChecks()),
string.concat("_ _:1 1,", ensures(bobClearChecks())),
ensures(bobClearChecks())
);
}
}
Loading