From 39cbab9ce1246bf01572ce691014e98abc4e9061 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Tue, 25 Oct 2016 11:25:49 +0100 Subject: [PATCH] Removed trader demo integration test. Fixed the AttachmentDemo which had unnecessary coupling to the traderdemo. Added new test util func. --- .../r3corda/core/testing/TraderDemoTest.kt | 55 ------------------ .../demos/attachment/AttachmentDemo.kt | 2 +- .../{ => attachment}/bank-of-london-cp.jar | Bin .../com/r3corda/testing/CoreTestUtils.kt | 5 +- 4 files changed, 5 insertions(+), 57 deletions(-) delete mode 100644 src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt rename src/main/resources/com/r3corda/demos/{ => attachment}/bank-of-london-cp.jar (100%) diff --git a/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt b/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt deleted file mode 100644 index 233139ca41..0000000000 --- a/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.r3corda.core.testing - -import com.google.common.net.HostAndPort -import com.r3corda.testing.* -import org.junit.Test -import kotlin.test.assertEquals - -class TraderDemoTest { - @Test fun `runs trader demo`() { - val buyerAddr = freeLocalHostAndPort() - val buyerApiAddr = freeLocalHostAndPort() - val directory = "./build/integration-test/${TestTimestamp.timestamp}/trader-demo" - var nodeProc: Process? = null - try { - nodeProc = runBuyer(directory, buyerAddr, buyerApiAddr) - runSeller(directory, buyerAddr) - } finally { - nodeProc?.destroy() - } - } - - companion object { - private fun runBuyer(baseDirectory: String, buyerAddr: HostAndPort, buyerApiAddr: HostAndPort): Process { - println("Running Buyer") - val args = listOf( - "--role", "BUYER", - "--network-address", buyerAddr.toString(), - "--api-address", buyerApiAddr.toString(), - "--base-directory", baseDirectory, - "--h2-port", "0" - ) - val proc = spawn("com.r3corda.demos.TraderDemoKt", args, "TradeDemoBuyer") - NodeApi.ensureNodeStartsOrKill(proc, buyerApiAddr) - return proc - } - - private fun runSeller(baseDirectory: String, buyerAddr: HostAndPort) { - println("Running Seller") - val sellerAddr = freeLocalHostAndPort() - val sellerApiAddr = freeLocalHostAndPort() - val args = listOf( - "--role", "SELLER", - "--network-address", sellerAddr.toString(), - "--api-address", sellerApiAddr.toString(), - "--other-network-address", buyerAddr.toString(), - "--base-directory", baseDirectory, - "--h2-port", "0" - ) - val proc = spawn("com.r3corda.demos.TraderDemoKt", args, "TradeDemoSeller") - assertExitOrKill(proc) - assertEquals(proc.exitValue(), 0) - } - - } -} diff --git a/src/main/kotlin/com/r3corda/demos/attachment/AttachmentDemo.kt b/src/main/kotlin/com/r3corda/demos/attachment/AttachmentDemo.kt index 41ae3768ab..1325d7aa99 100644 --- a/src/main/kotlin/com/r3corda/demos/attachment/AttachmentDemo.kt +++ b/src/main/kotlin/com/r3corda/demos/attachment/AttachmentDemo.kt @@ -164,7 +164,7 @@ private fun runSender(node: Node, otherSide: Party) { // Make sure we have the file in storage // TODO: We should have our own demo file, not share the trader demo file if (serviceHub.storageService.attachments.openAttachment(PROSPECTUS_HASH) == null) { - com.r3corda.demos.Role::class.java.getResourceAsStream("bank-of-london-cp.jar").use { + Role::class.java.getResourceAsStream("bank-of-london-cp.jar").use { val id = node.storage.attachments.importAttachment(it) assertEquals(PROSPECTUS_HASH, id) } diff --git a/src/main/resources/com/r3corda/demos/bank-of-london-cp.jar b/src/main/resources/com/r3corda/demos/attachment/bank-of-london-cp.jar similarity index 100% rename from src/main/resources/com/r3corda/demos/bank-of-london-cp.jar rename to src/main/resources/com/r3corda/demos/attachment/bank-of-london-cp.jar diff --git a/test-utils/src/main/kotlin/com/r3corda/testing/CoreTestUtils.kt b/test-utils/src/main/kotlin/com/r3corda/testing/CoreTestUtils.kt index a6e3327f0d..f59f11c806 100644 --- a/test-utils/src/main/kotlin/com/r3corda/testing/CoreTestUtils.kt +++ b/test-utils/src/main/kotlin/com/r3corda/testing/CoreTestUtils.kt @@ -21,6 +21,7 @@ import com.r3corda.node.services.statemachine.StateMachineManager.Change import com.r3corda.node.utilities.AddOrRemove.ADD import com.r3corda.testing.node.MockIdentityService import com.r3corda.testing.node.MockServices +import com.typesafe.config.Config import rx.Subscriber import java.net.ServerSocket import java.security.KeyPair @@ -163,4 +164,6 @@ inline fun > AbstractNode.initiateSingleShotProtoco smm.changes.subscribe(subscriber) return future -} \ No newline at end of file +} + +fun Config.getHostAndPort(name: String) = HostAndPort.fromString(getString(name)) \ No newline at end of file