Demo bug fixes (#217)

* Add webAddress back to NMS as it shifts the port allocation for all subsequent nodes and causes all demos to break.

* Attachment demo: fix node names

* Notary demo: fix certificate paths & ports

* IRS demo: role decider fixed to allocate roles properly. Previously it used to pick current node as the Fixer, causing both nodes to initiate the trade flow, resulting in double spend exceptions..
This commit is contained in:
Andrius Dagys 2017-02-06 15:57:19 +00:00 committed by GitHub
parent 3bbeb844dc
commit 5bf1c9d3d4
6 changed files with 53 additions and 30 deletions

View File

@ -3,7 +3,7 @@
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="net.corda.notarydemo.NotaryDemoKt" />
<option name="VM_PARAMETERS" value="-ea -javaagent:lib/quasar.jar " />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="--certificates=&quot;build/notary-demo-nodes/Party/certificates&quot;" />
<option name="WORKING_DIRECTORY" value="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />

View File

@ -452,13 +452,16 @@ open class DriverDSL(
private fun startNetworkMapService(): ListenableFuture<Process> {
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
val apiAddress = portAllocation.nextHostAndPort().toString()
val baseDirectory = driverDirectory / networkMapLegalName
val config = ConfigHelper.loadConfig(
baseDirectory = baseDirectory,
allowMissingConfig = true,
configOverrides = mapOf(
"myLegalName" to networkMapLegalName,
// TODO: remove the webAddress as NMS doesn't need to run a web server. This will cause all
// node port numbers to be shifted, so all demos and docs need to be updated accordingly.
"webAddress" to apiAddress,
"artemisAddress" to networkMapAddress.toString(),
"extraAdvertisedServiceIds" to "",
"useTestClock" to useTestClock

View File

@ -42,14 +42,14 @@ fun main(args: Array<String>) {
Role.SENDER -> {
val host = HostAndPort.fromString("localhost:10004")
println("Connecting to sender node ($host)")
CordaRPCClient(host, sslConfigFor("nodea", options.valueOf(certsPath))).use("demo", "demo") {
CordaRPCClient(host, sslConfigFor("BankA", options.valueOf(certsPath))).use("demo", "demo") {
sender(this)
}
}
Role.RECIPIENT -> {
val host = HostAndPort.fromString("localhost:10006")
println("Connecting to the recipient node ($host)")
CordaRPCClient(host, sslConfigFor("nodeb", options.valueOf(certsPath))).use("demo", "demo") {
CordaRPCClient(host, sslConfigFor("BankB", options.valueOf(certsPath))).use("demo", "demo") {
recipient(this)
}
}

View File

@ -143,11 +143,12 @@ object FixingFlow {
progressTracker.nextStep()
val dealToFix = serviceHub.loadState(ref)
val fixableDeal = (dealToFix.data as FixableDealState)
val parties = fixableDeal.parties.filter { it.owningKey != serviceHub.myInfo.legalIdentity.owningKey }
if (parties.isNotEmpty()) {
val parties = fixableDeal.parties.sortedBy { it.owningKey.toBase58String() }
val myKey = serviceHub.myInfo.legalIdentity.owningKey
if (parties[0].owningKey == myKey) {
val fixing = FixingSession(ref, fixableDeal.oracleType)
// Start the Floater which will then kick-off the Fixer
subFlow(Floater(parties.first(), fixing))
subFlow(Floater(parties[1], fixing))
}
}
}

View File

@ -84,12 +84,32 @@ task generateNotaryIdentity(type: JavaExec) {
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generateNotaryIdentity']) {
directory deployTo
networkMap "Notary 1"
node {
name "Party"
nearestCity "London"
advertisedServices = []
artemisPort 10002
webPort 10003
cordapps = []
rpcUsers = [['user': "demo", 'password': "demo", 'permissions': [
'StartFlow.net.corda.notarydemo.flows.DummyIssueAndMove',
'StartFlow.net.corda.flows.NotaryFlow$Client'
]]]
}
node {
name "Counterparty"
nearestCity "New York"
advertisedServices = []
artemisPort 10004
webPort 10005
cordapps = []
}
node {
name "Notary 1"
nearestCity "London"
advertisedServices = [advertisedNotary]
artemisPort 10002
webPort 10009
artemisPort 10007
webPort 10008
cordapps = []
notaryNodePort 11002
}
@ -97,8 +117,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generat
name "Notary 2"
nearestCity "London"
advertisedServices = [advertisedNotary]
artemisPort 10004
webPort 10005
artemisPort 10010
webPort 10011
cordapps = []
notaryNodePort 11004
notaryClusterAddresses = ["localhost:11002"]
@ -107,28 +127,12 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build', 'generat
name "Notary 3"
nearestCity "London"
advertisedServices = [advertisedNotary]
artemisPort 10006
webPort 10007
artemisPort 10013
webPort 10014
cordapps = []
notaryNodePort 11006
notaryClusterAddresses = ["localhost:11002"]
}
node {
name "Party"
nearestCity "London"
advertisedServices = []
artemisPort 10008
webPort 10003
cordapps = []
}
node {
name "Counterparty"
nearestCity "New York"
advertisedServices = []
artemisPort 10010
webPort 10011
cordapps = []
}
}
task notarise(type: JavaExec) {

View File

@ -2,6 +2,7 @@ package net.corda.notarydemo
import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.Futures
import joptsimple.OptionParser
import net.corda.core.crypto.toStringShort
import net.corda.core.div
import net.corda.core.getOrThrow
@ -14,11 +15,13 @@ import net.corda.node.services.messaging.CordaRPCClient
import net.corda.notarydemo.flows.DummyIssueAndMove
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.system.exitProcess
fun main(args: Array<String>) {
val certPath = getCertPath(args)
val host = HostAndPort.fromString("localhost:10002")
println("Connecting to the recipient node ($host)")
CordaRPCClient(host, sslConfigFor("nodeb", "build/notary-demo-nodes/Party/certificates")).use("demo", "demo") {
CordaRPCClient(host, sslConfigFor("Party", certPath)).use("demo", "demo") {
val api = NotaryDemoClientApi(this)
api.startNotarisation()
}
@ -79,6 +82,18 @@ private class NotaryDemoClientApi(val rpc: CordaRPCOps) {
}
}
private fun getCertPath(args: Array<String>): String? {
val parser = OptionParser()
val certsPath = parser.accepts("certificates").withRequiredArg()
val options = try {
parser.parse(*args)
} catch (e: Exception) {
println(e.message)
exitProcess(1)
}
return options.valueOf(certsPath)
}
// TODO: Take this out once we have a dedicated RPC port and allow SSL on it to be optional.
private fun sslConfigFor(nodename: String, certsPath: String?): SSLConfiguration {
return object : SSLConfiguration {