Skip to content
Merged
Show file tree
Hide file tree
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
59 changes: 59 additions & 0 deletions src/test/java/com/algorand/algosdk/unit/IndexerPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;

public class IndexerPaths {
IndexerClient indexerClient = new IndexerClient("localhost", 1234, "");;
Expand Down Expand Up @@ -134,6 +136,63 @@ public void oldSearchForTransactions(
addressRole, excludeCloseTo, "");
}

@When("we make a Search For BlockHeaders call with minRound {long} " +
"maxRound {long} " +
"limit {long} " +
"nextToken {string} " +
"beforeTime {string} " +
"afterTime {string} " +
"proposers {string} " +
"expired {string} " +
"absent {string}")
public void SearchForBlockHeaders(Long minRound, Long maxRound, Long limit,
String next, String beforeTime, String afterTime,
String proposers, String expired, String absent)
throws ParseException {

SearchForBlockHeaders q = this.indexerClient.searchForBlockHeaders();
if (TestingUtils.notEmpty(minRound)) q.minRound(minRound);
if (TestingUtils.notEmpty(maxRound)) q.maxRound(maxRound);
if (TestingUtils.notEmpty(limit)) q.limit(limit);
if (TestingUtils.notEmpty(next)) q.next(next);
if (TestingUtils.notEmpty(beforeTime)) q.beforeTime(Utils.parseDate(beforeTime));
if (TestingUtils.notEmpty(afterTime)) q.afterTime(Utils.parseDate(afterTime));
if (TestingUtils.notEmpty(proposers)) {
q.proposers(
Arrays.stream(proposers.split(",")).map(ea -> {
try {
return new Address(ea);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList())
);
}
if (TestingUtils.notEmpty(expired)) {
q.expired(
Arrays.stream(expired.split(",")).map(ea -> {
try {
return new Address(ea);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList())
);
}
if (TestingUtils.notEmpty(absent)) {
q.absent(
Arrays.stream(absent.split(",")).map(ea -> {
try {
return new Address(ea);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList())
);
}
ps.q = q;
}

@When("we make a SearchForAssets call with limit {long} "
+ "creator {string} "
+ "name {string} "
Expand Down
22 changes: 15 additions & 7 deletions src/test/java/com/algorand/algosdk/unit/IndexerResponses.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
import java.io.IOException;
import java.math.BigInteger;

import com.algorand.algosdk.v2.client.model.*;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Assertions;

import com.algorand.algosdk.crypto.Address;
import com.algorand.algosdk.unit.utils.ClientMocker;
import com.algorand.algosdk.v2.client.common.IndexerClient;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.AccountResponse;
import com.algorand.algosdk.v2.client.model.AccountsResponse;
import com.algorand.algosdk.v2.client.model.AssetBalancesResponse;
import com.algorand.algosdk.v2.client.model.AssetResponse;
import com.algorand.algosdk.v2.client.model.AssetsResponse;
import com.algorand.algosdk.v2.client.model.Block;
import com.algorand.algosdk.v2.client.model.TransactionsResponse;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
Expand All @@ -40,6 +34,7 @@ public IndexerResponses(ResponsesShared shared) {
Response<AssetResponse> assetResponse;
Response<AssetBalancesResponse> assetBalancesResponse;
Response<TransactionsResponse> transactionsResponse;
Response<BlockHeadersResponse> blockheadersResponse;
Response<AssetsResponse> assetsResponse;

@When("we make any LookupAssetBalances call")
Expand Down Expand Up @@ -90,6 +85,12 @@ public void we_make_any_SearchForTransactions_call() throws Exception {
transactionsResponse = client.searchForTransactions().execute();
}

@When("we make any SearchForBlockHeaders call")
public void we_make_any_search_for_block_headers_call() throws Exception {
ClientMocker.infect(client);
blockheadersResponse = client.searchForBlockHeaders().execute();
}

@When("we make any SearchForAssets call")
public void we_make_any_SearchForAssets_call() throws Exception {
ClientMocker.infect(client);
Expand Down Expand Up @@ -139,6 +140,13 @@ public void the_parsed_LookupBlock_response_should_have_previous_block_hash(Stri
verifyResponse(blockResponse, shared.bodyFile);
}

@Then("the parsed SearchForBlockHeaders response should have a block array of len {int} "
+ "and the element at index {int} should have round {string}")
public void the_parsed_search_for_block_headers_response_should_have_a_block_array_of_len_and_the_element_at_index_should_have_round(
Integer int1, Integer int2, String string) throws IOException {
verifyResponse(blockheadersResponse, shared.bodyFile);
}


@Then("the parsed LookupAccountByID response should have address {string}")
public void the_parsed_LookupAccountByID_response_should_have_address(String string) throws IOException {
Expand Down
1 change: 1 addition & 0 deletions src/test/unit.tags
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@unit.dryrun.trace.application
@unit.feetest
@unit.indexer
@unit.indexer.blockheaders
@unit.indexer.ledger_refactoring
@unit.indexer.logs
@unit.indexer.rekey
Expand Down