From 64c6d021a8c4abe4d185aa7a6f6ebf8540839974 Mon Sep 17 00:00:00 2001 From: matthewjames Date: Fri, 1 Nov 2024 19:38:46 -0400 Subject: [PATCH] Complete GetLatestBlockhashContractTest --- .../GetLatestBlockhashContractTest.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetLatestBlockhashContractTest.java b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetLatestBlockhashContractTest.java index 49341d7d..83a35f4c 100644 --- a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetLatestBlockhashContractTest.java +++ b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetLatestBlockhashContractTest.java @@ -1,30 +1,31 @@ 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; +// https://solana.com/docs/rpc/http/getlatestblockhash class GetLatestBlockhashContractTest extends SolanaClientIntegrationTestBase { @Test void shouldGetLatestBlockhash() throws SolanaJsonRpcClientException { -// { -// "jsonrpc" : "2.0", -// "result" : { -// "context" : { -// "apiVersion" : "2.0.14", -// "slot" : 117 -// }, -// "value" : { -// "blockhash" : "8hmtSxyZRLcXEwpVZyaeniQJevxQkLje3mLgFvyToWLs", -// "lastValidBlockHeight" : 267 -// } -// }, -// "id" : 4 -// } final var latestBlockhash = api.getLatestBlockhash().getResponse(); assertThat(latestBlockhash.getBlockhashBase58()).isNotBlank(); assertThat(latestBlockhash.getLastValidBlockHeight()).isGreaterThan(0); } + + @Test + void shouldReturnErrorForMinContextSlotNotReached() throws SolanaJsonRpcClientException + { + final SolanaClientOptionalParams optionalParams = new SolanaJsonRpcClientOptionalParams(); + optionalParams.addParam("minContextSlot", 10000000000L); + + final var response = api.getLatestBlockhash(optionalParams); + + assertThat(response.isSuccess()).isFalse(); + assertThat(response.getError().getErrorCode()).isEqualTo(-32016L); + assertThat(response.getError().getErrorMessage()).isEqualTo("Minimum context slot has not been reached"); + } }