Minor changes to bring in-sync with OS (#1390)

This commit is contained in:
Shams Asari 2018-09-13 12:53:06 +01:00 committed by GitHub
parent 9255866f10
commit 725441b39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 52 additions and 184 deletions

View File

@ -286,15 +286,6 @@ class CordaRPCClient private constructor(
): CordaRPCClient { ): CordaRPCClient {
return CordaRPCClient(hostAndPort, configuration, sslConfiguration, classLoader) return CordaRPCClient(hostAndPort, configuration, sslConfiguration, classLoader)
} }
internal fun createWithSslAndClassLoader(
haAddressPool: List<NetworkHostAndPort>,
configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT,
sslConfiguration: ClientRpcSslOptions? = null,
classLoader: ClassLoader? = null
): CordaRPCClient {
return CordaRPCClient(haAddressPool.first(), configuration, sslConfiguration, classLoader, haAddressPool)
}
} }
init { init {
@ -311,7 +302,7 @@ class CordaRPCClient private constructor(
private fun getRpcClient(): RPCClient<CordaRPCOps> { private fun getRpcClient(): RPCClient<CordaRPCOps> {
return when { return when {
// Client->RPC broker // Client->RPC broker
haAddressPool.isEmpty() -> RPCClient( haAddressPool.isEmpty() -> RPCClient(
rpcConnectorTcpTransport(hostAndPort, config = sslConfiguration), rpcConnectorTcpTransport(hostAndPort, config = sslConfiguration),
configuration, configuration,

View File

@ -16,13 +16,6 @@ fun createCordaRPCClientWithSslAndClassLoader(
classLoader: ClassLoader? = null classLoader: ClassLoader? = null
) = CordaRPCClient.createWithSslAndClassLoader(hostAndPort, configuration, sslConfiguration, classLoader) ) = CordaRPCClient.createWithSslAndClassLoader(hostAndPort, configuration, sslConfiguration, classLoader)
fun createCordaRPCClientWithSslAndClassLoader(
haAddressPool: List<NetworkHostAndPort>,
configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT,
sslConfiguration: ClientRpcSslOptions? = null,
classLoader: ClassLoader? = null
) = CordaRPCClient.createWithSslAndClassLoader(haAddressPool, configuration, sslConfiguration, classLoader)
fun CordaRPCOps.drainAndShutdown(): Observable<Unit> { fun CordaRPCOps.drainAndShutdown(): Observable<Unit> {
setFlowsDrainingModeEnabled(true) setFlowsDrainingModeEnabled(true)

View File

@ -480,7 +480,7 @@ class RPCClientProxyHandler(
try { try {
Thread.sleep(retryInterval.toMillis()) Thread.sleep(retryInterval.toMillis())
} catch (e: InterruptedException) {} } catch (e: InterruptedException) {}
// could not connect, try with next server transport // Could not connect, try with next server transport.
reconnectAttempts-- reconnectAttempts--
retryInterval = minOf(maxRetryInterval, retryInterval.times(rpcConfiguration.connectionRetryIntervalMultiplier.toLong())) retryInterval = minOf(maxRetryInterval, retryInterval.times(rpcConfiguration.connectionRetryIntervalMultiplier.toLong()))
continue continue

View File

@ -5,7 +5,6 @@ package net.corda.core.crypto.internal
import net.corda.core.DeleteForDJVM import net.corda.core.DeleteForDJVM
import net.corda.core.crypto.CORDA_SECURE_RANDOM_ALGORITHM import net.corda.core.crypto.CORDA_SECURE_RANDOM_ALGORITHM
import net.corda.core.crypto.DummySecureRandom import net.corda.core.crypto.DummySecureRandom
import net.corda.core.internal.VisibleForTesting
import net.corda.core.utilities.SgxSupport import net.corda.core.utilities.SgxSupport
import java.security.SecureRandom import java.security.SecureRandom
@ -13,7 +12,6 @@ import java.security.SecureRandom
* This has been migrated into a separate class so that it * This has been migrated into a separate class so that it
* is easier to delete from the core-deterministic module. * is easier to delete from the core-deterministic module.
*/ */
@VisibleForTesting
internal val platformSecureRandom = when { internal val platformSecureRandom = when {
SgxSupport.isInsideEnclave -> DummySecureRandom SgxSupport.isInsideEnclave -> DummySecureRandom
else -> SecureRandom.getInstance(CORDA_SECURE_RANDOM_ALGORITHM) else -> SecureRandom.getInstance(CORDA_SECURE_RANDOM_ALGORITHM)

View File

@ -5,9 +5,6 @@ package net.corda.core.internal
import net.corda.core.DeleteForDJVM import net.corda.core.DeleteForDJVM
import net.corda.core.KeepForDJVM import net.corda.core.KeepForDJVM
import net.corda.core.crypto.* import net.corda.core.crypto.*
import net.corda.core.flows.FlowLogic
import net.corda.core.node.ServicesForResolution
import net.corda.core.schemas.MappedSchema
import net.corda.core.serialization.* import net.corda.core.serialization.*
import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.UntrustworthyData import net.corda.core.utilities.UntrustworthyData

View File

@ -50,7 +50,6 @@ abstract class TrustedAuthorityNotaryService : NotaryService() {
} }
} else throw e } else throw e
} catch (e: Exception) { } catch (e: Exception) {
if (e is NotaryInternalException) throw e
log.error("Internal error", e) log.error("Internal error", e)
throw NotaryInternalException(NotaryError.General(Exception("Service unavailable, please try again later"))) throw NotaryInternalException(NotaryError.General(Exception("Service unavailable, please try again later")))
} }

View File

@ -98,12 +98,6 @@ data class StateMachineTransactionMapping(val stateMachineRunId: StateMachineRun
/** RPC operations that the node exposes to clients. */ /** RPC operations that the node exposes to clients. */
interface CordaRPCOps : RPCOps { interface CordaRPCOps : RPCOps {
/**
* Returns the RPC protocol version, which is the same the node's Platform Version. Exists since version 1 so guaranteed
* to be present.
*/
override val protocolVersion: Int get() = nodeInfo().platformVersion
/** Returns a list of currently in-progress state machine infos. */ /** Returns a list of currently in-progress state machine infos. */
fun stateMachinesSnapshot(): List<StateMachineInfo> fun stateMachinesSnapshot(): List<StateMachineInfo>

View File

@ -47,7 +47,7 @@ open class MappedSchema(schemaFamily: Class<*>,
val name: String = schemaFamily.name val name: String = schemaFamily.name
/** /**
* Points to a classpath resource containing the database changes for the [mappedTypes] * Optional classpath resource containing the database changes for the [mappedTypes]
*/ */
open val migrationResource: String? = null open val migrationResource: String? = null

View File

@ -17,8 +17,6 @@ import net.corda.core.node.services.AttachmentId
import net.corda.core.node.services.KeyManagementService import net.corda.core.node.services.KeyManagementService
import net.corda.core.serialization.SerializationContext import net.corda.core.serialization.SerializationContext
import net.corda.core.serialization.SerializationFactory import net.corda.core.serialization.SerializationFactory
import net.corda.core.utilities.contextLogger
import net.corda.core.utilities.loggerFor
import java.security.PublicKey import java.security.PublicKey
import java.time.Duration import java.time.Duration
import java.time.Instant import java.time.Instant
@ -49,11 +47,6 @@ open class TransactionBuilder @JvmOverloads constructor(
protected var privacySalt: PrivacySalt = PrivacySalt(), protected var privacySalt: PrivacySalt = PrivacySalt(),
protected val references: MutableList<StateRef> = arrayListOf() protected val references: MutableList<StateRef> = arrayListOf()
) { ) {
private companion object {
val logger = loggerFor<TransactionBuilder>()
}
private val inputsWithTransactionState = arrayListOf<TransactionState<ContractState>>() private val inputsWithTransactionState = arrayListOf<TransactionState<ContractState>>()
private val referencesWithTransactionState = arrayListOf<TransactionState<ContractState>>() private val referencesWithTransactionState = arrayListOf<TransactionState<ContractState>>()

View File

@ -100,18 +100,6 @@ public class FlowsInJavaTest {
} }
} }
@InitiatedBy(PrimitiveReceiveFlow.class)
private static class PrimitiveSendFlow extends FlowLogic<Void> {
public PrimitiveSendFlow(FlowSession session) {
}
@Suspendable
@Override
public Void call() throws FlowException {
return null;
}
}
@InitiatingFlow @InitiatingFlow
private static class PrimitiveReceiveFlow extends FlowLogic<Void> { private static class PrimitiveReceiveFlow extends FlowLogic<Void> {
private final Party otherParty; private final Party otherParty;

View File

@ -1,9 +0,0 @@
package net.corda.behave.logging
import org.slf4j.Logger
import org.slf4j.LoggerFactory
// TODO Already available in corda core
inline fun <reified T> getLogger(): Logger =
LoggerFactory.getLogger(T::class.java)

View File

@ -1,6 +1,6 @@
package net.corda.behave.node.configuration package net.corda.behave.node.configuration
class NotaryConfiguration(val notaryType: NotaryType = NotaryType.NONE) : ConfigurationTemplate() { class NotaryConfiguration(private val notaryType: NotaryType = NotaryType.NONE) : ConfigurationTemplate() {
override val config: (Configuration) -> String override val config: (Configuration) -> String
get() = { get() = {

View File

@ -70,7 +70,9 @@ class CordaRpcWorkerOps(
private val flowReplyStateMachineRunIdMap = ConcurrentHashMap<Trace.InvocationId, SettableFuture<StateMachineRunId>>() private val flowReplyStateMachineRunIdMap = ConcurrentHashMap<Trace.InvocationId, SettableFuture<StateMachineRunId>>()
private val flowReplyResultMap = ConcurrentHashMap<Trace.InvocationId, OpenFuture<Any?>>() private val flowReplyResultMap = ConcurrentHashMap<Trace.InvocationId, OpenFuture<Any?>>()
override val networkParameters: NetworkParameters = services.networkParameters override val protocolVersion: Int get() = services.myInfo.platformVersion
override val networkParameters: NetworkParameters get() = services.networkParameters
fun start() { fun start() {
session = artemisClient.start().session session = artemisClient.start().session

View File

@ -14,11 +14,8 @@ import net.corda.finance.EUR
import net.corda.finance.GBP import net.corda.finance.GBP
import net.corda.finance.USD import net.corda.finance.USD
import net.corda.finance.flows.ConfigHolder.Companion.supportedCurrencies import net.corda.finance.flows.ConfigHolder.Companion.supportedCurrencies
import java.io.BufferedReader
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.UTF_8
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.OpenOption import java.nio.file.OpenOption
import java.nio.file.Path import java.nio.file.Path
@ -36,7 +33,6 @@ class ConfigHolder(services: AppServiceHub) : SingletonSerializeAsToken() {
private operator fun Path.div(other: String): Path = resolve(other) private operator fun Path.div(other: String): Path = resolve(other)
private operator fun String.div(other: String): Path = Paths.get(this) / other private operator fun String.div(other: String): Path = Paths.get(this) / other
private fun Path.inputStream(vararg options: OpenOption): InputStream = Files.newInputStream(this, *options) private fun Path.inputStream(vararg options: OpenOption): InputStream = Files.newInputStream(this, *options)
private fun Path.reader(charset: Charset = UTF_8): BufferedReader = Files.newBufferedReader(this, charset)
private inline fun <R> Path.read(vararg options: OpenOption, block: (InputStream) -> R): R = inputStream(*options).use(block) private inline fun <R> Path.read(vararg options: OpenOption, block: (InputStream) -> R): R = inputStream(*options).use(block)
} }

View File

@ -19,8 +19,7 @@ object CashSchema
* at the time of writing. * at the time of writing.
*/ */
@CordaSerializable @CordaSerializable
object CashSchemaV1 : MappedSchema( object CashSchemaV1 : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCashState::class.java)) {
schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCashState::class.java)) {
override val migrationResource = "cash.changelog-master" override val migrationResource = "cash.changelog-master"

View File

@ -22,8 +22,7 @@ object CommercialPaperSchema
* as it stood at the time of writing. * as it stood at the time of writing.
*/ */
@CordaSerializable @CordaSerializable
object CommercialPaperSchemaV1 : MappedSchema( object CommercialPaperSchemaV1 : MappedSchema(schemaFamily = CommercialPaperSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCommercialPaperState::class.java)) {
schemaFamily = CommercialPaperSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCommercialPaperState::class.java)) {
override val migrationResource = "commercial-paper.changelog-master" override val migrationResource = "commercial-paper.changelog-master"

View File

@ -303,4 +303,4 @@ enum class UnknownConfigKeysPolicy(private val handle: (Set<String>, logger: Log
handle.invoke(unknownKeys, logger) handle.invoke(unknownKeys, logger)
} }
} }
} }

View File

@ -105,13 +105,11 @@ class BFTNotaryServiceTests {
networkParameters.install(mockNet.baseDirectory(node.id)) networkParameters.install(mockNet.baseDirectory(node.id))
node.start() node.start()
}.last() }.last()
return Pair(notaryIdentity, node) return Pair(notaryIdentity, node)
} }
} }
@Test @Test
fun `detect double spend`() { fun `detect double spend`() {
node.run { node.run {

View File

@ -16,8 +16,8 @@ import net.corda.testing.core.DUMMY_BANK_A_NAME
import net.corda.testing.core.dummyCommand import net.corda.testing.core.dummyCommand
import net.corda.testing.core.singleIdentity import net.corda.testing.core.singleIdentity
import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.InProcess
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import net.corda.testing.driver.internal.InProcessImpl
import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTest
import net.corda.testing.internal.IntegrationTestSchemas import net.corda.testing.internal.IntegrationTestSchemas
import net.corda.testing.internal.toDatabaseSchemaName import net.corda.testing.internal.toDatabaseSchemaName
@ -45,7 +45,7 @@ class RaftNotaryServiceTests : IntegrationTest() {
extraCordappPackagesToScan = listOf("net.corda.testing.contracts"), extraCordappPackagesToScan = listOf("net.corda.testing.contracts"),
notarySpecs = listOf(NotarySpec(notaryName, cluster = ClusterSpec.Raft(clusterSize = 3))) notarySpecs = listOf(NotarySpec(notaryName, cluster = ClusterSpec.Raft(clusterSize = 3)))
)) { )) {
val bankA = startNode(providedName = DUMMY_BANK_A_NAME).map { (it as InProcessImpl) }.getOrThrow() val bankA = startNode(providedName = DUMMY_BANK_A_NAME).map { (it as InProcess) }.getOrThrow()
val inputState = issueState(bankA, defaultNotaryIdentity) val inputState = issueState(bankA, defaultNotaryIdentity)
val firstTxBuilder = TransactionBuilder(defaultNotaryIdentity) val firstTxBuilder = TransactionBuilder(defaultNotaryIdentity)
@ -78,15 +78,16 @@ class RaftNotaryServiceTests : IntegrationTest() {
extraCordappPackagesToScan = listOf("net.corda.testing.contracts"), extraCordappPackagesToScan = listOf("net.corda.testing.contracts"),
notarySpecs = listOf(NotarySpec(notaryName, cluster = ClusterSpec.Raft(clusterSize = 3))) notarySpecs = listOf(NotarySpec(notaryName, cluster = ClusterSpec.Raft(clusterSize = 3)))
)) { )) {
val bankA = startNode(providedName = DUMMY_BANK_A_NAME).map { (it as InProcessImpl) }.getOrThrow() val bankA = startNode(providedName = DUMMY_BANK_A_NAME).map { (it as InProcess) }.getOrThrow()
val builder = DummyContract.generateInitial(Random().nextInt(), defaultNotaryIdentity, bankA.services.myInfo.singleIdentity().ref(0)) val builder = DummyContract.generateInitial(Random().nextInt(), defaultNotaryIdentity, bankA.services.myInfo.singleIdentity().ref(0))
.setTimeWindow(bankA.services.clock.instant(), 30.seconds) .setTimeWindow(bankA.services.clock.instant(), 30.seconds)
val issueTx = bankA.services.signInitialTransaction(builder) val issueTx = bankA.services.signInitialTransaction(builder)
bankA.startFlow(NotaryFlow.Client(issueTx)).getOrThrow() bankA.startFlow(NotaryFlow.Client(issueTx)).getOrThrow()
} }
} }
private fun issueState(nodeHandle: InProcessImpl, notary: Party): StateAndRef<*> { private fun issueState(nodeHandle: InProcess, notary: Party): StateAndRef<*> {
val builder = DummyContract.generateInitial(Random().nextInt(), notary, nodeHandle.services.myInfo.singleIdentity().ref(0)) val builder = DummyContract.generateInitial(Random().nextInt(), notary, nodeHandle.services.myInfo.singleIdentity().ref(0))
val stx = nodeHandle.services.signInitialTransaction(builder) val stx = nodeHandle.services.signInitialTransaction(builder)
nodeHandle.services.recordTransactions(stx) nodeHandle.services.recordTransactions(stx)

View File

@ -1,6 +1,5 @@
package net.corda.node.services.transactions package net.corda.node.services.transactions
import com.typesafe.config.ConfigFactory
import io.atomix.catalyst.transport.Address import io.atomix.catalyst.transport.Address
import io.atomix.copycat.client.ConnectionStrategies import io.atomix.copycat.client.ConnectionStrategies
import io.atomix.copycat.client.CopycatClient import io.atomix.copycat.client.CopycatClient
@ -24,7 +23,6 @@ import net.corda.testing.core.SerializationEnvironmentRule
import net.corda.testing.driver.PortAllocation import net.corda.testing.driver.PortAllocation
import net.corda.testing.internal.LogHelper import net.corda.testing.internal.LogHelper
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
import net.corda.testing.node.internal.makeInternalTestDataSourceProperties
import org.hamcrest.Matchers.instanceOf import org.hamcrest.Matchers.instanceOf
import org.junit.After import org.junit.After
import org.junit.Assert.assertThat import org.junit.Assert.assertThat

View File

@ -77,11 +77,11 @@ class P2PMessagingTest : IntegrationTest() {
} }
private fun InProcess.respondWith(message: Any) { private fun InProcess.respondWith(message: Any) {
internalServices.networkService.addMessageHandler("test.request") { netMessage, _, handle -> internalServices.networkService.addMessageHandler("test.request") { netMessage, _, handler ->
val request = netMessage.data.deserialize<TestRequest>() val request = netMessage.data.deserialize<TestRequest>()
val response = internalServices.networkService.createMessage("test.response", message.serialize().bytes) val response = internalServices.networkService.createMessage("test.response", message.serialize().bytes)
internalServices.networkService.send(response, request.replyTo) internalServices.networkService.send(response, request.replyTo)
handle.afterDatabaseTransaction() handler.afterDatabaseTransaction()
} }
} }
@ -103,12 +103,12 @@ class P2PMessagingTest : IntegrationTest() {
*/ */
inline fun MessagingService.runOnNextMessage(topic: String, crossinline callback: (ReceivedMessage) -> Unit) { inline fun MessagingService.runOnNextMessage(topic: String, crossinline callback: (ReceivedMessage) -> Unit) {
val consumed = AtomicBoolean() val consumed = AtomicBoolean()
addMessageHandler(topic) { msg, reg, handle -> addMessageHandler(topic) { msg, reg, handler ->
removeMessageHandler(reg) removeMessageHandler(reg)
check(!consumed.getAndSet(true)) { "Called more than once" } check(!consumed.getAndSet(true)) { "Called more than once" }
check(msg.topic == topic) { "Topic/session mismatch: ${msg.topic} vs $topic" } check(msg.topic == topic) { "Topic/session mismatch: ${msg.topic} vs $topic" }
callback(msg) callback(msg)
handle.afterDatabaseTransaction() handler.afterDatabaseTransaction()
} }
} }

View File

@ -16,7 +16,7 @@ data class VersionInfo(
/** The node vendor */ /** The node vendor */
val vendor: String) { val vendor: String) {
companion object { companion object {
val UNKNOWN = VersionInfo(1, "Unknown", "Unknown", "Unknown") val UNKNOWN = VersionInfo(1, "Unknown", "Unknown", "Unknown")
} }
} }

View File

@ -69,7 +69,6 @@ import net.corda.node.utilities.AffinityExecutor
import net.corda.node.utilities.JVMAgentRegistry import net.corda.node.utilities.JVMAgentRegistry
import net.corda.node.utilities.NamedThreadFactory import net.corda.node.utilities.NamedThreadFactory
import net.corda.node.utilities.NodeBuildProperties import net.corda.node.utilities.NodeBuildProperties
import net.corda.nodeapi.internal.DevIdentityGenerator
import net.corda.nodeapi.internal.NodeInfoAndSigned import net.corda.nodeapi.internal.NodeInfoAndSigned
import net.corda.nodeapi.internal.SignedNodeInfo import net.corda.nodeapi.internal.SignedNodeInfo
import net.corda.nodeapi.internal.config.CertificateStore import net.corda.nodeapi.internal.config.CertificateStore

View File

@ -132,9 +132,7 @@ open class Node(configuration: NodeConfiguration,
private val sameVmNodeCounter = AtomicInteger() private val sameVmNodeCounter = AtomicInteger()
@JvmStatic private fun makeCordappLoader(configuration: NodeConfiguration, versionInfo: VersionInfo): CordappLoader {
protected fun makeCordappLoader(configuration: NodeConfiguration, versionInfo: VersionInfo): CordappLoader {
return JarScanningCordappLoader.fromDirectories(configuration.cordappDirectories, versionInfo) return JarScanningCordappLoader.fromDirectories(configuration.cordappDirectories, versionInfo)
} }

View File

@ -34,7 +34,8 @@ import kotlin.streams.toList
* *
* @property cordappJarPaths The classpath of cordapp JARs * @property cordappJarPaths The classpath of cordapp JARs
*/ */
class JarScanningCordappLoader private constructor(private val cordappJarPaths: List<RestrictedURL>, versionInfo: VersionInfo = VersionInfo.UNKNOWN) : CordappLoaderTemplate() { class JarScanningCordappLoader private constructor(private val cordappJarPaths: List<RestrictedURL>,
versionInfo: VersionInfo = VersionInfo.UNKNOWN) : CordappLoaderTemplate() {
override val cordapps: List<CordappImpl> by lazy { loadCordapps() + coreCordapp } override val cordapps: List<CordappImpl> by lazy { loadCordapps() + coreCordapp }

View File

@ -1,24 +0,0 @@
package net.corda.node.services.identity
import net.corda.core.identity.CordaX500Name
import net.corda.core.identity.Party
fun partiesFromName(query: String, exactMatch: Boolean, x500name: CordaX500Name, results: LinkedHashSet<Party>, party: Party) {
val components = listOfNotNull(x500name.commonName, x500name.organisationUnit, x500name.organisation, x500name.locality, x500name.state, x500name.country)
components.forEach { component ->
if (exactMatch && component == query) {
results += party
} else if (!exactMatch) {
// We can imagine this being a query over a lucene index in future.
//
// Kostas says: We can easily use the Jaro-Winkler distance metric as it is best suited for short
// strings such as entity/company names, and to detect small typos. We can also apply it for city
// or any keyword related search in lists of records (not raw text - for raw text we need indexing)
// and we can return results in hierarchical order (based on normalised String similarity 0.0-1.0).
if (component.contains(query, ignoreCase = true))
results += party
}
}
}

View File

@ -31,6 +31,7 @@ class AbstractPartyToX500NameAsStringConverter(private val wellKnownPartyFromX50
if (dbData != null) { if (dbData != null) {
val party = wellKnownPartyFromX500Name(CordaX500Name.parse(dbData)) val party = wellKnownPartyFromX500Name(CordaX500Name.parse(dbData))
if (party != null) return party if (party != null) return party
log.warn("Identity service unable to resolve X500name: $dbData")
} }
return null // non resolvable anonymous parties are stored as nulls return null // non resolvable anonymous parties are stored as nulls
} }

View File

@ -73,4 +73,4 @@ sealed class SubFlow {
} }
} }
} }
} }

View File

@ -169,7 +169,11 @@ class InMemoryIdentityServiceTests {
val issuerKeyPair = generateKeyPair() val issuerKeyPair = generateKeyPair()
val issuer = getTestPartyAndCertificate(x500Name, issuerKeyPair.public) val issuer = getTestPartyAndCertificate(x500Name, issuerKeyPair.public)
val txKeyPair = Crypto.generateKeyPair() val txKeyPair = Crypto.generateKeyPair()
val txCert = X509Utilities.createCertificate(CertificateType.CONFIDENTIAL_LEGAL_IDENTITY, issuer.certificate, issuerKeyPair, x500Name.x500Principal, val txCert = X509Utilities.createCertificate(
CertificateType.CONFIDENTIAL_LEGAL_IDENTITY,
issuer.certificate,
issuerKeyPair,
x500Name.x500Principal,
txKeyPair.public) txKeyPair.public)
val txCertPath = X509Utilities.buildCertPath(txCert, issuer.certPath.x509Certificates) val txCertPath = X509Utilities.buildCertPath(txCert, issuer.certPath.x509Certificates)
return Pair(issuer, PartyAndCertificate(txCertPath)) return Pair(issuer, PartyAndCertificate(txCertPath))

View File

@ -7,7 +7,6 @@ import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.getTestPartyAndCertificate import net.corda.testing.core.getTestPartyAndCertificate
import net.corda.testing.core.singleIdentity import net.corda.testing.core.singleIdentity
import net.corda.testing.node.MockNodeParameters
import net.corda.testing.node.internal.InternalMockNetwork import net.corda.testing.node.internal.InternalMockNetwork
import net.corda.testing.node.internal.InternalMockNodeParameters import net.corda.testing.node.internal.InternalMockNodeParameters
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat

View File

@ -8,7 +8,6 @@ import net.corda.core.crypto.SecureHash
import net.corda.core.identity.AbstractParty import net.corda.core.identity.AbstractParty
import net.corda.core.identity.CordaX500Name import net.corda.core.identity.CordaX500Name
import net.corda.core.node.services.Vault import net.corda.core.node.services.Vault
import net.corda.core.schemas.CommonSchemaV1
import net.corda.core.schemas.MappedSchema import net.corda.core.schemas.MappedSchema
import net.corda.core.schemas.PersistentState import net.corda.core.schemas.PersistentState
import net.corda.core.schemas.QueryableState import net.corda.core.schemas.QueryableState

View File

@ -18,11 +18,11 @@ import net.corda.finance.contracts.Commodity
import net.corda.finance.contracts.DealState import net.corda.finance.contracts.DealState
import net.corda.finance.contracts.asset.Cash import net.corda.finance.contracts.asset.Cash
import net.corda.finance.contracts.asset.cash.selection.AbstractCashSelection import net.corda.finance.contracts.asset.cash.selection.AbstractCashSelection
import net.corda.finance.schemas.SampleCashSchemaV2
import net.corda.finance.schemas.SampleCashSchemaV3
import net.corda.finance.schemas.CashSchemaV1 import net.corda.finance.schemas.CashSchemaV1
import net.corda.finance.schemas.CashSchemaV1.PersistentCashState import net.corda.finance.schemas.CashSchemaV1.PersistentCashState
import net.corda.finance.schemas.CommercialPaperSchemaV1 import net.corda.finance.schemas.CommercialPaperSchemaV1
import net.corda.finance.schemas.SampleCashSchemaV2
import net.corda.finance.schemas.SampleCashSchemaV3
import net.corda.node.internal.configureDatabase import net.corda.node.internal.configureDatabase
import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.CordaPersistence
import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.nodeapi.internal.persistence.DatabaseConfig

View File

@ -25,7 +25,6 @@ class AttachmentDemoTest : IntegrationTest() {
} }
// run with a 10,000,000 bytes in-memory zip file. In practice, a slightly bigger file will be used (~10,002,000 bytes). // run with a 10,000,000 bytes in-memory zip file. In practice, a slightly bigger file will be used (~10,002,000 bytes).
// Force INFO logging to prevent printing 10MB arrays in logfiles
@Test @Test
fun `attachment demo using a 10MB zip file`() { fun `attachment demo using a 10MB zip file`() {
val numOfExpectedBytes = 10_000_000 val numOfExpectedBytes = 10_000_000

View File

@ -14,7 +14,6 @@ import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import java.net.ConnectException import java.net.ConnectException
import java.net.URL import java.net.URL
import java.nio.file.Paths
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
fun <A> springDriver( fun <A> springDriver(

View File

@ -1,13 +1,3 @@
#
# R3 Proprietary and Confidential
#
# Copyright (c) 2018 R3 Limited. All rights reserved.
#
# The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
#
# Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
#
corda.host=localhost:10006 corda.host=localhost:10006
server.port=10007 server.port=10007
liquibase.enabled=false liquibase.enabled=false

View File

@ -1,13 +1,3 @@
#
# R3 Proprietary and Confidential
#
# Copyright (c) 2018 R3 Limited. All rights reserved.
#
# The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
#
# Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
#
corda.host=localhost:10009 corda.host=localhost:10009
server.port=10010 server.port=10010
liquibase.enabled=false liquibase.enabled=false

View File

@ -1,13 +1,3 @@
#
# R3 Proprietary and Confidential
#
# Copyright (c) 2018 R3 Limited. All rights reserved.
#
# The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
#
# Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
#
corda.host=localhost:10003 corda.host=localhost:10003
server.port=10004 server.port=10004
liquibase.enabled=false liquibase.enabled=false

View File

@ -1,13 +1,3 @@
#
# R3 Proprietary and Confidential
#
# Copyright (c) 2018 R3 Limited. All rights reserved.
#
# The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
#
# Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
#
corda.user=user corda.user=user
corda.password=password corda.password=password
liquibase.enabled=false liquibase.enabled=false

View File

@ -5,7 +5,6 @@ package net.corda.serialization.internal
import net.corda.core.DeleteForDJVM import net.corda.core.DeleteForDJVM
import net.corda.core.KeepForDJVM import net.corda.core.KeepForDJVM
import net.corda.core.serialization.* import net.corda.core.serialization.*
import net.corda.serialization.internal.CordaSerializationEncoding.SNAPPY
import net.corda.serialization.internal.amqp.amqpMagic import net.corda.serialization.internal.amqp.amqpMagic
val AMQP_P2P_CONTEXT = SerializationContextImpl( val AMQP_P2P_CONTEXT = SerializationContextImpl(

View File

@ -47,7 +47,7 @@ abstract class AbstractAMQPSerializationScheme(
constructor(cordapps: List<Cordapp>) : this(cordapps.customSerializers, AccessOrderLinkedHashMap(128)) constructor(cordapps: List<Cordapp>) : this(cordapps.customSerializers, AccessOrderLinkedHashMap(128))
// TODO: This method of initialisation for the Whitelist and plugin serializers will have to change // TODO: This method of initialisation for the Whitelist and plugin serializers will have to change
// when we have per-cordapp contexts and dynamic app reloading but for now it's the easiest way // when we have per-cordapp contexts and dynamic app reloading but for now it's the easiest way
companion object { companion object {
const val SCAN_SPEC_PROP_NAME = "amqp.custom.serialization.scanSpec" const val SCAN_SPEC_PROP_NAME = "amqp.custom.serialization.scanSpec"

View File

@ -1,4 +1,5 @@
@file:JvmName("AMQPSerializerFactories") @file:JvmName("AMQPSerializerFactories")
package net.corda.serialization.internal.amqp package net.corda.serialization.internal.amqp
import net.corda.core.serialization.SerializationContext import net.corda.core.serialization.SerializationContext

View File

@ -46,7 +46,6 @@ class EvolvabilityTests {
// Original version of the class for the serialised version of this class // Original version of the class for the serialised version of this class
// data class C (val a: Int, val b: Int) // data class C (val a: Int, val b: Int)
// File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(C(A, B)).bytes) // File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(C(A, B)).bytes)
// println (path)
// new version of the class, in this case the order of the parameters has been swapped // new version of the class, in this case the order of the parameters has been swapped
data class C(val b: Int, val a: Int) data class C(val b: Int, val a: Int)
@ -69,7 +68,6 @@ class EvolvabilityTests {
// Original version of the class as it was serialised // Original version of the class as it was serialised
// data class C (val a: Int, val b: String) // data class C (val a: Int, val b: String)
// File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(C(A, B)).bytes) // File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(C(A, B)).bytes)
// println (path)
// new version of the class, in this case the order of the parameters has been swapped // new version of the class, in this case the order of the parameters has been swapped
data class C(val b: String, val a: Int) data class C(val b: String, val a: Int)
@ -90,7 +88,7 @@ class EvolvabilityTests {
// Original version of the class as it was serialised // Original version of the class as it was serialised
// data class C(val a: Int) // data class C(val a: Int)
// File(URI("$localPath/$resource")).writeBytes( SerializationOutput(sf).serialize(C(A)) // File(URI("$localPath/$resource")).writeBytes(SerializationOutput(sf).serialize(C(A)).bytes)
data class C(val a: Int, val b: Int?) data class C(val a: Int, val b: Int?)
@ -375,6 +373,7 @@ class EvolvabilityTests {
val resource1 = "EvolvabilityTests.multiVersion.1" val resource1 = "EvolvabilityTests.multiVersion.1"
val resource2 = "EvolvabilityTests.multiVersion.2" val resource2 = "EvolvabilityTests.multiVersion.2"
val resource3 = "EvolvabilityTests.multiVersion.3" val resource3 = "EvolvabilityTests.multiVersion.3"
val a = 100 val a = 100
val b = 200 val b = 200
val c = 300 val c = 300

View File

@ -38,7 +38,7 @@ import kotlin.streams.toList
import kotlin.test.assertEquals import kotlin.test.assertEquals
class DriverTests : IntegrationTest() { class DriverTests : IntegrationTest() {
companion object { private companion object {
val DUMMY_REGULATOR_NAME = CordaX500Name("Regulator A", "Paris", "FR") val DUMMY_REGULATOR_NAME = CordaX500Name("Regulator A", "Paris", "FR")
val executorService: ScheduledExecutorService = Executors.newScheduledThreadPool(2) val executorService: ScheduledExecutorService = Executors.newScheduledThreadPool(2)
@ -103,7 +103,11 @@ class DriverTests : IntegrationTest() {
// Make sure we're using the log4j2 config which writes to the log file // Make sure we're using the log4j2 config which writes to the log file
val logConfigFile = projectRootDir / "config" / "dev" / "log4j2.xml" val logConfigFile = projectRootDir / "config" / "dev" / "log4j2.xml"
assertThat(logConfigFile).isRegularFile() assertThat(logConfigFile).isRegularFile()
driver(DriverParameters(isDebug = true,notarySpecs = emptyList(), systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString()))) { driver(DriverParameters(
isDebug = true,
notarySpecs = emptyList(),
systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())
)) {
val baseDirectory = startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow().baseDirectory val baseDirectory = startNode(providedName = DUMMY_BANK_A_NAME).getOrThrow().baseDirectory
val logFile = (baseDirectory / NodeStartup.LOGS_DIRECTORY_NAME).list { it.sorted().findFirst().get() } val logFile = (baseDirectory / NodeStartup.LOGS_DIRECTORY_NAME).list { it.sorted().findFirst().get() }
val debugLinesPresent = logFile.readLines { lines -> lines.anyMatch { line -> line.startsWith("[DEBUG]") } } val debugLinesPresent = logFile.readLines { lines -> lines.anyMatch { line -> line.startsWith("[DEBUG]") } }

View File

@ -28,7 +28,6 @@ import net.corda.node.services.schema.NodeSchemaService
import net.corda.node.services.transactions.InMemoryTransactionVerifierService import net.corda.node.services.transactions.InMemoryTransactionVerifierService
import net.corda.node.services.vault.NodeVaultService import net.corda.node.services.vault.NodeVaultService
import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.CordaPersistence
import net.corda.nodeapi.internal.persistence.HibernateConfiguration
import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.common.internal.testNetworkParameters
import net.corda.testing.core.TestIdentity import net.corda.testing.core.TestIdentity
import net.corda.testing.internal.DEV_ROOT_CA import net.corda.testing.internal.DEV_ROOT_CA

View File

@ -21,7 +21,6 @@ import net.corda.node.services.config.ConfigHelper
import net.corda.node.services.config.configOf import net.corda.node.services.config.configOf
import net.corda.node.services.config.parseToDbSchemaFriendlyName import net.corda.node.services.config.parseToDbSchemaFriendlyName
import net.corda.node.services.messaging.Message import net.corda.node.services.messaging.Message
import net.corda.node.services.messaging.MessagingService
import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.nodeapi.internal.persistence.DatabaseConfig
import net.corda.nodeapi.internal.persistence.TransactionIsolationLevel import net.corda.nodeapi.internal.persistence.TransactionIsolationLevel
import net.corda.testing.database.DatabaseConstants import net.corda.testing.database.DatabaseConstants
@ -120,10 +119,6 @@ fun StartedNodeServices.newContext(): InvocationContext = testContext(myInfo.cho
fun InMemoryMessagingNetwork.MessageTransfer.getMessage(): Message = message fun InMemoryMessagingNetwork.MessageTransfer.getMessage(): Message = message
internal interface InternalMockMessagingService : MessagingService {
fun pumpReceive(block: Boolean): InMemoryMessagingNetwork.MessageTransfer?
}
/** /**
* Make properties appropriate for creating a DataSource for unit tests. * Make properties appropriate for creating a DataSource for unit tests.
* Defaults configuration of in-memory H2 instance. If 'databaseProvider' system property is set then creates * Defaults configuration of in-memory H2 instance. If 'databaseProvider' system property is set then creates

View File

@ -115,7 +115,7 @@ fun <A> rpcDriver(
notarySpecs: List<NotarySpec> = emptyList(), notarySpecs: List<NotarySpec> = emptyList(),
externalTrace: Trace? = null, externalTrace: Trace? = null,
jmxPolicy: JmxPolicy = JmxPolicy(), jmxPolicy: JmxPolicy = JmxPolicy(),
networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()), networkParameters: NetworkParameters = testNetworkParameters(),
notaryCustomOverrides: Map<String, Any?> = emptyMap(), notaryCustomOverrides: Map<String, Any?> = emptyMap(),
inMemoryDB: Boolean = true, inMemoryDB: Boolean = true,
cordappsForAllNodes: Set<TestCorDapp> = cordappsInCurrentAndAdditionalPackages(), cordappsForAllNodes: Set<TestCorDapp> = cordappsInCurrentAndAdditionalPackages(),

View File

@ -11,7 +11,7 @@ import java.nio.file.Paths
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap import java.util.concurrent.ConcurrentMap
object TestCordappDirectories { object TestCordappDirectories {
private val logger = loggerFor<TestCordappDirectories>() private val logger = loggerFor<TestCordappDirectories>()
@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentMap
private val cordappsCache: ConcurrentMap<List<String>, Path> = ConcurrentHashMap<List<String>, Path>() private val cordappsCache: ConcurrentMap<List<String>, Path> = ConcurrentHashMap<List<String>, Path>()
fun cached(cordapps: Iterable<TestCorDapp>, replaceExistingOnes: Boolean = false, cordappsDirectory: Path = defaultCordappsDirectory): Iterable<Path> { fun cached(cordapps: Iterable<TestCorDapp>, replaceExistingOnes: Boolean = false, cordappsDirectory: Path = defaultCordappsDirectory): Iterable<Path> {
cordappsDirectory.toFile().deleteOnExit() cordappsDirectory.toFile().deleteOnExit()
return cordapps.map { cached(it, replaceExistingOnes, cordappsDirectory) } return cordapps.map { cached(it, replaceExistingOnes, cordappsDirectory) }

View File

@ -1,16 +1,13 @@
package net.corda.testing.node.internal.performance package net.corda.testing.node.internal.performance
import com.codahale.metrics.Gauge import com.codahale.metrics.Gauge
import com.codahale.metrics.MetricRegistry import com.codahale.metrics.MetricRegistry
import com.google.common.base.Stopwatch
import net.corda.core.concurrent.CordaFuture import net.corda.core.concurrent.CordaFuture
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.testing.internal.performance.Rate import net.corda.testing.internal.performance.Rate
import net.corda.testing.node.internal.ShutdownManager import net.corda.testing.node.internal.ShutdownManager
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.time.Duration import java.time.Duration
import java.util.*
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.Semaphore import java.util.concurrent.Semaphore

View File

@ -24,6 +24,7 @@ import net.corda.core.serialization.serialize
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.NetworkHostAndPort
import net.corda.core.utilities.contextLogger import net.corda.core.utilities.contextLogger
import net.corda.nodeapi.internal.PLATFORM_VERSION
import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.common.internal.testNetworkParameters
import java.io.InputStream import java.io.InputStream
import java.net.URL import java.net.URL
@ -76,6 +77,8 @@ class CordaRPCProxyClient(private val targetHostAndPort: NetworkHostAndPort) : C
return doGet(targetHostAndPort, "registered-flows") return doGet(targetHostAndPort, "registered-flows")
} }
override val protocolVersion: Int get() = PLATFORM_VERSION
override val networkParameters: NetworkParameters get() = testNetworkParameters() override val networkParameters: NetworkParameters get() = testNetworkParameters()
override fun stateMachinesSnapshot(): List<StateMachineInfo> { override fun stateMachinesSnapshot(): List<StateMachineInfo> {