From 8b55f415bda73df54e838dd9f08a8e26df42aa4e Mon Sep 17 00:00:00 2001 From: Christian Sailer Date: Mon, 6 Nov 2017 17:37:30 +0000 Subject: [PATCH] Merge branch 'master' of https://github.com/corda/corda into christians_os_merge_20171106 --- gradle/wrapper/gradle-wrapper.properties | 3 +- .../net/corda/node/internal/EnterpriseNode.kt | 1 - .../contracts/asset/CashSelectionH2Test.kt | 41 ++++++++-------- .../flows/CashExitFlowTests.kt | 8 ++-- .../flows/CashIssueFlowTests.kt | 9 ++-- .../flows/CashPaymentFlowTests.kt | 18 ++++--- .../flows/TwoPartyTradeFlowTest.kt | 48 +++++++++++-------- .../net/corda/vega/SimmValuationTest.kt | 1 - settings.gradle | 2 +- .../KryoVerifierSerializationScheme.kt | 4 +- 10 files changed, 65 insertions(+), 70 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92165eede8..b05efff0b2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Nov 06 15:05:49 GMT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip diff --git a/node/src/main/kotlin/net/corda/node/internal/EnterpriseNode.kt b/node/src/main/kotlin/net/corda/node/internal/EnterpriseNode.kt index 00f376726e..685a57afc2 100644 --- a/node/src/main/kotlin/net/corda/node/internal/EnterpriseNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/EnterpriseNode.kt @@ -7,7 +7,6 @@ import net.corda.core.utilities.loggerFor import net.corda.node.VersionInfo import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.config.RelayConfiguration -import net.corda.nodeapi.internal.ServiceInfo import org.fusesource.jansi.Ansi import org.fusesource.jansi.AnsiConsole import java.io.IOException diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt index 5aa10b3179..36b767c219 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt @@ -4,38 +4,35 @@ import net.corda.core.utilities.getOrThrow import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.flows.CashException import com.r3.corda.enterprise.perftestcordapp.flows.CashPaymentFlow -import net.corda.testing.chooseIdentity import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNodeParameters import org.assertj.core.api.Assertions.assertThatThrownBy +import org.junit.After import org.junit.Test - class CashSelectionH2Test { + private val mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance")) + + @After + fun cleanUp() { + mockNet.stopNodes() + } @Test fun `check does not hold connection over retries`() { - val mockNet = MockNetwork(threadPerNode = true) - try { - val notaryNode = mockNet.createNotaryNode() - val bankA = mockNet.createNode(MockNodeParameters(configOverrides = { existingConfig -> - // Tweak connections to be minimal to make this easier (1 results in a hung node during start up, so use 2 connections). - existingConfig.dataSourceProperties.setProperty("maximumPoolSize", "2") - existingConfig - })) + val bankA = mockNet.createNode(MockNodeParameters(configOverrides = { + // Tweak connections to be minimal to make this easier (1 results in a hung node during start up, so use 2 connections). + it.dataSourceProperties.setProperty("maximumPoolSize", "2") + })) + val notary = mockNet.defaultNotaryIdentity - mockNet.startNodes() + // Start more cash spends than we have connections. If spend leaks a connection on retry, we will run out of connections. + val flow1 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) + val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) + val flow3 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) - // Start more cash spends than we have connections. If spend leaks a connection on retry, we will run out of connections. - val flow1 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) - val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) - val flow3 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) - - assertThatThrownBy { flow1.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) - assertThatThrownBy { flow2.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) - assertThatThrownBy { flow3.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) - } finally { - mockNet.stopNodes() - } + assertThatThrownBy { flow1.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) + assertThatThrownBy { flow2.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) + assertThatThrownBy { flow3.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) } } \ No newline at end of file diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt index fc827ac9c6..eb469fc55d 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt @@ -20,20 +20,18 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith class CashExitFlowTests { - private lateinit var mockNet : MockNetwork + private lateinit var mockNet: MockNetwork private val initialBalance = 2000.DOLLARS private val ref = OpaqueBytes.of(0x01) private lateinit var bankOfCordaNode: StartedNode private lateinit var bankOfCorda: Party - private lateinit var notaryNode: StartedNode private lateinit var notary: Party @Before fun start() { - mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - notaryNode = mockNet.createNotaryNode() + mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), + cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) bankOfCordaNode = mockNet.createPartyNode(BOC.name) - notary = notaryNode.services.getDefaultNotary() bankOfCorda = bankOfCordaNode.info.chooseIdentity() mockNet.runNetwork() diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt index 9df67f5f29..89287be7a9 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt @@ -7,9 +7,8 @@ import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import net.corda.node.internal.StartedNode -import net.corda.testing.chooseIdentity -import net.corda.testing.getDefaultNotary import net.corda.testing.BOC +import net.corda.testing.chooseIdentity import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode @@ -20,19 +19,17 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith class CashIssueFlowTests { - private lateinit var mockNet : MockNetwork + private lateinit var mockNet: MockNetwork private lateinit var bankOfCordaNode: StartedNode private lateinit var bankOfCorda: Party - private lateinit var notaryNode: StartedNode private lateinit var notary: Party @Before fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - notaryNode = mockNet.createNotaryNode() bankOfCordaNode = mockNet.createPartyNode(BOC.name) bankOfCorda = bankOfCordaNode.info.chooseIdentity() - notary = notaryNode.services.getDefaultNotary() + notary = mockNet.defaultNotaryIdentity mockNet.runNetwork() } diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt index 58aba54e43..a43515da84 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt @@ -21,23 +21,21 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith class CashPaymentFlowTests { - private lateinit var mockNet : MockNetwork + private lateinit var mockNet: MockNetwork private val initialBalance = 2000.DOLLARS private val ref = OpaqueBytes.of(0x01) private lateinit var bankOfCordaNode: StartedNode private lateinit var bankOfCorda: Party - private lateinit var notaryNode: StartedNode - private lateinit var notary: Party + private lateinit var aliceNode: StartedNode @Before fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - notaryNode = mockNet.createNotaryNode() bankOfCordaNode = mockNet.createPartyNode(BOC.name) + aliceNode = mockNet.createPartyNode(ALICE.name) bankOfCorda = bankOfCordaNode.info.chooseIdentity() - notary = notaryNode.services.getDefaultNotary() - val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture mockNet.runNetwork() + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture future.getOrThrow() } @@ -48,7 +46,7 @@ class CashPaymentFlowTests { @Test fun `pay some cash`() { - val payTo = notaryNode.info.chooseIdentity() + val payTo = aliceNode.info.chooseIdentity() val expectedPayment = 500.DOLLARS val expectedChange = 1500.DOLLARS @@ -56,7 +54,7 @@ class CashPaymentFlowTests { // Register for vault updates val criteria = QueryCriteria.VaultQueryCriteria(status = Vault.StateStatus.ALL) val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultService.trackBy(criteria) - val (_, vaultUpdatesBankClient) = notaryNode.services.vaultService.trackBy(criteria) + val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy(criteria) val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment, payTo)).resultFuture @@ -88,7 +86,7 @@ class CashPaymentFlowTests { @Test fun `pay more than we have`() { - val payTo = notaryNode.info.chooseIdentity() + val payTo = aliceNode.info.chooseIdentity() val expected = 4000.DOLLARS val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, payTo)).resultFuture @@ -100,7 +98,7 @@ class CashPaymentFlowTests { @Test fun `pay zero cash`() { - val payTo = notaryNode.info.chooseIdentity() + val payTo = aliceNode.info.chooseIdentity() val expected = 0.DOLLARS val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, payTo)).resultFuture diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt index 23653ad786..c5a863d023 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt @@ -82,7 +82,7 @@ internal fun CheckpointStorage.checkpoints(): List { * We assume that Alice and Bob already found each other via some market, and have agreed the details already. */ @RunWith(Parameterized::class) -class TwoPartyTradeFlowTests(val anonymous: Boolean) { +class TwoPartyTradeFlowTests(private val anonymous: Boolean) { companion object { private val cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts") @JvmStatic @@ -112,7 +112,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { // allow interruption half way through. mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) ledger(MockServices(cordappPackages), initialiseSerialization = false) { - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) val bankNode = mockNet.createPartyNode(BOC_NAME) @@ -162,7 +162,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { fun `trade cash for commercial paper fails using soft locking`() { mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) ledger(MockServices(cordappPackages), initialiseSerialization = false) { - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) val bankNode = mockNet.createPartyNode(BOC_NAME) @@ -218,7 +218,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { fun `shutdown and restore`() { mockNet = MockNetwork(cordappPackages = cordappPackages) ledger(MockServices(cordappPackages), initialiseSerialization = false) { - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) var bobNode = mockNet.createPartyNode(BOB_NAME) val bankNode = mockNet.createPartyNode(BOC_NAME) @@ -311,15 +311,14 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { // Creates a mock node with an overridden storage service that uses a RecordingMap, that lets us test the order // of gets and puts. - private fun makeNodeWithTracking(name: CordaX500Name): StartedNode { + private fun makeNodeWithTracking( + name: CordaX500Name): StartedNode { // Create a node in the mock network ... - return mockNet.createNode(MockNodeParameters(legalName = name), nodeFactory = object : MockNetwork.Factory { - override fun create(args: MockNodeArgs): MockNetwork.MockNode { - return object : MockNetwork.MockNode(args) { - // That constructs a recording tx storage - override fun makeTransactionStorage(): WritableTransactionStorage { - return RecordingTransactionStorage(database, super.makeTransactionStorage()) - } + return mockNet.createNode(MockNodeParameters(legalName = name), nodeFactory = { args -> + object : MockNetwork.MockNode(args) { + // That constructs a recording tx storage + override fun makeTransactionStorage(): WritableTransactionStorage { + return RecordingTransactionStorage(database, super.makeTransactionStorage()) } } }) @@ -328,7 +327,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { @Test fun `check dependencies of sale asset are resolved`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = makeNodeWithTracking(ALICE_NAME) val bobNode = makeNodeWithTracking(BOB_NAME) val bankNode = makeNodeWithTracking(BOC_NAME) @@ -434,7 +433,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { @Test fun `track works`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = makeNodeWithTracking(ALICE_NAME) val bobNode = makeNodeWithTracking(BOB_NAME) val bankNode = makeNodeWithTracking(BOC_NAME) @@ -589,7 +588,7 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { aliceError: Boolean, expectedMessageSubstring: String ) { - val notaryNode = mockNet.createNotaryNode() + val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) val bankNode = mockNet.createPartyNode(BOC_NAME) @@ -636,18 +635,25 @@ class TwoPartyTradeFlowTests(val anonymous: Boolean) { notaryNode: StartedNode<*>, vararg extraSigningNodes: StartedNode<*>): Map { + val notaryParty = notaryNode.info.legalIdentities[0] val signed = wtxToSign.map { val id = it.id val sigs = mutableListOf() val nodeKey = node.info.chooseIdentity().owningKey - sigs.add(node.services.keyManagementService.sign(SignableData(id, SignatureMetadata(1, Crypto.findSignatureScheme(nodeKey).schemeNumberID)), nodeKey)) - sigs.add(notaryNode.services.keyManagementService.sign(SignableData(id, SignatureMetadata(1, - Crypto.findSignatureScheme(notaryNode.info.legalIdentities[1].owningKey).schemeNumberID)), notaryNode.info.legalIdentities[1].owningKey)) + sigs += node.services.keyManagementService.sign( + SignableData(id, SignatureMetadata(1, Crypto.findSignatureScheme(nodeKey).schemeNumberID)), + nodeKey + ) + sigs += notaryNode.services.keyManagementService.sign( + SignableData(id, SignatureMetadata(1, Crypto.findSignatureScheme(notaryParty.owningKey).schemeNumberID)), + notaryParty.owningKey + ) extraSigningNodes.forEach { currentNode -> - sigs.add(currentNode.services.keyManagementService.sign( - SignableData(id, SignatureMetadata(1, Crypto.findSignatureScheme(currentNode.info.chooseIdentity().owningKey).schemeNumberID)), + sigs += currentNode.services.keyManagementService.sign( + SignableData(id, SignatureMetadata( + 1, + Crypto.findSignatureScheme(currentNode.info.chooseIdentity().owningKey).schemeNumberID)), currentNode.info.chooseIdentity().owningKey) - ) } SignedTransaction(it, sigs) } diff --git a/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt b/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt index 6c9c6cff74..d09d8f5a8c 100644 --- a/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt +++ b/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt @@ -5,7 +5,6 @@ import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.getOrThrow import net.corda.testing.DUMMY_BANK_A import net.corda.testing.DUMMY_BANK_B -import net.corda.testing.IntegrationTestCategory import net.corda.testing.driver.driver import net.corda.testing.http.HttpApi import net.corda.vega.api.PortfolioApi diff --git a/settings.gradle b/settings.gradle index 2ef7265d8b..7ce3241252 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,7 +19,7 @@ include 'experimental' include 'experimental:sandbox' include 'experimental:quasar-hook' include 'experimental:kryo-hook' -include 'experimental:intellij-plugin' +//include 'experimental:intellij-plugin' include 'verifier' include 'test-common' include 'test-utils' diff --git a/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoVerifierSerializationScheme.kt b/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoVerifierSerializationScheme.kt index b81352281d..455be7ae40 100644 --- a/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoVerifierSerializationScheme.kt +++ b/verify-enclave/src/main/kotlin/com/r3/enclaves/txverify/KryoVerifierSerializationScheme.kt @@ -3,10 +3,10 @@ package com.r3.enclaves.txverify import net.corda.core.serialization.SerializationContext import net.corda.core.serialization.SerializationDefaults import net.corda.core.utilities.ByteSequence -import net.corda.nodeapi.internal.serialization.AbstractKryoSerializationScheme import net.corda.nodeapi.internal.serialization.KRYO_P2P_CONTEXT -import net.corda.nodeapi.internal.serialization.KryoHeaderV0_1 import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl +import net.corda.nodeapi.internal.serialization.kryo.AbstractKryoSerializationScheme +import net.corda.nodeapi.internal.serialization.kryo.KryoHeaderV0_1 @Suppress("UNUSED") private class KryoVerifierSerializationScheme : AbstractKryoSerializationScheme() {