-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Soroban PRC's
getVersionInfo
API. (#645)
- Loading branch information
Showing
20 changed files
with
170 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/org/stellar/sdk/responses/sorobanrpc/GetVersionInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.stellar.sdk.responses.sorobanrpc; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Value; | ||
|
||
/** | ||
* Response for JSON-RPC method getNetwork. | ||
* | ||
* @see <a href="https://developers.stellar.org/docs/data/rpc/api-reference/methods/getVersionInfo" | ||
* target="_blank">getNetwork documentation</a> | ||
*/ | ||
@AllArgsConstructor | ||
@Value | ||
public class GetVersionInfoResponse { | ||
String version; | ||
|
||
String commitHash; | ||
|
||
String buildTimestamp; | ||
|
||
String captiveCoreVersion; | ||
|
||
Integer protocolVersion; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/java/org/stellar/sdk/responses/sorobanrpc/GetVersionInfoDeserializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.stellar.sdk.responses.sorobanrpc; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import com.google.gson.reflect.TypeToken; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import org.junit.Test; | ||
import org.stellar.sdk.responses.gson.GsonSingleton; | ||
|
||
public class GetVersionInfoDeserializerTest { | ||
@Test | ||
public void testDeserialize() throws IOException { | ||
String filePath = "src/test/resources/responses/sorobanrpc/get_version_info.json"; | ||
String json = new String(Files.readAllBytes(Paths.get(filePath))); | ||
SorobanRpcResponse<GetVersionInfoResponse> getVersionInfoResponse = | ||
GsonSingleton.getInstance() | ||
.fromJson( | ||
json, new TypeToken<SorobanRpcResponse<GetVersionInfoResponse>>() {}.getType()); | ||
assertEquals(getVersionInfoResponse.getResult().getVersion(), "21.1.0"); | ||
assertEquals( | ||
getVersionInfoResponse.getResult().getCommitHash(), | ||
"fcd2f0523f04279bae4502f3e3fa00ca627e6f6a"); | ||
assertEquals(getVersionInfoResponse.getResult().getBuildTimestamp(), "2024-05-10T11:18:38"); | ||
assertEquals( | ||
getVersionInfoResponse.getResult().getCaptiveCoreVersion(), | ||
"stellar-core 21.0.0.rc2 (c6f474133738ae5f6d11b07963ca841909210273)"); | ||
assertEquals(getVersionInfoResponse.getResult().getProtocolVersion().intValue(), 21); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/resources/responses/sorobanrpc/get_version_info.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": "198cb1a8-9104-4446-a269-88bf000c2721", | ||
"result": { | ||
"version": "21.1.0", | ||
"commitHash": "fcd2f0523f04279bae4502f3e3fa00ca627e6f6a", | ||
"buildTimestamp": "2024-05-10T11:18:38", | ||
"captiveCoreVersion": "stellar-core 21.0.0.rc2 (c6f474133738ae5f6d11b07963ca841909210273)", | ||
"protocolVersion": 21 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": "198cb1a8-9104-4446-a269-88bf000c2721", | ||
"result": { | ||
"version": "21.1.0", | ||
"commitHash": "fcd2f0523f04279bae4502f3e3fa00ca627e6f6a", | ||
"buildTimestamp": "2024-05-10T11:18:38", | ||
"captiveCoreVersion": "stellar-core 21.0.0.rc2 (c6f474133738ae5f6d11b07963ca841909210273)", | ||
"protocolVersion": 21 | ||
} | ||
} |