Skip to content

Commit 0ce9008

Browse files
Test order-clearer and order context words for both orders in clear3
Closes #2936 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d84b25c commit 0ce9008

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

‎test/concrete/raindex/RaindexV6.contextWordEntrypoints.t.sol‎

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,14 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
181181
}
182182

183183
/// `CLEARER` clears an ACTOR order whose calculate source is `calculate` and
184-
/// handle source is `handle` against a TAKER order.
185-
function doClear(string memory calculate, string memory handle) public {
184+
/// handle source is `handle` against a TAKER order whose calculate source is
185+
/// `bobCalculate` and handle source is `bobHandle`.
186+
function doClear(
187+
string memory calculate,
188+
string memory handle,
189+
string memory bobCalculate,
190+
string memory bobHandle
191+
) public {
186192
vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20.transferFrom.selector), abi.encode(true));
187193
vm.mockCall(address(iToken1), abi.encodeWithSelector(IERC20.transferFrom.selector), abi.encode(true));
188194
vm.prank(ACTOR);
@@ -200,7 +206,13 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
200206
VAULT_ID
201207
);
202208
OrderV4 memory bob = LibTestTakeOrder.addOrderWithExpression(
203-
vm, TAKER, "_ _:1 1;:;", address(iToken1), VAULT_ID, address(iToken0), VAULT_ID
209+
vm,
210+
TAKER,
211+
bytes(string.concat("using-words-from ", address(iSubParser).toHexString(), "\n", bobCalculate, bobHandle)),
212+
address(iToken1),
213+
VAULT_ID,
214+
address(iToken0),
215+
VAULT_ID
204216
);
205217
vm.prank(CLEARER);
206218
iRaindex.clear3(alice, bob, ClearConfigV2(0, 0, 0, 0, 0, 0), new SignedContextV1[](0), new SignedContextV1[](0));
@@ -379,11 +391,29 @@ contract RaindexV6ContextWordEntrypointsTest is RaindexV6ExternalRealTest {
379391
checks[4] = Check("order-clearer()", CLEARER.toHexString());
380392
}
381393

394+
function bobClearChecks() internal view returns (Check[] memory checks) {
395+
checks = new Check[](5);
396+
checks[0] = raindexCheck();
397+
checks[1] = senderCheck(CLEARER);
398+
checks[2] = Check("order-owner()", TAKER.toHexString());
399+
checks[3] = Check("order-counterparty()", ACTOR.toHexString());
400+
checks[4] = Check("order-clearer()", CLEARER.toHexString());
401+
}
402+
382403
function testClearCalculateContextWords() external {
383-
this.doClear(string.concat("_ _:1 1,", ensures(clearChecks())), ":;");
404+
this.doClear(string.concat("_ _:1 1,", ensures(clearChecks())), ":;", "_ _:1 1;", ":;");
384405
}
385406

386407
function testClearHandleIOContextWords() external {
387-
this.doClear("_ _:1 1;", ensures(clearChecks()));
408+
this.doClear("_ _:1 1;", ensures(clearChecks()), "_ _:1 1;", ":;");
409+
}
410+
411+
function testClearBothOrdersContextWords() external {
412+
this.doClear(
413+
string.concat("_ _:1 1,", ensures(clearChecks())),
414+
ensures(clearChecks()),
415+
string.concat("_ _:1 1,", ensures(bobClearChecks())),
416+
ensures(bobClearChecks())
417+
);
388418
}
389419
}

0 commit comments

Comments
 (0)