diff --git a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetAccountInfoContractTest.java b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetAccountInfoContractTest.java index d8775bcc..ef883ef3 100644 --- a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetAccountInfoContractTest.java +++ b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetAccountInfoContractTest.java @@ -11,37 +11,14 @@ class GetAccountInfoContractTest extends SolanaClientIntegrationTestBase @Test void shouldGetAccountInfo() { -// { -// "jsonrpc": "2.0", -// "result": { -// "context": { -// "apiVersion": "1.18.25", -// "slot": 733 -// }, -// "value": { -// "data": [ -// "", -// "base64" -// ], -// "executable": false, -// "lamports": 1000000000, -// "owner": "11111111111111111111111111111111", -// "rentEpoch": 18446744073709551615, -// "space": 0 -// } -// }, -// "id": 8 -// } - - - final var accountInfo = Waiter.waitFor(Condition.isNotNull(() -> api.getAccountInfo(account))); + final var accountInfo = Waiter.waitFor(Condition.isNotNull(() -> api.getAccountInfo(payerAccount))); assertThat(accountInfo.getOwner()).isEqualTo("11111111111111111111111111111111"); assertThat(accountInfo.getData().get(0)).isEqualTo(""); assertThat(accountInfo.getData().get(1)).isEqualTo("base64"); - assertThat(accountInfo.getLamports()).isEqualTo(1000000000); + assertThat(accountInfo.getLamports()).isEqualTo(600000L); assertThat(accountInfo.isExecutable()).isEqualTo(false); - assertThat(accountInfo.getRentEpoch()).isEqualTo(0); + assertThat(accountInfo.getRentEpoch()).isEqualTo("18446744073709551615"); assertThat(accountInfo.getSpace()).isEqualTo(0); } } diff --git a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/SolanaClientIntegrationTestBase.java b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/SolanaClientIntegrationTestBase.java index d65b1a55..a4525089 100644 --- a/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/SolanaClientIntegrationTestBase.java +++ b/client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/SolanaClientIntegrationTestBase.java @@ -4,23 +4,19 @@ import com.lmax.solana4j.assertion.Condition; import com.lmax.solana4j.assertion.Waiter; import com.lmax.solana4j.client.api.SolanaApi; -import com.lmax.solana4j.domain.Sol; -import com.lmax.solana4j.util.TestKeyPairGenerator; import org.junit.jupiter.api.BeforeEach; -import java.math.BigDecimal; - public class SolanaClientIntegrationTestBase extends IntegrationTestBase { - // associated token account public key : 4swkJXi9iwk1sRB4QAk4ZmX1WCWfpP9ButmqCfkEyaqC - // multisig account public key : 13SkCFWQiqAN4YTdH3SxNoUNL4RvcxCxMXXQxpJue1UW - // nonce account public key : 6qS7fCwPYCSJ6msth7h1AB6g8aGe6rro1agHAamM4rAM - // payer account public key : EjmK3LTW8oBSJp14zvQ55PMvPJCuQwRrnjd17P4vrQYo - // token account public key : Ad1xH9GUwv8AgsMvGzPmxvgKyht3u2yEseztCqQGH6aJ - // token mint public key : 876uAwedRmXAxH2uuxcDwJ49gMyCemWZUz73m2L7NZVn + // found in shared/src/test-support/resources/testcontainers/accounts + protected final String associatedTokenAccount = "4swkJXi9iwk1sRB4QAk4ZmX1WCWfpP9ButmqCfkEyaqC"; + protected final String multiSigAccount = "13SkCFWQiqAN4YTdH3SxNoUNL4RvcxCxMXXQxpJue1UW"; + protected final String nonceAccount = "6qS7fCwPYCSJ6msth7h1AB6g8aGe6rro1agHAamM4rAM"; + protected final String payerAccount = "EjmK3LTW8oBSJp14zvQ55PMvPJCuQwRrnjd17P4vrQYo"; + protected final String tokenAccount = "Ad1xH9GUwv8AgsMvGzPmxvgKyht3u2yEseztCqQGH6aJ"; + protected final String tokenMintAccount = "876uAwedRmXAxH2uuxcDwJ49gMyCemWZUz73m2L7NZVn"; protected SolanaApi api; - protected String account; @BeforeEach void moreSetup() @@ -28,12 +24,5 @@ void moreSetup() api = new SolanaJsonRpcClient(rpcUrl, true); Waiter.waitFor(Condition.isTrue(() -> api.getSlot() > 35)); - - final var testKeyPair = TestKeyPairGenerator.generateSolanaKeyPair(); - account = testKeyPair.getPublicKeyBase58(); - - api.requestAirdrop(testKeyPair.getPublicKeyBase58(), new Sol(BigDecimal.ONE).lamports()); - - Waiter.waitFor(Condition.isEqualTo(1000000000L, () -> api.getBalance(account))); } } diff --git a/client/src/main/java/com/lmax/solana4j/client/api/AccountInfo.java b/client/src/main/java/com/lmax/solana4j/client/api/AccountInfo.java index 524f56cb..6253c81c 100644 --- a/client/src/main/java/com/lmax/solana4j/client/api/AccountInfo.java +++ b/client/src/main/java/com/lmax/solana4j/client/api/AccountInfo.java @@ -49,7 +49,7 @@ public interface AccountInfo * * @return the rent epoch number */ - long getRentEpoch(); + String getRentEpoch(); /** * Returns the amount of space, in bytes, allocated to the account. diff --git a/client/src/main/java/com/lmax/solana4j/client/api/AccountInfoParsedData.java b/client/src/main/java/com/lmax/solana4j/client/api/AccountInfoParsedData.java index c7c60e11..54426227 100644 --- a/client/src/main/java/com/lmax/solana4j/client/api/AccountInfoParsedData.java +++ b/client/src/main/java/com/lmax/solana4j/client/api/AccountInfoParsedData.java @@ -75,5 +75,5 @@ public interface AccountInfoParsedData * * @return the rent epoch number */ - long getRentEpoch(); + String getRentEpoch(); } \ No newline at end of file diff --git a/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoDTO.java b/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoDTO.java index e1d3058d..c84aada0 100644 --- a/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoDTO.java +++ b/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoDTO.java @@ -49,9 +49,9 @@ static final class AccountInfoValueDTO implements AccountInfo { private final long lamports; private final String owner; - private final List data; // Base64 encoded + private final List data; private final boolean executable; - private final long rentEpoch; + private final String rentEpoch; private final int space; @JsonCreator @@ -67,9 +67,7 @@ static final class AccountInfoValueDTO implements AccountInfo this.owner = owner; this.data = unmodifiableList(data); this.executable = executable; - // TODO: suspicious - // solana rpc uses unsigned longs which can overflow javas long object, this is a small workaround - this.rentEpoch = Long.parseUnsignedLong(rentEpoch) < 0 ? 0 : Long.parseLong(rentEpoch); + this.rentEpoch = rentEpoch; this.space = space; } @@ -98,7 +96,7 @@ public boolean isExecutable() } @Override - public long getRentEpoch() + public String getRentEpoch() { return rentEpoch; } diff --git a/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoParsedDataDTO.java b/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoParsedDataDTO.java index 605a9cfe..d41c8894 100644 --- a/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoParsedDataDTO.java +++ b/client/src/main/java/com/lmax/solana4j/client/jsonrpc/AccountInfoParsedDataDTO.java @@ -47,9 +47,9 @@ static final class AccountInfoValueParsedDataDTO implements AccountInfoParsedDat { private final long lamports; private final String owner; - private final Map data; // JSON encoded + private final Map data; private final boolean executable; - private final long rentEpoch; + private final String rentEpoch; @JsonCreator AccountInfoValueParsedDataDTO( @@ -63,8 +63,7 @@ static final class AccountInfoValueParsedDataDTO implements AccountInfoParsedDat this.owner = owner; this.data = data; this.executable = executable; - // Solana rpc uses unsigned longs which can overflow javas long object, this is a small workaround - this.rentEpoch = Long.parseUnsignedLong(rentEpoch) < 0 ? 0 : Long.parseLong(rentEpoch); + this.rentEpoch = rentEpoch; } @Override @@ -115,7 +114,7 @@ public boolean isExecutable() } @Override - public long getRentEpoch() + public String getRentEpoch() { return rentEpoch; }