forked from corda/corda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests to make sure the platform version is correctly available
1 parent
2ceb628
commit 4ca54b7
Showing
12 changed files
with
125 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
gradlePluginsVersion=2.0.9 | ||
kotlinVersion=1.1.60 | ||
platformVersion=2 | ||
guavaVersion=21.0 | ||
bouncycastleVersion=1.57 | ||
typesafeConfigVersion=1.3.1 |
75 changes: 75 additions & 0 deletions
75
core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.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,75 @@ | ||
package net.corda.core | ||
|
||
import co.paralleluniverse.fibers.Suspendable | ||
import net.corda.core.flows.FlowLogic | ||
import net.corda.core.flows.StartableByRPC | ||
import net.corda.core.identity.CordaX500Name | ||
import net.corda.core.internal.* | ||
import net.corda.core.messaging.startFlow | ||
import net.corda.core.utilities.getOrThrow | ||
import net.corda.nodeapi.User | ||
import net.corda.smoketesting.NodeConfig | ||
import net.corda.smoketesting.NodeProcess | ||
import net.corda.testing.common.internal.ProjectStructure | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import java.nio.file.Paths | ||
import java.util.* | ||
import java.util.concurrent.atomic.AtomicInteger | ||
import java.util.jar.JarFile | ||
import kotlin.streams.toList | ||
|
||
class NodeVersioningTest { | ||
private companion object { | ||
val user = User("user1", "test", permissions = setOf("ALL")) | ||
val port = AtomicInteger(15100) | ||
|
||
val expectedPlatformVersion = (ProjectStructure.projectRootDir / "constants.properties").read { | ||
val constants = Properties() | ||
constants.load(it) | ||
constants.getProperty("platformVersion").toInt() | ||
} | ||
} | ||
|
||
private val factory = NodeProcess.Factory() | ||
|
||
private val aliceConfig = NodeConfig( | ||
legalName = CordaX500Name(organisation = "Alice Corp", locality = "Madrid", country = "ES"), | ||
p2pPort = port.andIncrement, | ||
rpcPort = port.andIncrement, | ||
webPort = port.andIncrement, | ||
isNotary = false, | ||
users = listOf(user) | ||
) | ||
|
||
@Test | ||
fun `platform version in manifest file`() { | ||
val manifest = JarFile(factory.cordaJar.toFile()).manifest | ||
assertThat(manifest.mainAttributes.getValue("Corda-Platform-Version").toInt()).isEqualTo(expectedPlatformVersion) | ||
} | ||
|
||
@Test | ||
fun `platform version from RPC`() { | ||
val cordappsDir = (factory.baseDirectory(aliceConfig) / NodeProcess.CORDAPPS_DIR_NAME).createDirectories() | ||
// Find the jar file for the smoke tests of this module | ||
val selfCordapp = Paths.get("build", "libs").list { | ||
it.filter { "-smokeTests" in it.toString() }.toList().single() | ||
} | ||
selfCordapp.copyToDirectory(cordappsDir) | ||
|
||
factory.create(aliceConfig).use { alice -> | ||
alice.connect().use { | ||
val rpc = it.proxy | ||
assertThat(rpc.protocolVersion).isEqualTo(expectedPlatformVersion) | ||
assertThat(rpc.nodeInfo().platformVersion).isEqualTo(expectedPlatformVersion) | ||
assertThat(rpc.startFlow(NodeVersioningTest::GetPlatformVersionFlow).returnValue.getOrThrow()).isEqualTo(expectedPlatformVersion) | ||
} | ||
} | ||
} | ||
|
||
@StartableByRPC | ||
class GetPlatformVersionFlow : FlowLogic<Int>() { | ||
@Suspendable | ||
override fun call(): Int = serviceHub.myInfo.platformVersion | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...lin/net/corda/testing/ProjectStructure.kt → ...sting/common/internal/ProjectStructure.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