From bffac331a37666415b91c0780d811669885a5d48 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Fri, 5 Oct 2018 09:28:00 +0100 Subject: [PATCH] Moved the PLATFORM_VERSION constant to core and added some missing usages (#4026) --- build.gradle | 1 - .../net/corda/client/rpc/CordaRPCClient.kt | 2 +- constants.properties | 6 ++++-- .../kotlin/net/corda/core/internal/CordaUtils.kt | 2 ++ .../kotlin/net/corda/core/NodeVersioningTest.kt | 16 ++++------------ .../corda/nodeapi/internal/NodeInfoConstants.kt | 1 - .../internal/network/NetworkBootstrapperTest.kt | 2 +- .../node/services/AttachmentLoadingTests.kt | 1 - .../main/kotlin/net/corda/node/VersionInfo.kt | 2 +- .../net/corda/node/internal/NodeStartup.kt | 2 +- .../internal/cordapp/CordappProviderImplTests.kt | 1 - .../net/corda/testing/node/MockServices.kt | 2 -- .../corda/testing/node/internal/DriverDSLImpl.kt | 4 +--- .../testing/node/internal/InternalMockNetwork.kt | 2 +- .../corda/testing/node/internal/NodeBasedTest.kt | 9 +++++---- .../main/kotlin/net/corda/bootstrapper/Main.kt | 2 +- 16 files changed, 22 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index 233c8be5c1..36872b5fef 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ buildscript { // Our version: bump this on release. ext.corda_release_version = "4.0-SNAPSHOT" - // Increment this on any release that changes public APIs anywhere in the Corda platform ext.corda_platform_version = constants.getProperty("platformVersion") ext.gradle_plugins_version = constants.getProperty("gradlePluginsVersion") diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt index 116e6baf84..db445caa55 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt @@ -13,7 +13,7 @@ import net.corda.core.utilities.days import net.corda.core.utilities.minutes import net.corda.core.utilities.seconds import net.corda.nodeapi.internal.ArtemisTcpTransport.Companion.rpcConnectorTcpTransport -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION import net.corda.serialization.internal.AMQP_RPC_CLIENT_CONTEXT import java.time.Duration diff --git a/constants.properties b/constants.properties index 8d23d66503..d472994d01 100644 --- a/constants.properties +++ b/constants.properties @@ -1,7 +1,9 @@ gradlePluginsVersion=4.0.29 kotlinVersion=1.2.51 -# When adjusting platformVersion upwards please also modify CordaRPCClientConfiguration.minimumServerProtocolVersion \ -# if there have been any RPC changes. Also please modify InternalMockNetwork.kt:MOCK_VERSION_INFO and NodeBasedTest.startNode +# ***************************************************************# +# When incrementing platformVersion make sure to update # +# net.corda.core.internal.CordaUtilsKt.PLATFORM_VERSION as well. # +# ***************************************************************# platformVersion=4 guavaVersion=25.1-jre proguardVersion=6.0.3 diff --git a/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt b/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt index 35ea7158ef..c7651da4cb 100644 --- a/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt +++ b/core/src/main/kotlin/net/corda/core/internal/CordaUtils.kt @@ -17,6 +17,8 @@ import org.slf4j.MDC // *Internal* Corda-specific utilities +const val PLATFORM_VERSION = 4 + fun ServicesForResolution.ensureMinimumPlatformVersion(requiredMinPlatformVersion: Int, feature: String) { val currentMinPlatformVersion = networkParameters.minimumPlatformVersion if (currentMinPlatformVersion < requiredMinPlatformVersion) { diff --git a/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt b/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt index 20f7e8cbfd..e118fe0326 100644 --- a/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt +++ b/core/src/smoke-test/kotlin/net/corda/core/NodeVersioningTest.kt @@ -10,11 +10,9 @@ import net.corda.core.utilities.getOrThrow import net.corda.nodeapi.internal.config.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 @@ -23,12 +21,6 @@ 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() @@ -45,7 +37,7 @@ class NodeVersioningTest { @Test fun `platform version in manifest file`() { val manifest = JarFile(factory.cordaJar.toFile()).manifest - assertThat(manifest.mainAttributes.getValue("Corda-Platform-Version").toInt()).isEqualTo(expectedPlatformVersion) + assertThat(manifest.mainAttributes.getValue("Corda-Platform-Version").toInt()).isEqualTo(PLATFORM_VERSION) } @Test @@ -60,9 +52,9 @@ class NodeVersioningTest { 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) + assertThat(rpc.protocolVersion).isEqualTo(PLATFORM_VERSION) + assertThat(rpc.nodeInfo().platformVersion).isEqualTo(PLATFORM_VERSION) + assertThat(rpc.startFlow(NodeVersioningTest::GetPlatformVersionFlow).returnValue.getOrThrow()).isEqualTo(PLATFORM_VERSION) } } } diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/NodeInfoConstants.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/NodeInfoConstants.kt index 79cb6844de..371ed2cd57 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/NodeInfoConstants.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/NodeInfoConstants.kt @@ -2,4 +2,3 @@ package net.corda.nodeapi.internal // TODO: Add to Corda node.conf to allow customisation const val NODE_INFO_DIRECTORY = "additional-node-infos" -const val PLATFORM_VERSION = 4 diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapperTest.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapperTest.kt index 1871ea553f..a3ddb3cc93 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapperTest.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapperTest.kt @@ -11,7 +11,7 @@ import net.corda.core.serialization.serialize import net.corda.node.services.config.NotaryConfig import net.corda.nodeapi.internal.DEV_ROOT_CA import net.corda.nodeapi.internal.NODE_INFO_DIRECTORY -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION import net.corda.nodeapi.internal.SignedNodeInfo import net.corda.nodeapi.internal.config.parseAs import net.corda.nodeapi.internal.config.toConfig diff --git a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt index d21de023cb..b9e5029fc9 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt @@ -26,7 +26,6 @@ import net.corda.core.utilities.getOrThrow import net.corda.node.VersionInfo import net.corda.node.internal.cordapp.JarScanningCordappLoader import net.corda.node.internal.cordapp.CordappProviderImpl -import net.corda.nodeapi.internal.PLATFORM_VERSION import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.core.DUMMY_BANK_A_NAME import net.corda.testing.core.DUMMY_NOTARY_NAME diff --git a/node/src/main/kotlin/net/corda/node/VersionInfo.kt b/node/src/main/kotlin/net/corda/node/VersionInfo.kt index b3d0ec0fbb..01492ee396 100644 --- a/node/src/main/kotlin/net/corda/node/VersionInfo.kt +++ b/node/src/main/kotlin/net/corda/node/VersionInfo.kt @@ -1,6 +1,6 @@ package net.corda.node -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION /** * Encapsulates various pieces of version information of the node. diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index 74f3b0f40f..1b089a7c63 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -28,7 +28,7 @@ import net.corda.node.utilities.registration.NodeRegistrationException import net.corda.node.utilities.registration.NodeRegistrationHelper import net.corda.node.utilities.saveToKeyStore import net.corda.node.utilities.saveToTrustStore -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION import net.corda.nodeapi.internal.addShutdownHook import net.corda.nodeapi.internal.config.UnknownConfigurationKeysException import net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException diff --git a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt index d622f834f8..77d97f5715 100644 --- a/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt +++ b/node/src/test/kotlin/net/corda/node/internal/cordapp/CordappProviderImplTests.kt @@ -4,7 +4,6 @@ import com.typesafe.config.Config import com.typesafe.config.ConfigFactory import net.corda.core.node.services.AttachmentStorage import net.corda.node.VersionInfo -import net.corda.nodeapi.internal.PLATFORM_VERSION import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.internal.MockCordappConfigProvider import net.corda.testing.services.MockAttachmentStorage diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt index be91c42c1f..112cf3f19f 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt @@ -28,10 +28,8 @@ import net.corda.node.services.identity.InMemoryIdentityService import net.corda.node.services.schema.NodeSchemaService import net.corda.node.services.transactions.InMemoryTransactionVerifierService import net.corda.node.services.vault.NodeVaultService -import net.corda.nodeapi.internal.PLATFORM_VERSION import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.DatabaseConfig -import net.corda.nodeapi.internal.persistence.HibernateConfiguration import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.core.TestIdentity import net.corda.testing.internal.DEV_ROOT_CA diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index 850cf8f8d5..92615f3fd0 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -28,7 +28,7 @@ import net.corda.node.services.Permissions import net.corda.node.services.config.* import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NodeRegistrationHelper -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION import net.corda.nodeapi.internal.DevIdentityGenerator import net.corda.nodeapi.internal.SignedNodeInfo import net.corda.nodeapi.internal.addShutdownHook @@ -54,10 +54,8 @@ import net.corda.testing.node.User import net.corda.testing.node.internal.DriverDSLImpl.Companion.cordappsInCurrentAndAdditionalPackages import okhttp3.OkHttpClient import okhttp3.Request -import rx.Observable import rx.Subscription import rx.schedulers.Schedulers -import rx.subjects.AsyncSubject import java.lang.management.ManagementFactory import java.net.ConnectException import java.net.URL diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt index cebb7f6d30..9d6ce49198 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt @@ -74,7 +74,7 @@ import java.time.Clock import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicInteger -val MOCK_VERSION_INFO = VersionInfo(4, "Mock release", "Mock revision", "Mock Vendor") +val MOCK_VERSION_INFO = VersionInfo(PLATFORM_VERSION, "Mock release", "Mock revision", "Mock Vendor") data class MockNodeArgs( val config: NodeConfiguration, diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt index b21df970db..66a4f2408d 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt @@ -2,6 +2,7 @@ package net.corda.testing.node.internal import com.typesafe.config.ConfigValueFactory import net.corda.core.identity.CordaX500Name +import net.corda.core.internal.PLATFORM_VERSION import net.corda.core.internal.concurrent.fork import net.corda.core.internal.concurrent.transpose import net.corda.core.internal.createDirectories @@ -31,12 +32,12 @@ import java.nio.file.Path import java.util.concurrent.Executors import kotlin.concurrent.thread -// TODO Some of the logic here duplicates what's in the driver - the reason why it's not straightforward to replace it by using DriverDSLImpl in `init()` and `stopAllNodes()` is because of the platform version passed to nodes (driver doesn't support this, and it's a property of the Corda JAR) +// TODO Some of the logic here duplicates what's in the driver - the reason why it's not straightforward to replace it by +// using DriverDSLImpl in `init()` and `stopAllNodes()` is because of the platform version passed to nodes (driver doesn't +// support this, and it's a property of the Corda JAR) abstract class NodeBasedTest(private val cordappPackages: List = emptyList()) { companion object { private val WHITESPACE = "\\s++".toRegex() - - private val logger = loggerFor() } @Rule @@ -85,7 +86,7 @@ abstract class NodeBasedTest(private val cordappPackages: List = emptyLi @JvmOverloads fun startNode(legalName: CordaX500Name, - platformVersion: Int = 4, + platformVersion: Int = PLATFORM_VERSION, rpcUsers: List = emptyList(), configOverrides: Map = emptyMap()): NodeWithInfo { val baseDirectory = baseDirectory(legalName).createDirectories() diff --git a/tools/bootstrapper/src/main/kotlin/net/corda/bootstrapper/Main.kt b/tools/bootstrapper/src/main/kotlin/net/corda/bootstrapper/Main.kt index 9d382516fa..e3a1967e2e 100644 --- a/tools/bootstrapper/src/main/kotlin/net/corda/bootstrapper/Main.kt +++ b/tools/bootstrapper/src/main/kotlin/net/corda/bootstrapper/Main.kt @@ -2,7 +2,7 @@ package net.corda.bootstrapper import net.corda.cliutils.CordaCliWrapper import net.corda.cliutils.start -import net.corda.nodeapi.internal.PLATFORM_VERSION +import net.corda.core.internal.PLATFORM_VERSION import net.corda.nodeapi.internal.network.NetworkBootstrapper import picocli.CommandLine.Option import java.nio.file.Path