From 8e934df21770523503ba2d25612ae691ca2e2267 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Wed, 16 May 2018 15:55:51 +0100 Subject: [PATCH 1/2] Fix db transaction check (#3164) --- .../corda/node/services/statemachine/FlowStateMachineImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt index b75a68178e..fe60503096 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt @@ -159,7 +159,7 @@ class FlowStateMachineImpl(override val id: StateMachineRunId, private fun checkDbTransaction(isPresent: Boolean) { if (isPresent) { - requireNotNull(contextTransactionOrNull != null) + requireNotNull(contextTransactionOrNull) } else { require(contextTransactionOrNull == null) } From 27803cdc9e6ac531ac67f79627cdd5b8248d6465 Mon Sep 17 00:00:00 2001 From: josecoll Date: Wed, 16 May 2018 18:01:53 +0100 Subject: [PATCH 2/2] ENT-1887 Make sure open and enterprise API are identical (#3158) * Sync public API's (and associated internal helpers) between Enterprise and OS. * Add previous default constructor explicitly. * Keep the API checker happy! * Revert addition of ENT makeTestDataSourceProperties() function. --- .../kotlin/net/corda/testing/driver/Driver.kt | 138 +++++++++++++++--- .../testing/dsl/TransactionDSLInterpreter.kt | 7 +- 2 files changed, 126 insertions(+), 19 deletions(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt index 97cd2ef116..a1f1851232 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -142,14 +142,48 @@ data class NodeParameters( val verifierType: VerifierType = VerifierType.InMemory, val customOverrides: Map = emptyMap(), val startInSameProcess: Boolean? = null, - val maximumHeapSize: String = "512m" + val maximumHeapSize: String = "512m", + val logLevel: String? = null ) { + constructor( + providedName: CordaX500Name?, + rpcUsers: List, + verifierType: VerifierType, + customOverrides: Map, + startInSameProcess: Boolean?, + maximumHeapSize: String + ) : this( + providedName, + rpcUsers, + verifierType, + customOverrides, + startInSameProcess, + maximumHeapSize, + null) + + fun copy( + providedName: CordaX500Name?, + rpcUsers: List, + verifierType: VerifierType, + customOverrides: Map, + startInSameProcess: Boolean?, + maximumHeapSize: String + ) = this.copy( + providedName, + rpcUsers, + verifierType, + customOverrides, + startInSameProcess, + maximumHeapSize, + null) + fun withProvidedName(providedName: CordaX500Name?): NodeParameters = copy(providedName = providedName) fun withRpcUsers(rpcUsers: List): NodeParameters = copy(rpcUsers = rpcUsers) fun withVerifierType(verifierType: VerifierType): NodeParameters = copy(verifierType = verifierType) fun withCustomOverrides(customOverrides: Map): NodeParameters = copy(customOverrides = customOverrides) fun withStartInSameProcess(startInSameProcess: Boolean?): NodeParameters = copy(startInSameProcess = startInSameProcess) fun withMaximumHeapSize(maximumHeapSize: String): NodeParameters = copy(maximumHeapSize = maximumHeapSize) + fun withLogLevel(logLevel: String?): NodeParameters = copy(logLevel = logLevel) } /** @@ -202,7 +236,7 @@ fun driver(defaultParameters: DriverParameters = DriverParameters(), dsl: Dr ), coerce = { it }, dsl = dsl, - initialiseSerialization = true + initialiseSerialization = defaultParameters.initialiseSerialization ) } @@ -245,9 +279,10 @@ data class DriverParameters( val notarySpecs: List = listOf(NotarySpec(DUMMY_NOTARY_NAME)), val extraCordappPackagesToScan: List = emptyList(), val jmxPolicy: JmxPolicy = JmxPolicy(), - val networkParameters: NetworkParameters = testNetworkParameters(), - val notaryCustomOverrides: Map = emptyMap() -) { + val networkParameters: NetworkParameters = testNetworkParameters(notaries = emptyList()), + val notaryCustomOverrides: Map = emptyMap(), + val initialiseSerialization: Boolean = true + ) { constructor( isDebug: Boolean, driverDirectory: Path, @@ -273,7 +308,40 @@ data class DriverParameters( notarySpecs, extraCordappPackagesToScan, jmxPolicy, - networkParameters, emptyMap() + networkParameters, + emptyMap(), + true + ) + + constructor( + isDebug: Boolean, + driverDirectory: Path, + portAllocation: PortAllocation, + debugPortAllocation: PortAllocation, + systemProperties: Map, + useTestClock: Boolean, + startNodesInProcess: Boolean, + waitForAllNodesToFinish: Boolean, + notarySpecs: List, + extraCordappPackagesToScan: List, + jmxPolicy: JmxPolicy, + networkParameters: NetworkParameters, + initialiseSerialization: Boolean + ) : this( + isDebug, + driverDirectory, + portAllocation, + debugPortAllocation, + systemProperties, + useTestClock, + startNodesInProcess, + waitForAllNodesToFinish, + notarySpecs, + extraCordappPackagesToScan, + jmxPolicy, + networkParameters, + emptyMap(), + initialiseSerialization ) fun withIsDebug(isDebug: Boolean): DriverParameters = copy(isDebug = isDebug) @@ -282,6 +350,7 @@ data class DriverParameters( fun withDebugPortAllocation(debugPortAllocation: PortAllocation): DriverParameters = copy(debugPortAllocation = debugPortAllocation) fun withSystemProperties(systemProperties: Map): DriverParameters = copy(systemProperties = systemProperties) fun withUseTestClock(useTestClock: Boolean): DriverParameters = copy(useTestClock = useTestClock) + fun withInitialiseSerialization(initialiseSerialization: Boolean): DriverParameters = copy(initialiseSerialization = initialiseSerialization) fun withStartNodesInProcess(startNodesInProcess: Boolean): DriverParameters = copy(startNodesInProcess = startNodesInProcess) fun withWaitForAllNodesToFinish(waitForAllNodesToFinish: Boolean): DriverParameters = copy(waitForAllNodesToFinish = waitForAllNodesToFinish) fun withNotarySpecs(notarySpecs: List): DriverParameters = copy(notarySpecs = notarySpecs) @@ -304,17 +373,50 @@ data class DriverParameters( jmxPolicy: JmxPolicy, networkParameters: NetworkParameters ) = this.copy( - isDebug, - driverDirectory, - portAllocation, - debugPortAllocation, - systemProperties, - useTestClock, - startNodesInProcess, - waitForAllNodesToFinish, - notarySpecs, - extraCordappPackagesToScan, - jmxPolicy, - networkParameters, emptyMap() + isDebug = isDebug, + driverDirectory = driverDirectory, + portAllocation = portAllocation, + debugPortAllocation = debugPortAllocation, + systemProperties = systemProperties, + useTestClock = useTestClock, + startNodesInProcess = startNodesInProcess, + waitForAllNodesToFinish = waitForAllNodesToFinish, + notarySpecs = notarySpecs, + extraCordappPackagesToScan = extraCordappPackagesToScan, + jmxPolicy = jmxPolicy, + networkParameters = networkParameters, + notaryCustomOverrides = emptyMap(), + initialiseSerialization = true + ) + + fun copy( + isDebug: Boolean, + driverDirectory: Path, + portAllocation: PortAllocation, + debugPortAllocation: PortAllocation, + systemProperties: Map, + useTestClock: Boolean, + startNodesInProcess: Boolean, + waitForAllNodesToFinish: Boolean, + notarySpecs: List, + extraCordappPackagesToScan: List, + jmxPolicy: JmxPolicy, + networkParameters: NetworkParameters, + initialiseSerialization: Boolean + ) = this.copy( + isDebug = isDebug, + driverDirectory = driverDirectory, + portAllocation = portAllocation, + debugPortAllocation = debugPortAllocation, + systemProperties = systemProperties, + useTestClock = useTestClock, + startNodesInProcess = startNodesInProcess, + waitForAllNodesToFinish = waitForAllNodesToFinish, + notarySpecs = notarySpecs, + extraCordappPackagesToScan = extraCordappPackagesToScan, + jmxPolicy = jmxPolicy, + networkParameters = networkParameters, + notaryCustomOverrides = emptyMap(), + initialiseSerialization = initialiseSerialization ) } diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt index 8bb0b6c492..6b6f90dd18 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/dsl/TransactionDSLInterpreter.kt @@ -4,8 +4,8 @@ import net.corda.core.DoNotImplement import net.corda.core.contracts.* import net.corda.core.crypto.SecureHash import net.corda.core.identity.Party -import net.corda.core.utilities.seconds import net.corda.core.transactions.TransactionBuilder +import net.corda.core.utilities.seconds import java.security.PublicKey import java.time.Duration import java.time.Instant @@ -86,6 +86,11 @@ class TransactionDSL(interpreter: T, private */ fun input(stateLabel: String) = input(retrieveOutputStateAndRef(ContractState::class.java, stateLabel).ref) + fun input(contractClassName: ContractClassName, stateLabel: String) { + val stateAndRef = retrieveOutputStateAndRef(ContractState::class.java, stateLabel) + input(contractClassName, stateAndRef.state.data) + } + /** * Creates an [LedgerDSLInterpreter._unverifiedTransaction] with a single output state and adds it's reference as an * input to the current transaction.