mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
Removed trader demo integration test. Fixed the AttachmentDemo which had unnecessary coupling to the traderdemo. Added new test util func.
This commit is contained in:
parent
c3ac4efa70
commit
39cbab9ce1
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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 <reified P : ProtocolLogic<*>> AbstractNode.initiateSingleShotProtoco
|
||||
smm.changes.subscribe(subscriber)
|
||||
|
||||
return future
|
||||
}
|
||||
}
|
||||
|
||||
fun Config.getHostAndPort(name: String) = HostAndPort.fromString(getString(name))
|
Loading…
x
Reference in New Issue
Block a user