Skip to content

Commit 75c53f5

Browse files
authored
Handle limit zero case in tests - the generated code should not have been manually modified. (#859)
1 parent 6f70041 commit 75c53f5

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForApplicationBoxes.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ public SearchForApplicationBoxes(Client client, Long applicationId) {
3030
* limit is not reached.
3131
*/
3232
public SearchForApplicationBoxes limit(Long limit) {
33-
// Only add limit parameter if limit is not null and not 0
34-
// This matches behavior of other SDKs (Python/Go) which omit the parameter when limit=0
35-
if (limit != null && limit != 0) {
36-
addQuery("limit", String.valueOf(limit));
37-
}
33+
addQuery("limit", String.valueOf(limit));
3834
return this;
3935
}
4036

src/test/java/com/algorand/algosdk/integration/Applications.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,14 @@ public void checkAppBoxesNum(String fromClient, Long limit, int expected_num) th
386386
Response<BoxesResponse> r;
387387
if (fromClient.equals("algod"))
388388
r = base.aclv2.GetApplicationBoxes(this.appId).max(limit).execute();
389-
else if (fromClient.equals("indexer"))
390-
r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).limit(limit).execute();
391-
else
389+
else if (fromClient.equals("indexer")) {
390+
// Handle limit=0 case for indexer: omit the limit parameter to use server default
391+
if (limit == 0) {
392+
r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).execute();
393+
} else {
394+
r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).limit(limit).execute();
395+
}
396+
} else
392397
throw new IllegalArgumentException("expecting algod or indexer, got " + fromClient);
393398

394399
Assert.assertTrue(r.isSuccessful());
@@ -398,7 +403,13 @@ else if (fromClient.equals("indexer"))
398403

399404
@Then("according to indexer, with {long} being the parameter that limits results, and {string} being the parameter that sets the next result, the current application should have the following boxes {string}.")
400405
public void indexerCheckAppBoxesWithParams(Long limit, String next, String encodedBoxesRaw) throws Exception {
401-
Response<BoxesResponse> r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).limit(limit).next(next).execute();
406+
// Handle limit=0 case for indexer: omit the limit parameter to use server default
407+
Response<BoxesResponse> r;
408+
if (limit == 0) {
409+
r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).next(next).execute();
410+
} else {
411+
r = base.v2IndexerClient.searchForApplicationBoxes(this.appId).limit(limit).next(next).execute();
412+
}
402413
final Set<byte[]> expectedNames = new HashSet<>();
403414
if (!encodedBoxesRaw.isEmpty()) {
404415
for (String s : encodedBoxesRaw.split(":")) {

src/test/java/com/algorand/algosdk/unit/utils/TestingUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,6 @@ public static boolean notEmpty(String str) {
311311
}
312312

313313
public static boolean notEmpty(Long val) {
314-
return val != null && val != 0;
314+
return val != 0;
315315
}
316316
}

0 commit comments

Comments
 (0)