Skip to content

Commit

Permalink
Add missing test in GetAccountInfoContractTest for getting NonceAccou…
Browse files Browse the repository at this point in the history
…ntData
  • Loading branch information
ml-james committed Dec 12, 2024
1 parent fcb25f0 commit 2f3ea77
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ void shouldGetMintAccountInfoJsonParsedEncodingOptionalParam() throws SolanaJson
);
}

@Test
void shouldGetNonceAccountInfoJsonParsedEncodingOptionalParam() throws SolanaJsonRpcClientException
{
final SolanaClientOptionalParams optionalParams = new SolanaJsonRpcClientOptionalParams();
optionalParams.addParam("encoding", "jsonParsed");

final var accountInfo = SOLANA_API.getAccountInfo(NONCE_ACCOUNT, optionalParams).getResponse();
assertThat(accountInfo.getOwner()).isEqualTo("11111111111111111111111111111111");

// program specific parser so we can try and read the data that's returned
assertThat(accountInfo.getData().getAccountInfoEncoded()).isNull();

final var parsedAccountInfo = accountInfo.getData().getAccountInfoParsed();
assertThat(parsedAccountInfo.getProgram()).isEqualTo("nonce");
assertThat(parsedAccountInfo.getSpace()).isEqualTo(80);

// i think the best we can do here is really just return a Map<String, Object> and let the user do their own parsing
// since the parsing is very much program specific
assertThat(parsedAccountInfo.getParsedData().get("type")).isEqualTo("initialized");
assertThat(parsedAccountInfo.getParsedData().get("info"))
.usingRecursiveComparison()
.isEqualTo(Map.of("authority", "2dY4b9YdnHaURDVJj339q7eczTdxnVyiGifA5yXG4yQN",
"blockhash", "Hb4pM3V4j9ipCsFNpymzViHZPiDMUH2KwLzrpSchiYVU",
"feeCalculator", Map.of("lamportsPerSignature", "5000"))
);
}

@Test
void shouldGetAccountInfoDataSliceOptionalParam() throws SolanaJsonRpcClientException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ abstract class SolanaClientIntegrationTestBase extends IntegrationTestBase

protected static final String SOL_ACCOUNT = "4Nd1mnszWRVFzzsxMgcTzdFoC8Wx5mPQD9KZx3qtDr1M";

protected static final String NONCE_ACCOUNT = "6qS7fCwPYCSJ6msth7h1AB6g8aGe6rro1agHAamM4rAM";

protected static final String TOKEN_MINT = "2tokpcExDmewsSNRKuTLVLMUseiSkEdBQWBjeQLmuFaS";

protected static final String TOKEN_ACCOUNT_1 = "CZJWrh6o1tchnKB1UkGn2f65DDD7BbA1u6Nz6bZfTTNC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public abstract class IntegrationTestBase
copyResourceToTempFile(parentDirectory, "accounts/token_mint.json");
copyResourceToTempFile(parentDirectory, "accounts/token_account_1.json");
copyResourceToTempFile(parentDirectory, "accounts/token_account_2.json");
copyResourceToTempFile(parentDirectory, "accounts/nonce_account.json");

final String solanaVersion = System.getProperty("solana.version");
if (arch.equals("aarch64"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pubkey": "6qS7fCwPYCSJ6msth7h1AB6g8aGe6rro1agHAamM4rAM",
"account": {
"lamports": 300000,
"data": [
"AQAAAAEAAAAYN7fDgyW630LDtnup4nlG5uUrhnBS077hAkv7jaK5U/Z1Da4WA4qlaCl2RvtERjayxzWWD30+4/7zXET6S+5XiBMAAAAAAAA=",
"base64"
],
"owner": "11111111111111111111111111111111",
"executable": false,
"rentEpoch": 18446744073709551615,
"space": 80
}
}

0 comments on commit 2f3ea77

Please sign in to comment.