From 8fc76b3803964448ceee5348913c39e5e1833626 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Thu, 6 Jul 2017 10:43:45 +0100 Subject: [PATCH] Moved VersionInfo out of core and into node --- .../net/corda/services/messaging/P2PSecurityTest.kt | 2 +- .../src/main/kotlin/net/corda}/node/VersionInfo.kt | 2 +- node/src/main/kotlin/net/corda/node/internal/Node.kt | 2 +- .../main/kotlin/net/corda/node/internal/NodeStartup.kt | 2 +- .../corda/node/services/messaging/NodeMessagingClient.kt | 2 +- .../node/services/messaging/ArtemisMessagingTests.kt | 4 ++-- .../services/network/PersistentNetworkMapServiceTest.kt | 5 ++--- .../src/main/kotlin/net/corda/testing/CoreTestUtils.kt | 2 -- .../src/main/kotlin/net/corda/testing/driver/Driver.kt | 9 +++++++-- .../kotlin/net/corda/testing/node/MockNetworkMapCache.kt | 5 ++--- .../src/main/kotlin/net/corda/testing/node/MockNode.kt | 2 +- .../main/kotlin/net/corda/testing/node/MockServices.kt | 8 +++++--- .../main/kotlin/net/corda/testing/node/NodeBasedTest.kt | 3 +-- .../src/main/kotlin/net/corda/testing/node/SimpleNode.kt | 1 - 14 files changed, 25 insertions(+), 24 deletions(-) rename {core/src/main/kotlin/net/corda/core => node/src/main/kotlin/net/corda}/node/VersionInfo.kt (91%) diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt index a5789b3b7b..3df678b855 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt @@ -67,7 +67,7 @@ class P2PSecurityTest : NodeBasedTest() { private fun SimpleNode.registerWithNetworkMap(registrationName: X500Name): ListenableFuture { val legalIdentity = getTestPartyAndCertificate(registrationName, identity.public) - val nodeInfo = NodeInfo(listOf(MOCK_HOST_AND_PORT), legalIdentity, setOf(legalIdentity), MOCK_VERSION_INFO.platformVersion) + val nodeInfo = NodeInfo(listOf(MOCK_HOST_AND_PORT), legalIdentity, setOf(legalIdentity), 1) val registration = NodeRegistration(nodeInfo, System.currentTimeMillis(), AddOrRemove.ADD, Instant.MAX) val request = RegistrationRequest(registration.toWire(keyService, identity.public), network.myAddress) return network.sendRequest(NetworkMapService.REGISTER_TOPIC, request, networkMapNode.network.myAddress) diff --git a/core/src/main/kotlin/net/corda/core/node/VersionInfo.kt b/node/src/main/kotlin/net/corda/node/VersionInfo.kt similarity index 91% rename from core/src/main/kotlin/net/corda/core/node/VersionInfo.kt rename to node/src/main/kotlin/net/corda/node/VersionInfo.kt index f072eafe04..c51df32229 100644 --- a/core/src/main/kotlin/net/corda/core/node/VersionInfo.kt +++ b/node/src/main/kotlin/net/corda/node/VersionInfo.kt @@ -1,4 +1,4 @@ -package net.corda.core.node +package net.corda.node /** * Encapsulates various pieces of version information of the node. diff --git a/node/src/main/kotlin/net/corda/node/internal/Node.kt b/node/src/main/kotlin/net/corda/node/internal/Node.kt index 993fe6391b..871bdd6307 100644 --- a/node/src/main/kotlin/net/corda/node/internal/Node.kt +++ b/node/src/main/kotlin/net/corda/node/internal/Node.kt @@ -9,12 +9,12 @@ import net.corda.core.flatMap import net.corda.core.messaging.RPCOps import net.corda.core.minutes import net.corda.core.node.ServiceHub -import net.corda.core.node.VersionInfo import net.corda.core.node.services.ServiceInfo import net.corda.core.seconds import net.corda.core.success import net.corda.core.utilities.loggerFor import net.corda.core.utilities.trace +import net.corda.node.VersionInfo import net.corda.node.serialization.NodeClock import net.corda.node.services.RPCUserService import net.corda.node.services.RPCUserServiceImpl 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 2251244e0b..b9824e7c6d 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -6,7 +6,7 @@ import joptsimple.OptionException import net.corda.core.* import net.corda.core.crypto.commonName import net.corda.core.crypto.orgName -import net.corda.core.node.VersionInfo +import net.corda.node.VersionInfo import net.corda.core.node.services.ServiceInfo import net.corda.core.utilities.Emoji import net.corda.core.utilities.loggerFor diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt b/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt index d3773f68b7..56afb69dd3 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt @@ -7,13 +7,13 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.MessageRecipients import net.corda.core.messaging.RPCOps import net.corda.core.messaging.SingleMessageRecipient -import net.corda.core.node.VersionInfo import net.corda.core.node.services.PartyInfo import net.corda.core.node.services.TransactionVerifierService import net.corda.core.serialization.opaque import net.corda.core.transactions.LedgerTransaction import net.corda.core.utilities.loggerFor import net.corda.core.utilities.trace +import net.corda.node.VersionInfo import net.corda.node.services.RPCUserService import net.corda.node.services.api.MonitoringService import net.corda.node.services.config.NodeConfiguration diff --git a/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt b/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt index de4aaf1c0f..4a4a0cc7e3 100644 --- a/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTests.kt @@ -8,7 +8,6 @@ import com.google.common.util.concurrent.SettableFuture import net.corda.core.crypto.generateKeyPair import net.corda.core.messaging.RPCOps import net.corda.core.node.services.DEFAULT_SESSION_ID -import net.corda.testing.ALICE import net.corda.core.utilities.LogHelper import net.corda.node.services.RPCUserService import net.corda.node.services.RPCUserServiceImpl @@ -21,9 +20,10 @@ import net.corda.node.services.transactions.PersistentUniquenessProvider import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor import net.corda.node.utilities.configureDatabase import net.corda.node.utilities.transaction -import net.corda.testing.MOCK_VERSION_INFO +import net.corda.testing.ALICE import net.corda.testing.freeLocalHostAndPort import net.corda.testing.freePort +import net.corda.testing.node.MOCK_VERSION_INFO import net.corda.testing.node.makeTestDataSourceProperties import net.corda.testing.testNodeConfiguration import org.assertj.core.api.Assertions.assertThat diff --git a/node/src/test/kotlin/net/corda/node/services/network/PersistentNetworkMapServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/network/PersistentNetworkMapServiceTest.kt index 2a3a8fd3b2..c5af8af7ae 100644 --- a/node/src/test/kotlin/net/corda/node/services/network/PersistentNetworkMapServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/network/PersistentNetworkMapServiceTest.kt @@ -5,7 +5,6 @@ import net.corda.core.node.services.ServiceInfo import net.corda.node.services.api.ServiceHubInternal import net.corda.node.services.config.NodeConfiguration import net.corda.node.utilities.transaction -import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode import java.math.BigInteger @@ -49,11 +48,11 @@ class PersistentNetworkMapServiceTest : AbstractNetworkMapServiceTest get() = listOf(MEGA_CORP_KEY, MINI_CORP_KEY, AL val MOCK_IDENTITIES = listOf(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, DUMMY_NOTARY_IDENTITY) val MOCK_IDENTITY_SERVICE: IdentityService get() = InMemoryIdentityService(MOCK_IDENTITIES, emptyMap(), DUMMY_CA.certificate.cert) -val MOCK_VERSION_INFO = VersionInfo(1, "Mock release", "Mock revision", "Mock Vendor") val MOCK_HOST_AND_PORT = HostAndPort.fromParts("mockHost", 30000) fun generateStateRef() = StateRef(SecureHash.randomSHA256(), 0) diff --git a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt index 36d496d187..3d21d4c827 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -20,7 +20,8 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.node.NodeInfo import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType -import net.corda.core.utilities.* +import net.corda.core.utilities.WHITESPACE +import net.corda.core.utilities.loggerFor import net.corda.node.internal.Node import net.corda.node.internal.NodeStartup import net.corda.node.serialization.NodeClock @@ -34,7 +35,11 @@ import net.corda.nodeapi.User import net.corda.nodeapi.config.SSLConfiguration import net.corda.nodeapi.config.parseAs import net.corda.nodeapi.internal.addShutdownHook -import net.corda.testing.* +import net.corda.testing.ALICE +import net.corda.testing.BOB +import net.corda.testing.DUMMY_BANK_A +import net.corda.testing.DUMMY_NOTARY +import net.corda.testing.node.MOCK_VERSION_INFO import okhttp3.OkHttpClient import okhttp3.Request import org.bouncycastle.asn1.x500.X500Name diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt index 36a72e77f0..c4de528dd1 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt @@ -8,7 +8,6 @@ import net.corda.core.node.NodeInfo import net.corda.core.node.ServiceHub import net.corda.core.node.services.NetworkMapCache import net.corda.node.services.network.InMemoryNetworkMapCache -import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.getTestPartyAndCertificate import net.corda.testing.getTestX509Name import rx.Observable @@ -29,8 +28,8 @@ class MockNetworkMapCache(serviceHub: ServiceHub) : InMemoryNetworkMapCache(serv override val changed: Observable = PublishSubject.create() init { - val mockNodeA = NodeInfo(listOf(BANK_C_ADDR), BANK_C, setOf(BANK_C), MOCK_VERSION_INFO.platformVersion) - val mockNodeB = NodeInfo(listOf(BANK_D_ADDR), BANK_D, setOf(BANK_D), MOCK_VERSION_INFO.platformVersion) + val mockNodeA = NodeInfo(listOf(BANK_C_ADDR), BANK_C, setOf(BANK_C), 1) + val mockNodeB = NodeInfo(listOf(BANK_D_ADDR), BANK_D, setOf(BANK_D), 1) registeredNodes[mockNodeA.legalIdentity.owningKey] = mockNodeA registeredNodes[mockNodeB.legalIdentity.owningKey] = mockNodeB runWithoutMapService() diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt index 2d57e1f06e..05f3c115be 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -144,7 +144,7 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false, AbstractNode(config, advertisedServices, TestClock(), mockNet.busyLatch) { var counter = entropyRoot override val log: Logger = loggerFor() - override val platformVersion: Int get() = MOCK_VERSION_INFO.platformVersion + override val platformVersion: Int get() = 1 override val serverThread: AffinityExecutor = if (mockNet.threadPerNode) ServiceAffinityExecutor("Mock node $id thread", 1) diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt index 5422973d68..804e8520b7 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt @@ -12,8 +12,8 @@ import net.corda.core.node.services.* import net.corda.core.serialization.SerializeAsToken import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.transactions.SignedTransaction -import net.corda.testing.DUMMY_CA import net.corda.flows.AnonymisedIdentity +import net.corda.node.VersionInfo import net.corda.node.services.api.StateMachineRecordedTransactionMappingStorage import net.corda.node.services.api.WritableTransactionStorage import net.corda.node.services.database.HibernateConfiguration @@ -25,9 +25,9 @@ import net.corda.node.services.schema.HibernateObserver import net.corda.node.services.schema.NodeSchemaService import net.corda.node.services.transactions.InMemoryTransactionVerifierService import net.corda.node.services.vault.NodeVaultService +import net.corda.testing.DUMMY_CA import net.corda.testing.MEGA_CORP import net.corda.testing.MOCK_IDENTITIES -import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.getTestPartyAndCertificate import org.bouncycastle.operator.ContentSigner import rx.Observable @@ -76,7 +76,7 @@ open class MockServices(vararg val keys: KeyPair) : ServiceHub { override val clock: Clock get() = Clock.systemUTC() override val myInfo: NodeInfo get() { val identity = getTestPartyAndCertificate(MEGA_CORP.name, key.public) - return NodeInfo(listOf(HostAndPort.fromHost("localhost")), identity, setOf(identity), MOCK_VERSION_INFO.platformVersion) + return NodeInfo(listOf(HostAndPort.fromHost("localhost")), identity, setOf(identity), 1) } override val transactionVerifierService: TransactionVerifierService get() = InMemoryTransactionVerifierService(2) @@ -195,3 +195,5 @@ fun makeTestDataSourceProperties(nodeName: String = SecureHash.randomSHA256().to props.setProperty("dataSource.password", "") return props } + +val MOCK_VERSION_INFO = VersionInfo(1, "Mock release", "Mock revision", "Mock Vendor") diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt index f8f71c8277..81b11bd7fc 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt @@ -9,7 +9,6 @@ import net.corda.core.crypto.appendToCommonName import net.corda.core.crypto.commonName import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType -import net.corda.testing.DUMMY_MAP import net.corda.core.utilities.WHITESPACE import net.corda.node.internal.Node import net.corda.node.serialization.NodeClock @@ -21,7 +20,7 @@ import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.utilities.ServiceIdentityGenerator import net.corda.nodeapi.User import net.corda.nodeapi.config.parseAs -import net.corda.testing.MOCK_VERSION_INFO +import net.corda.testing.DUMMY_MAP import net.corda.testing.driver.addressMustNotBeBoundFuture import net.corda.testing.getFreeLocalPorts import org.apache.logging.log4j.Level diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/SimpleNode.kt b/test-utils/src/main/kotlin/net/corda/testing/node/SimpleNode.kt index 6731e35c5c..2527ae8e0b 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/SimpleNode.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/SimpleNode.kt @@ -19,7 +19,6 @@ import net.corda.node.services.network.InMemoryNetworkMapCache import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor import net.corda.node.utilities.configureDatabase import net.corda.node.utilities.transaction -import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.freeLocalHostAndPort import org.jetbrains.exposed.sql.Database import java.io.Closeable