From c817252e7a26d2570996f8cec4d9eb2097e20886 Mon Sep 17 00:00:00 2001 From: josecoll Date: Fri, 17 Nov 2017 17:36:00 +0000 Subject: [PATCH] Fix compilation errors in `perftestcordapp` module. --- .../contracts/CommercialPaperTests.kt | 8 ++--- .../contracts/asset/CashSelectionH2Test.kt | 3 +- .../contracts/asset/CashTests.kt | 4 +-- .../flows/CashExitFlowTests.kt | 5 +-- .../flows/CashIssueFlowTests.kt | 12 +++---- .../flows/TwoPartyTradeFlowTest.kt | 31 +++++++++---------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt index ae341985d2..dd3462fa87 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt @@ -1,5 +1,8 @@ package com.r3.corda.enterprise.perftestcordapp.contracts +import com.r3.corda.enterprise.perftestcordapp.DOLLARS +import com.r3.corda.enterprise.perftestcordapp.`issued by` +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.* import net.corda.core.contracts.* import net.corda.core.identity.AnonymousParty import net.corda.core.identity.Party @@ -9,13 +12,8 @@ import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.days import net.corda.core.utilities.seconds -import com.r3.corda.enterprise.perftestcordapp.DOLLARS -import com.r3.corda.enterprise.perftestcordapp.`issued by` -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.* import net.corda.testing.* -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.fillWithSomeTestCash import net.corda.testing.node.MockServices -import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith 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 36b767c219..5af511b3ac 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 @@ -1,11 +1,12 @@ package com.r3.corda.enterprise.perftestcordapp.contracts.asset -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.core.utilities.getOrThrow import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNodeParameters +import net.corda.testing.startFlow import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.After import org.junit.Test diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt index 9d27df3756..8edade4062 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt @@ -104,7 +104,7 @@ class CashTests { @Before fun setUp() = withTestSerialization { LogHelper.setLevel(NodeVaultService::class) - megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP_KEY) + megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP.name, MEGA_CORP_KEY) val databaseAndServices = makeTestDatabaseAndMockServices(cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), keys = listOf(MINI_CORP_KEY, MEGA_CORP_KEY, OUR_KEY)) database = databaseAndServices.first miniCorpServices = databaseAndServices.second @@ -828,7 +828,7 @@ class CashTests { // Double spend. @Test fun chainCashDoubleSpendFailsWith() { - val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP_KEY) + val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP.name, MEGA_CORP_KEY) ledger(mockService) { unverifiedTransaction { 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 eb469fc55d..3456935d6d 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 @@ -6,13 +6,14 @@ import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import net.corda.core.identity.Party import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow +import net.corda.finance.flows.CashIssueFlow import net.corda.node.internal.StartedNode import net.corda.testing.BOC import net.corda.testing.chooseIdentity -import net.corda.testing.getDefaultNotary import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode +import net.corda.testing.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -35,7 +36,7 @@ class CashExitFlowTests { bankOfCorda = bankOfCordaNode.info.chooseIdentity() mockNet.runNetwork() - notary = bankOfCordaNode.services.getDefaultNotary() + notary = mockNet.defaultNotaryIdentity val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture mockNet.runNetwork() future.getOrThrow() 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 89287be7a9..467c1c7b0b 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 @@ -1,17 +1,18 @@ package com.r3.corda.enterprise.perftestcordapp.flows -import net.corda.core.identity.Party -import net.corda.core.utilities.OpaqueBytes -import net.corda.core.utilities.getOrThrow 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.core.identity.Party +import net.corda.core.utilities.OpaqueBytes +import net.corda.core.utilities.getOrThrow import net.corda.node.internal.StartedNode import net.corda.testing.BOC -import net.corda.testing.chooseIdentity +import net.corda.testing.BOC_NAME import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode +import net.corda.testing.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -28,9 +29,8 @@ class CashIssueFlowTests { fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) bankOfCordaNode = mockNet.createPartyNode(BOC.name) - bankOfCorda = bankOfCordaNode.info.chooseIdentity() + bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME) notary = mockNet.defaultNotaryIdentity - mockNet.runNetwork() } @After 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 c5a863d023..50475495b0 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 @@ -47,7 +47,6 @@ import net.corda.testing.node.* import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized @@ -111,14 +110,14 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { // we run in the unit test thread exclusively to speed things up, ensure deterministic results and // allow interruption half way through. mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages), initialiseSerialization = false) { + ledger(MockServices(cordappPackages)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) val bankNode = mockNet.createPartyNode(BOC_NAME) val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() - val notary = notaryNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity val cashIssuer = bank.ref(1) val cpIssuer = bank.ref(1, 2, 3) @@ -161,7 +160,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test(expected = InsufficientBalanceException::class) fun `trade cash for commercial paper fails using soft locking`() { mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages), initialiseSerialization = false) { + ledger(MockServices(cordappPackages)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) @@ -169,7 +168,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() val issuer = bank.ref(1) - val notary = aliceNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity aliceNode.internals.disableDBCloseOnStop() bobNode.internals.disableDBCloseOnStop() @@ -217,7 +216,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `shutdown and restore`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages), initialiseSerialization = false) { + ledger(MockServices(cordappPackages)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) var bobNode = mockNet.createPartyNode(BOB_NAME) @@ -228,7 +227,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bobAddr = bobNode.network.myAddress as InMemoryMessagingNetwork.PeerHandle mockNet.runNetwork() // Clear network map registration messages - val notary = notaryNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity val alice = aliceNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) @@ -317,8 +316,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { 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()) + override fun makeTransactionStorage(database: CordaPersistence): WritableTransactionStorage { + return RecordingTransactionStorage(database, super.makeTransactionStorage(database)) } } }) @@ -332,13 +331,13 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bobNode = makeNodeWithTracking(BOB_NAME) val bankNode = makeNodeWithTracking(BOC_NAME) mockNet.runNetwork() - val notary = aliceNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity val alice = aliceNode.info.singleIdentity() val bob = bobNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) - ledger(aliceNode.services, initialiseSerialization = false) { + ledger(aliceNode.services) { // Insert a prospectus type attachment into the commercial paper transaction. val stream = ByteArrayOutputStream() @@ -439,12 +438,12 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bankNode = makeNodeWithTracking(BOC_NAME) mockNet.runNetwork() - val notary = aliceNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity val alice: Party = aliceNode.info.singleIdentity() val bank: Party = bankNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) - ledger(aliceNode.services, initialiseSerialization = false) { + ledger(aliceNode.services) { // Insert a prospectus type attachment into the commercial paper transaction. val stream = ByteArrayOutputStream() JarOutputStream(stream).use { @@ -514,7 +513,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `dependency with error on buyer side`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages), initialiseSerialization = false) { + ledger(MockServices(cordappPackages)) { runWithError(true, false, "at least one cash input") } } @@ -522,7 +521,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `dependency with error on seller side`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages), initialiseSerialization = false) { + ledger(MockServices(cordappPackages)) { runWithError(false, true, "Issuances have a time-window") } } @@ -594,7 +593,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bankNode = mockNet.createPartyNode(BOC_NAME) mockNet.runNetwork() - val notary = aliceNode.services.getDefaultNotary() + val notary = mockNet.defaultNotaryIdentity val alice = aliceNode.info.singleIdentity() val bob = bobNode.info.singleIdentity() val bank = bankNode.info.singleIdentity()