@@ -1128,6 +1128,25 @@ contract OnChainAllocatorTest is Test, TestHelper {
11281128 );
11291129 }
11301130
1131+ function test_allocateAndRegister_revert_InvalidCommitments () public {
1132+ Lock[] memory commitments = new Lock [](0 );
1133+
1134+ vm.expectRevert (abi.encodeWithSelector (IOnChainAllocator.InvalidCommitments.selector ));
1135+ allocator.allocateAndRegister (
1136+ recipient, commitments, arbiter, defaultExpiration, BATCH_COMPACT_TYPEHASH, bytes32 (0 )
1137+ );
1138+ }
1139+
1140+ function test_allocateAndRegister_revert_InvalidAmount_native () public {
1141+ Lock[] memory commitments = new Lock [](1 );
1142+ commitments[0 ] = _makeLock (address (0 ), 1 ether);
1143+
1144+ vm.expectRevert (abi.encodeWithSelector (IOnChainAllocator.InvalidAmount.selector , commitments[0 ].amount));
1145+ allocator.allocateAndRegister {value: commitments[0 ].amount + 1 }(
1146+ recipient, commitments, arbiter, defaultExpiration, BATCH_COMPACT_TYPEHASH, bytes32 (0 )
1147+ );
1148+ }
1149+
11311150 function test_allocateAndRegister_revert_InvalidAmount () public {
11321151 Lock[] memory commitments = new Lock [](1 );
11331152 commitments[0 ] = _makeLock (address (usdc), uint256 (type (uint224 ).max) + 1 );
@@ -1274,6 +1293,43 @@ contract OnChainAllocatorTest is Test, TestHelper {
12741293 );
12751294 }
12761295
1296+ function test_allocateAndRegister_success_multiple () public {
1297+ uint256 amount1 = 1 ether ;
1298+ uint256 amount2 = 2 ether ;
1299+
1300+ usdc.mint (address (allocator), amount2);
1301+
1302+ Lock[] memory commitments = new Lock [](2 );
1303+ commitments[0 ] = _makeLock (address (0 ), amount1);
1304+ commitments[1 ] = _makeLock (address (usdc), amount2);
1305+
1306+ vm.deal (caller, amount1);
1307+ vm.prank (caller);
1308+ (bytes32 claimHash , uint256 [] memory registeredAmounts , uint256 nonce ) = allocator.allocateAndRegister {
1309+ value: amount1
1310+ }(recipient, commitments, arbiter, defaultExpiration, BATCH_COMPACT_TYPEHASH, bytes32 (0 ));
1311+
1312+ uint256 id1 = _toId (Scope.Multichain, ResetPeriod.TenMinutes, address (allocator), address (0 ));
1313+ uint256 id2 = _toId (Scope.Multichain, ResetPeriod.TenMinutes, address (allocator), address (usdc));
1314+
1315+ assertEq (registeredAmounts.length , 2 );
1316+ assertEq (registeredAmounts[0 ], amount1);
1317+ assertEq (registeredAmounts[1 ], amount2);
1318+
1319+ assertEq (ERC6909 (address (compact)).balanceOf (recipient, id1), amount1);
1320+ assertEq (ERC6909 (address (compact)).balanceOf (recipient, id2), amount2);
1321+
1322+ uint256 [2 ][] memory idsAndAmounts = new uint256 [2 ][](2 );
1323+ idsAndAmounts[0 ][0 ] = id1;
1324+ idsAndAmounts[0 ][1 ] = amount1;
1325+ idsAndAmounts[1 ][0 ] = id2;
1326+ idsAndAmounts[1 ][1 ] = amount2;
1327+
1328+ assertTrue (
1329+ allocator.isClaimAuthorized (claimHash, arbiter, recipient, nonce, defaultExpiration, idsAndAmounts, '' )
1330+ );
1331+ }
1332+
12771333 function test_allocateAndRegister_tokensImmediatelyAllocated () public {
12781334 uint256 amount1 = 1 ether ;
12791335 uint256 amount2 = 2 ether ;
0 commit comments