@@ -18,13 +18,11 @@ import {Strings} from "@openzeppelin-contracts-5.7.0/utils/Strings.sol";
1818import {LibDecimalFloat, Float} from "rain-math-float-0.3.10/src/lib/LibDecimalFloat.sol " ;
1919import {LibTestSignedContext} from "test/util/lib/LibTestSignedContext.sol " ;
2020
21- /// @title RaindexV6ClearSignedContextRoutingTest
22- /// @notice `clear4` evaluates alice's order with `aliceSignedContext` and bob's
23- /// with `bobSignedContext`, matching `quote3`/`takeOrders5`. Each order's
24- /// expression asserts the signer, domain and signed content it sees, so routing
25- /// is pinned by signer, domain and content rather than slot. Runs against
26- /// fresh-compiled RaindexV6 so source mutations are observable.
27- contract RaindexV6ClearSignedContextRoutingTest is RaindexV6ExternalRealTest {
21+ /// @title RaindexV6ClearSignedContextV2Test
22+ /// @notice `clear4` evaluates orders with `SignedContextV2`: each order's
23+ /// expression asserts the signer, domain and signed content it sees. Runs
24+ /// against fresh-compiled RaindexV6 so source mutations are observable.
25+ contract RaindexV6ClearSignedContextV2Test is RaindexV6ExternalRealTest {
2826 using Strings for address ;
2927 using Strings for uint256 ;
3028 using LibDecimalFloat for Float;
@@ -134,50 +132,21 @@ contract RaindexV6ClearSignedContextRoutingTest is RaindexV6ExternalRealTest {
134132 return ClearConfigV2 (0 , 0 , 0 , 0 , bytes32 (uint256 (0xc1 )), bytes32 (uint256 (0xc2 )));
135133 }
136134
135+ /// Both orders receive the same signed context, so this holds under either
136+ /// routing of `aliceSignedContext`/`bobSignedContext`.
137137 /// forge-config: default.fuzz.runs = 32
138- function testClearRoutesEachSignedContextToItsOwnOrder (Expected memory alice , Expected memory bob ) external {
139- alice .pk = boundPk (alice .pk);
140- bob.pk = boundPk (bob.pk );
141- vm. assume (vm. addr (alice.pk) != vm. addr (bob.pk) );
142- (OrderV4 memory aliceOrder , OrderV4 memory bobOrder ) = orders (alice, bob );
138+ function testClearEvalSeesSignedContextV2 (Expected memory expected ) external {
139+ expected .pk = boundPk (expected .pk);
140+ vm. assume (expected.domain != bytes32 ( 0 ) );
141+ (OrderV4 memory aliceOrder , OrderV4 memory bobOrder ) = orders (expected, expected );
142+ SignedContextV2[] memory signedContexts = signedContext (expected );
143143
144- iRaindex.clear4 (aliceOrder, bobOrder, clearConfig (), signedContext (alice), signedContext (bob) );
144+ iRaindex.clear4 (aliceOrder, bobOrder, clearConfig (), signedContexts, signedContexts );
145145
146146 assertTrue (iRaindex.vaultBalance2 (aliceOrder.owner, address (iToken0), ALICE_IN).gt (LibDecimalFloat.FLOAT_ZERO));
147147 assertTrue (iRaindex.vaultBalance2 (bobOrder.owner, address (iToken1), BOB_IN).gt (LibDecimalFloat.FLOAT_ZERO));
148148 }
149149
150- /// forge-config: default.fuzz.runs = 32
151- function testClearRevertsWhenSignedContextsAreSwapped (Expected memory alice , Expected memory bob ) external {
152- alice.pk = boundPk (alice.pk);
153- bob.pk = boundPk (bob.pk);
154- vm.assume (vm.addr (alice.pk) != vm.addr (bob.pk));
155- (OrderV4 memory aliceOrder , OrderV4 memory bobOrder ) = orders (alice, bob);
156- SignedContextV2[] memory aliceSignedContext = signedContext (alice);
157- SignedContextV2[] memory bobSignedContext = signedContext (bob);
158-
159- vm.expectRevert ("alice signer " );
160- iRaindex.clear4 (aliceOrder, bobOrder, clearConfig (), bobSignedContext, aliceSignedContext);
161- }
162-
163- /// Same signer and content for both orders, so only the domain tells the
164- /// two signed contexts apart.
165- /// forge-config: default.fuzz.runs = 32
166- function testClearRevertsWhenDomainsAreSwapped (uint256 pk , bytes32 aliceDomain , bytes32 bobDomain , bytes32 content )
167- external
168- {
169- vm.assume (aliceDomain != bobDomain);
170- pk = boundPk (pk);
171- Expected memory alice = Expected (pk, aliceDomain, content);
172- Expected memory bob = Expected (pk, bobDomain, content);
173- (OrderV4 memory aliceOrder , OrderV4 memory bobOrder ) = orders (alice, bob);
174- SignedContextV2[] memory aliceSignedContext = signedContext (alice);
175- SignedContextV2[] memory bobSignedContext = signedContext (bob);
176-
177- vm.expectRevert ("alice domain " );
178- iRaindex.clear4 (aliceOrder, bobOrder, clearConfig (), bobSignedContext, aliceSignedContext);
179- }
180-
181150 function testClear3SelectorIsRemoved () external {
182151 (bool success , bytes memory returnData ) = address (iRaindex)
183152 .call (
0 commit comments