Skip to content

Commit

Permalink
Complete GetSlotContractTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-james committed Nov 1, 2024
1 parent 91efa80 commit e985c6b
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/getaccountinfo
class GetAccountInfoContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/getbalance
class GetBalanceContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/getblockheight
class GetBlockHeightContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/getlatestblockhash
class GetLatestBlockhashContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/getminimumbalanceforrentexemption
class GetMinimumBalanceForRentExemptionContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lmax.solana4j.client.jsonrpc;

import com.lmax.solana4j.client.api.SolanaClientOptionalParams;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -8,13 +9,21 @@
class GetSlotContractTest extends SolanaClientIntegrationTestBase
{
@Test
void shouldGetSlot() throws SolanaJsonRpcClientException
void shouldGetSlotDefaultOptionalParams() throws SolanaJsonRpcClientException
{
// {
// "jsonrpc" : "2.0",
// "result" : 369,
// "id" : 4
// }
assertThat(api.getSlot().getResponse()).isGreaterThan(0L);
}

@Test
void shouldReturnErrorForMinContextSlotNotReached() throws SolanaJsonRpcClientException
{
final SolanaClientOptionalParams optionalParams = new SolanaJsonRpcClientOptionalParams();
optionalParams.addParam("minContextSlot", 10000000000L);

final var response = api.getSlot(optionalParams);

assertThat(response.isSuccess()).isFalse();
assertThat(response.getError().getErrorCode()).isEqualTo(-32016L);
assertThat(response.getError().getErrorMessage()).isEqualTo("Minimum context slot has not been reached");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/gettokenaccountbalance
class GetTokenAccountBalanceContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import static org.assertj.core.api.Assertions.assertThat;

// https://solana.com/docs/rpc/http/requestairdrop
class RequestAirdropContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import static org.assertj.core.api.Assertions.fail;

// https://solana.com/docs/rpc/http/sendtransaction
class SendTransactionContractTest extends SolanaClientIntegrationTestBase
{
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Map;

final class RpcWrapperDTO<T>
{
private final String jsonrpc;
Expand Down Expand Up @@ -58,12 +60,17 @@ public static class Error
{
private final long code;
private final String message;
private final Map<String, Object> data;

@JsonCreator
Error(final @JsonProperty("code") long code, final @JsonProperty("message") String message)
Error(
final @JsonProperty("code") long code,
final @JsonProperty("message") String message,
final @JsonProperty("data") Map<String, Object> data)
{
this.code = code;
this.message = message;
this.data = data;
}

public long getCode()
Expand All @@ -82,6 +89,7 @@ public String toString()
return "Error{" +
"code=" + code +
", message='" + message + '\'' +
", data=" + data +
'}';
}
}
Expand Down

0 comments on commit e985c6b

Please sign in to comment.