-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from onflow/get-node-version-info-protobuf-sc…
…hema #107/ Update GetNodeVersionInfo response object
- Loading branch information
Showing
23 changed files
with
1,876 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ build | |
sdk/gradle.properties | ||
flowdb | ||
.DS_Store | ||
.kotlin/errors |
23 changes: 23 additions & 0 deletions
23
...ava/org/onflow/examples/java/getNodeVersionInfo/GetNodeVersionInfoAccessAPIConnector.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,23 @@ | ||
package org.onflow.examples.java.getNodeVersionInfo; | ||
|
||
import org.onflow.flow.sdk.FlowAccessApi; | ||
import org.onflow.flow.sdk.FlowNodeVersionInfo; | ||
|
||
public class GetNodeVersionInfoAccessAPIConnector { | ||
private final FlowAccessApi accessAPI; | ||
|
||
public GetNodeVersionInfoAccessAPIConnector(FlowAccessApi accessAPI) { | ||
this.accessAPI = accessAPI; | ||
} | ||
|
||
public FlowNodeVersionInfo getNodeVersionInfo() { | ||
FlowAccessApi.AccessApiCallResponse<FlowNodeVersionInfo> response = accessAPI.getNodeVersionInfo(); | ||
if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { | ||
return ((FlowAccessApi.AccessApiCallResponse.Success<FlowNodeVersionInfo>) response).getData(); | ||
} else { | ||
FlowAccessApi.AccessApiCallResponse.Error errorResponse = (FlowAccessApi.AccessApiCallResponse.Error) response; | ||
throw new RuntimeException(errorResponse.getMessage(), errorResponse.getThrowable()); | ||
} | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
...org/onflow/examples/java/getNodeVersionInfo/GetNodeVersionInfoAccessAPIConnectorTest.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.onflow.examples.java.getNodeVersionInfo; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.onflow.flow.common.test.FlowEmulatorProjectTest; | ||
import org.onflow.flow.common.test.FlowTestClient; | ||
import org.onflow.flow.sdk.FlowAccessApi; | ||
import org.onflow.flow.sdk.FlowNodeVersionInfo; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@FlowEmulatorProjectTest(flowJsonLocation = "../flow/flow.json") | ||
public class GetNodeVersionInfoAccessAPIConnectorTest { | ||
@FlowTestClient | ||
private FlowAccessApi accessAPI; | ||
private GetNodeVersionInfoAccessAPIConnector nodeVersionInfoConnector; | ||
@BeforeEach | ||
public void setup() { | ||
nodeVersionInfoConnector = new GetNodeVersionInfoAccessAPIConnector(accessAPI); | ||
} | ||
|
||
@Test | ||
public void canFetchNodeVersionInfo() { | ||
FlowNodeVersionInfo nodeVersionInfo = nodeVersionInfoConnector.getNodeVersionInfo(); | ||
assertNotNull(nodeVersionInfo, "Node version info should not be null"); | ||
assertEquals(nodeVersionInfo.getProtocolVersion(), 0); | ||
assertEquals(nodeVersionInfo.getSporkRootBlockHeight(), 0); | ||
assertEquals(nodeVersionInfo.getNodeRootBlockHeight(), 0); | ||
assertNull(nodeVersionInfo.getCompatibleRange()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...lin/org/onflow/examples/kotlin/getNodeVersionInfo/GetNodeVersionInfoAccessAPIConnector.kt
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,14 @@ | ||
package org.onflow.examples.kotlin.getNodeVersionInfo | ||
|
||
import org.onflow.flow.sdk.FlowAccessApi | ||
import org.onflow.flow.sdk.FlowNodeVersionInfo | ||
|
||
internal class GetNodeVersionInfoAccessAPIConnector( | ||
private val accessAPI: FlowAccessApi | ||
) { | ||
fun getNodeVersionInfo(): FlowNodeVersionInfo = | ||
when (val response = accessAPI.getNodeVersionInfo()) { | ||
is FlowAccessApi.AccessApiCallResponse.Success -> response.data | ||
is FlowAccessApi.AccessApiCallResponse.Error -> throw Exception(response.message, response.throwable) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...org/onflow/examples/kotlin/getNodeVersionInfo/GetNodeVersionInfoAccessAPIConnectorTest.kt
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,32 @@ | ||
package org.onflow.examples.kotlin.getNodeVersionInfo | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.onflow.flow.common.test.FlowEmulatorProjectTest | ||
import org.onflow.flow.common.test.FlowTestClient | ||
import org.onflow.flow.sdk.FlowAccessApi | ||
import org.onflow.flow.sdk.FlowNodeVersionInfo | ||
|
||
@FlowEmulatorProjectTest(flowJsonLocation = "../flow/flow.json") | ||
internal class GetNodeVersionInfoAccessAPIConnectorTest { | ||
@FlowTestClient | ||
lateinit var accessAPI: FlowAccessApi | ||
|
||
private lateinit var nodeVersionInfoConnector: GetNodeVersionInfoAccessAPIConnector | ||
|
||
@BeforeEach | ||
fun setup() { | ||
nodeVersionInfoConnector = GetNodeVersionInfoAccessAPIConnector(accessAPI) | ||
} | ||
|
||
@Test | ||
fun `Can fetch node version info`() { | ||
val nodeVersionInfo: FlowNodeVersionInfo = nodeVersionInfoConnector.getNodeVersionInfo() | ||
assertNotNull(nodeVersionInfo, "Node version info should not be null") | ||
assertEquals(nodeVersionInfo.protocolVersion, 0) | ||
assertEquals(nodeVersionInfo.sporkRootBlockHeight, 0) | ||
assertEquals(nodeVersionInfo.nodeRootBlockHeight, 0) | ||
assertEquals(nodeVersionInfo.compatibleRange, null) | ||
} | ||
} |
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
Oops, something went wrong.