Merge pull request #1388 from corda/os-merge-90a7dd2

O/S merge 90a7dd2
This commit is contained in:
Shams Asari 2018-09-12 13:26:49 +01:00 committed by GitHub
commit 9255866f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 65 additions and 25 deletions

View File

@ -14,6 +14,7 @@ import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo
import org.bouncycastle.jcajce.provider.util.AsymmetricKeyInfoConverter
import org.bouncycastle.jce.provider.BouncyCastleProvider
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider
import java.security.SecureRandom
import java.security.Security
internal val cordaSecurityProvider = CordaSecurityProvider().also {
@ -46,4 +47,4 @@ internal val bouncyCastlePQCProvider = BouncyCastlePQCProvider().apply {
internal val providerMap = listOf(cordaBouncyCastleProvider, cordaSecurityProvider, bouncyCastlePQCProvider).map { it.name to it }.toMap()
@DeleteForDJVM
internal fun platformSecureRandomFactory() = platformSecureRandom // To minimise diff of CryptoUtils against open-source.
internal fun platformSecureRandomFactory(): SecureRandom = platformSecureRandom // To minimise diff of CryptoUtils against open-source.

View File

@ -42,7 +42,8 @@ data class StateMachineInfo @JvmOverloads constructor(
* An object representing information about the initiator of the flow. Note that this field is
* superseded by the [invocationContext] property, which has more detail.
*/
@Deprecated("There is more info available using 'invocationContext'") val initiator: FlowInitiator,
@Deprecated("There is more info available using 'invocationContext'")
val initiator: FlowInitiator,
/** A [DataFeed] of the current progress step as a human readable string, and updates to that string. */
val progressTrackerStepAndUpdates: DataFeed<String, String>?,
/** An [InvocationContext] describing why and by whom the flow was started. */

View File

@ -140,4 +140,4 @@ interface IdentityService {
fun partiesFromName(query: String, exactMatch: Boolean): Set<Party>
}
class UnknownAnonymousPartyException(msg: String) : CordaException(msg)
class UnknownAnonymousPartyException(message: String) : CordaException(message)

View File

@ -36,7 +36,7 @@ sealed class ByteSequence(private val _bytes: ByteArray, val offset: Int, val si
* Create a sub-sequence of this sequence. A copy of the underlying array may be made, if a subclass overrides
* [bytes] to do so, as [OpaqueBytes] does.
*
* @param offset The offset within this sequence to start the new sequence. Note: not the offset within the backing array.
* @param offset The offset within this sequence to start the new sequence. Note: not the offset within the backing array.
* @param size The size of the intended sub sequence.
*/
@Suppress("MemberVisibilityCanBePrivate")

View File

@ -4,20 +4,11 @@ import net.corda.core.contracts.Amount
import net.corda.core.contracts.ContractState
import net.corda.core.identity.Party
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.DEFAULT_PAGE_NUM
import net.corda.core.node.services.vault.DEFAULT_PAGE_SIZE
import net.corda.core.node.services.vault.PageSpecification
import net.corda.core.node.services.vault.QueryCriteria
import net.corda.core.node.services.vault.builder
import net.corda.core.node.services.vault.*
import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow
import net.corda.docs.java.tutorial.helloworld.IOUFlow
import net.corda.finance.CHF
import net.corda.finance.DOLLARS
import net.corda.finance.GBP
import net.corda.finance.POUNDS
import net.corda.finance.SWISS_FRANCS
import net.corda.finance.USD
import net.corda.finance.*
import net.corda.finance.contracts.getCashBalances
import net.corda.finance.flows.CashIssueFlow
import net.corda.node.services.vault.VaultSchemaV1
@ -112,4 +103,4 @@ class CustomVaultQueryTest {
return Pair(balancesNodesA, balancesNodesB)
}
}
}

View File

@ -26,7 +26,7 @@ class CashIssueFlowTests {
fun start() {
mockNet = MockNetwork(
servicePeerAllocationStrategy = RoundRobin(),
cordappPackages = listOf("net.corda.finance.contracts.asset", "net.corda.finance.schemas"))
cordappPackages = listOf("net.corda.finance.contracts", "net.corda.finance.schemas"))
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME)
notary = mockNet.defaultNotaryIdentity

View File

@ -10,6 +10,8 @@ import net.corda.core.utilities.ProgressTracker
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.unwrap
import net.corda.node.services.Permissions
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.*
import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver
@ -77,7 +79,7 @@ class InitiatorFlow(private val sessionsCount: Int, private val iterationsCount:
fun tracker() = ProgressTracker(FIRST_STEP)
val seen = Collections.synchronizedSet(HashSet<Visited>())
val seen: MutableSet<Visited> = Collections.synchronizedSet(HashSet<Visited>())
fun visit(sessionNum: Int, iterationNum: Int, step: Step) {
val visited = Visited(sessionNum, iterationNum, step)
@ -128,7 +130,7 @@ class InitiatedFlow(val session: FlowSession) : FlowLogic<Any>() {
fun tracker() = ProgressTracker(FIRST_STEP)
val seen = Collections.synchronizedSet(HashSet<Visited>())
val seen: MutableSet<Visited> = Collections.synchronizedSet(HashSet<Visited>())
fun visit(sessionNum: Int, iterationNum: Int, step: Step) {
val visited = Visited(sessionNum, iterationNum, step)

View File

@ -6,8 +6,8 @@ import net.corda.core.flows.*
import net.corda.core.identity.Party
import net.corda.core.internal.concurrent.map
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.contextLogger
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.loggerFor
import net.corda.core.utilities.unwrap
import net.corda.node.services.Permissions
import net.corda.testing.core.*
@ -37,7 +37,7 @@ class P2PFlowsDrainingModeTest : IntegrationTest() {
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray())
private val logger = loggerFor<P2PFlowsDrainingModeTest>()
private val logger = contextLogger()
}
private val portAllocation = PortAllocation.Incremental(10000)

View File

@ -781,7 +781,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
}
// Specific class so that MockNode can catch it.
class DatabaseConfigurationException(msg: String) : CordaException(msg)
class DatabaseConfigurationException(message: String) : CordaException(message)
protected open fun startDatabase(metricRegistry: MetricRegistry? = null) {
log.debug {

View File

@ -65,7 +65,7 @@ class DBCheckpointStorage : CheckpointStorage {
override fun getCheckpoint(id: StateMachineRunId): SerializedBytes<Checkpoint>? {
val bytes = currentDBSession().get(DBCheckpoint::class.java, id.uuid.toString())?.checkpoint ?: return null
return SerializedBytes<Checkpoint>(bytes)
return SerializedBytes(bytes)
}
override fun getAllCheckpoints(): Stream<Pair<StateMachineRunId, SerializedBytes<Checkpoint>>> {
@ -79,7 +79,7 @@ class DBCheckpointStorage : CheckpointStorage {
}
override fun getCheckpointCount(connection: Connection): Long {
try {
return try {
return connection.prepareStatement("select count(*) from node_checkpoints").use { ps ->
ps.executeQuery().use { rs ->
rs.next()

View File

@ -5,4 +5,4 @@ import net.corda.core.CordaException
/**
* An exception propagated and thrown in case a session initiation fails.
*/
class SessionRejectException(reason: String) : CordaException(reason)
class SessionRejectException(message: String) : CordaException(message)

View File

@ -0,0 +1,45 @@
package net.corda.node.services.statemachine
import net.corda.core.CordaException
import net.corda.core.node.services.UnknownAnonymousPartyException
import net.corda.core.serialization.SerializedBytes
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize
import net.corda.node.internal.AbstractNode
import net.corda.node.utilities.registration.CertificateRequestException
import net.corda.testing.core.SerializationEnvironmentRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import kotlin.test.assertEquals
@RunWith(Parameterized::class)
class ExceptionsSerializationTest(private val initialException: CordaException, @Suppress("UNUSED_PARAMETER") description: String) {
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{1}")
fun data(): Collection<Array<Any>> = listOf(
arrayOf<Any>(SessionRejectException("test"), "SessionRejectException"),
arrayOf<Any>(CertificateRequestException("test"), "CertificateRequestException"),
arrayOf<Any>(UnknownAnonymousPartyException("test"), "UnknownAnonymousPartyException"),
arrayOf<Any>(AbstractNode.DatabaseConfigurationException("test"), "DatabaseConfigurationException")
)
}
@Rule
@JvmField
val testSerialization = SerializationEnvironmentRule()
@Test
fun testMarshal() {
val fromSerialized = performRoundTripSerialization(initialException)
assertEquals(initialException.message, fromSerialized.message)
}
private inline fun <reified T : Any> performRoundTripSerialization(obj: T): T {
val serializedForm: SerializedBytes<T> = obj.serialize()
return serializedForm.deserialize()
}
}