Get rid of the fake NodeInfo used to identify the NetworkMapService node.

Remove old comment
This commit is contained in:
Matthew Nesbit
2016-09-06 16:23:47 +01:00
parent c6fd467fb5
commit 2e1952a8a7
21 changed files with 89 additions and 152 deletions

View File

@ -300,8 +300,6 @@ class DriverDSL(
val driverCliParams = NodeRunner.CliParams(
services = advertisedServices,
networkMapName = networkMapNodeInfo!!.identity.name,
networkMapPublicKey = networkMapNodeInfo!!.identity.owningKey,
networkMapAddress = networkMapAddress,
messagingAddress = messagingAddress,
apiAddress = apiAddress,
@ -386,17 +384,8 @@ class DriverDSL(
override fun start() {
startNetworkMapService()
val networkMapClient = startClient("driver-$networkMapName-client", networkMapAddress).get()
// We fake the network map's NodeInfo with a random public key in order to retrieve the correct NodeInfo from
// the network map service itself.
val fakeNodeInfo = NodeInfo(
address = ArtemisMessagingClient.makeNetworkMapAddress(networkMapAddress),
identity = Party(
name = networkMapName,
owningKey = generateKeyPair().public
),
advertisedServices = setOf(NetworkMapService.Type)
)
networkMapCache.addMapService(networkMapClient, fakeNodeInfo, true)
val networkMapAddr = ArtemisMessagingClient.makeNetworkMapAddress(networkMapAddress)
networkMapCache.addMapService(networkMapClient, networkMapAddr, true)
networkMapNodeInfo = poll("network map cache for $networkMapName") {
networkMapCache.partyNodes.forEach {
if (it.identity.name == networkMapName) {
@ -423,8 +412,6 @@ class DriverDSL(
val driverCliParams = NodeRunner.CliParams(
services = setOf(NetworkMapService.Type),
networkMapName = null,
networkMapPublicKey = null,
networkMapAddress = null,
messagingAddress = networkMapAddress,
apiAddress = apiAddress,

View File

@ -1,16 +1,11 @@
package com.r3corda.node.driver
import com.google.common.net.HostAndPort
import com.r3corda.core.crypto.Party
import com.r3corda.core.crypto.parsePublicKeyBase58
import com.r3corda.core.crypto.toBase58String
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.services.ServiceType
import com.r3corda.node.internal.Node
import com.r3corda.node.services.config.NodeConfiguration
import com.r3corda.node.services.config.NodeConfigurationFromConfig
import com.r3corda.node.services.messaging.ArtemisMessagingClient
import com.r3corda.node.services.network.NetworkMapService
import joptsimple.ArgumentAcceptingOptionSpec
import joptsimple.OptionParser
import joptsimple.OptionSet
@ -18,7 +13,6 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.nio.file.Path
import java.nio.file.Paths
import java.security.PublicKey
import java.util.*
private val log: Logger = LoggerFactory.getLogger(NodeRunner::class.java)
@ -33,15 +27,8 @@ class NodeRunner {
with(cliParams) {
val networkMapNodeInfo =
if (networkMapName != null && networkMapPublicKey != null && networkMapAddress != null) {
NodeInfo(
address = ArtemisMessagingClient.makeNetworkMapAddress(networkMapAddress),
identity = Party(
name = networkMapName,
owningKey = networkMapPublicKey
),
advertisedServices = setOf(NetworkMapService.Type)
)
if (networkMapAddress != null) {
ArtemisMessagingClient.makeNetworkMapAddress(networkMapAddress)
} else {
null
}
@ -70,8 +57,6 @@ class NodeRunner {
class CliParams (
val services: Set<ServiceType>,
val networkMapName: String?,
val networkMapPublicKey: PublicKey?,
val networkMapAddress: HostAndPort?,
val messagingAddress: HostAndPort,
val apiAddress: HostAndPort,
@ -82,10 +67,6 @@ class NodeRunner {
val parser = OptionParser()
val services =
parser.accepts("services").withRequiredArg().ofType(String::class.java)
val networkMapName =
parser.accepts("network-map-name").withOptionalArg().ofType(String::class.java)
val networkMapPublicKey =
parser.accepts("network-map-public-key").withOptionalArg().ofType(String::class.java)
val networkMapAddress =
parser.accepts("network-map-address").withOptionalArg().ofType(String::class.java)
val messagingAddress =
@ -100,8 +81,6 @@ class NodeRunner {
fun parse(optionSet: OptionSet): CliParams {
val services = optionSet.valuesOf(services)
val networkMapName = optionSet.valueOf(networkMapName)
val networkMapPublicKey = optionSet.valueOf(networkMapPublicKey)?.run { parsePublicKeyBase58(this) }
val networkMapAddress = optionSet.valueOf(networkMapAddress)
val messagingAddress = requiredArgument(optionSet, messagingAddress)
val apiAddress = requiredArgument(optionSet, apiAddress)
@ -112,8 +91,6 @@ class NodeRunner {
messagingAddress = HostAndPort.fromString(messagingAddress),
apiAddress = HostAndPort.fromString(apiAddress),
baseDirectory = baseDirectory,
networkMapName = networkMapName,
networkMapPublicKey = networkMapPublicKey,
networkMapAddress = networkMapAddress?.let { HostAndPort.fromString(it) }
)
}
@ -125,14 +102,6 @@ class NodeRunner {
cliArguments.add("--services")
cliArguments.addAll(services.map { it.toString() })
}
if (networkMapName != null) {
cliArguments.add("--network-map-name")
cliArguments.add(networkMapName)
}
if (networkMapPublicKey != null) {
cliArguments.add("--network-map-public-key")
cliArguments.add(networkMapPublicKey.toBase58String())
}
if (networkMapAddress != null) {
cliArguments.add("--network-map-address")
cliArguments.add(networkMapAddress.toString())

View File

@ -6,6 +6,7 @@ import com.google.common.util.concurrent.MoreExecutors
import com.google.common.util.concurrent.SettableFuture
import com.r3corda.core.RunOnCallerThread
import com.r3corda.core.crypto.Party
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.messaging.runOnNextMessage
import com.r3corda.core.node.CityDatabase
import com.r3corda.core.node.CordaPluginRegistry
@ -69,7 +70,7 @@ import java.util.concurrent.TimeUnit
// TODO: Where this node is the initial network map service, currently no networkMapService is provided.
// In theory the NodeInfo for the node should be passed in, instead, however currently this is constructed by the
// AbstractNode. It should be possible to generate the NodeInfo outside of AbstractNode, so it can be passed in.
abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, val networkMapService: NodeInfo?,
abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, val networkMapService: SingleMessageRecipient?,
val advertisedServices: Set<ServiceType>, val platformClock: Clock): SingletonSerializeAsToken() {
companion object {
val PRIVATE_KEY_FILE_NAME = "identity-private-key"
@ -277,11 +278,11 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
* updates) if one has been supplied.
*/
private fun registerWithNetworkMap(): ListenableFuture<Unit> {
require(networkMapService == null || NetworkMapService.Type in networkMapService.advertisedServices) {
require(networkMapService != null || NetworkMapService.Type in advertisedServices) {
"Initial network map address must indicate a node that provides a network map service"
}
services.networkMapCache.addNode(info)
if (networkMapService != null && networkMapService != info) {
if (networkMapService != null) {
// Only register if we are pointed at a network map service and it's not us.
// TODO: Return a future so the caller knows these operations may not have completed yet, and can monitor if needed
updateRegistration(networkMapService, AddOrRemove.ADD)
@ -291,7 +292,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
if (inNodeNetworkMapService == null)
return noNetworkMapConfigured()
// Register for updates, even if we're the one running the network map.
return services.networkMapCache.addMapService(net, info, true, null)
return services.networkMapCache.addMapService(net, info.address, true, null)
}
/** This is overriden by the mock node implementation to enable operation without any network map service */
@ -301,7 +302,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
"has any other map node been configured.")
}
private fun updateRegistration(serviceInfo: NodeInfo, type: AddOrRemove): ListenableFuture<NetworkMapService.RegistrationResponse> {
private fun updateRegistration(networkMapAddr: SingleMessageRecipient, type: AddOrRemove): ListenableFuture<NetworkMapService.RegistrationResponse> {
// Register this node against the network
val expires = platformClock.instant() + NetworkMapService.DEFAULT_EXPIRATION_PERIOD
val reg = NodeRegistration(info, networkMapSeq++, type, expires)
@ -313,7 +314,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
net.runOnNextMessage(REGISTER_PROTOCOL_TOPIC, sessionID, RunOnCallerThread) { message ->
future.set(message.data.deserialize())
}
net.send(message, serviceInfo.address)
net.send(message, networkMapAddr)
return future
}
@ -339,8 +340,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
protected open fun makeIdentityService(): IdentityService {
val service = InMemoryIdentityService()
if (networkMapService != null)
service.registerIdentity(networkMapService.identity)
service.registerIdentity(storage.myLegalIdentity)
services.networkMapCache.partyNodes.forEach { service.registerIdentity(it.identity) }

View File

@ -2,6 +2,7 @@ package com.r3corda.node.internal
import com.codahale.metrics.JmxReporter
import com.google.common.net.HostAndPort
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.ServiceHub
import com.r3corda.core.node.services.ServiceType
@ -53,7 +54,7 @@ class ConfigurationException(message: String) : Exception(message)
* @param messagingServerAddr The address of the Artemis broker instance. If not provided the node will run one locally.
*/
class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
configuration: NodeConfiguration, networkMapAddress: NodeInfo?,
configuration: NodeConfiguration, networkMapAddress: SingleMessageRecipient?,
advertisedServices: Set<ServiceType>, clock: Clock = NodeClock(),
val messagingServerAddr: HostAndPort? = null) : AbstractNode(dir, configuration, networkMapAddress, advertisedServices, clock) {
companion object {

View File

@ -3,6 +3,7 @@ package com.r3corda.node.services.config
import com.google.common.net.HostAndPort
import com.r3corda.core.crypto.Party
import com.r3corda.core.crypto.generateKeyPair
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.services.ServiceType
import com.r3corda.node.internal.Node
@ -122,9 +123,8 @@ class FullNodeConfiguration(conf: Config) : NodeConfiguration {
advertisedServices.add(object : ServiceType(serviceId) {})
}
}
// TODO Node startup should not need a full NodeInfo for the remote NetworkMapService provider as bootstrap
val networkMapBootstrapIdentity = Party(mapService.identity, generateKeyPair().public)
val networkMapAddress: NodeInfo? = if (mapService.hostServiceLocally) null else NodeInfo(networkMapTarget, networkMapBootstrapIdentity, setOf(NetworkMapService.Type))
val networkMapAddress: SingleMessageRecipient? = if (mapService.hostServiceLocally) null else networkMapTarget
return Node(basedir.toAbsolutePath().normalize(),
artemisAddress,
webAddress,

View File

@ -3,6 +3,7 @@ package com.r3corda.node.services.messaging
import com.google.common.net.HostAndPort
import com.r3corda.core.ThreadBox
import com.r3corda.core.crypto.newSecureRandom
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.services.NetworkMapCache
import com.r3corda.core.utilities.loggerFor
@ -67,8 +68,8 @@ class ArtemisMessagingServer(directory: Path,
running = false
}
fun bridgeToNetworkMapService(networkMapService: NodeInfo?) {
if ((networkMapService != null) && (networkMapService.address is NetworkMapAddress)) {
fun bridgeToNetworkMapService(networkMapService: SingleMessageRecipient?) {
if ((networkMapService != null) && (networkMapService is NetworkMapAddress)) {
val query = activeMQServer.queueQuery(NETWORK_MAP_ADDRESS)
if (!query.isExists) {
activeMQServer.createQueue(NETWORK_MAP_ADDRESS, NETWORK_MAP_ADDRESS, null, true, false)
@ -87,7 +88,7 @@ class ArtemisMessagingServer(directory: Path,
val query = activeMQServer.queueQuery(queueName)
if (query.isExists) {
// Queue exists so now wire up bridge
maybeDeployBridgeForAddress(queueName, change.node)
maybeDeployBridgeForAddress(queueName, change.node.address)
}
}
@ -99,7 +100,7 @@ class ArtemisMessagingServer(directory: Path,
val query = activeMQServer.queueQuery(queueName)
if (query.isExists) {
// Deploy new bridge
maybeDeployBridgeForAddress(queueName, change.node)
maybeDeployBridgeForAddress(queueName, change.node.address)
}
}
@ -135,7 +136,7 @@ class ArtemisMessagingServer(directory: Path,
if (identity != null) {
val nodeInfo = networkMapCache.getNodeByPublicKey(identity)
if (nodeInfo != null) {
maybeDeployBridgeForAddress(queueName, nodeInfo)
maybeDeployBridgeForAddress(queueName, nodeInfo.address)
}
}
}
@ -191,8 +192,8 @@ class ArtemisMessagingServer(directory: Path,
* For every queue created we need to have a bridge deployed in case the address of the queue
* is that of a remote party
*/
private fun maybeDeployBridgeForAddress(name: SimpleString, nodeInfo: NodeInfo) {
val hostAndPort = toHostAndPort(nodeInfo.address)
private fun maybeDeployBridgeForAddress(name: SimpleString, address: SingleMessageRecipient) {
val hostAndPort = toHostAndPort(address)
if (hostAndPort == myHostPort) {
return

View File

@ -6,6 +6,7 @@ import com.google.common.util.concurrent.SettableFuture
import com.r3corda.core.contracts.Contract
import com.r3corda.core.crypto.Party
import com.r3corda.core.messaging.MessagingService
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.messaging.runOnNextMessage
import com.r3corda.core.messaging.send
import com.r3corda.core.node.NodeInfo
@ -57,7 +58,7 @@ open class InMemoryNetworkMapCache : SingletonSerializeAsToken(), NetworkMapCach
override fun getNodeByLegalName(name: String) = get().singleOrNull { it.identity.name == name }
override fun getNodeByPublicKey(publicKey: PublicKey) = get().singleOrNull { it.identity.owningKey == publicKey }
override fun addMapService(net: MessagingService, service: NodeInfo, subscribe: Boolean,
override fun addMapService(net: MessagingService, networkMapAddress: SingleMessageRecipient, subscribe: Boolean,
ifChangedSinceVer: Int?): ListenableFuture<Unit> {
if (subscribe && !registeredForPush) {
// Add handler to the network, for updates received from the remote network map service.
@ -90,7 +91,7 @@ open class InMemoryNetworkMapCache : SingletonSerializeAsToken(), NetworkMapCach
resp.nodes?.forEach { processRegistration(it) }
future.set(Unit)
}
net.send(NetworkMapService.FETCH_PROTOCOL_TOPIC, DEFAULT_SESSION_ID, req, service.address)
net.send(NetworkMapService.FETCH_PROTOCOL_TOPIC, DEFAULT_SESSION_ID, req, networkMapAddress)
return future
}

View File

@ -3,6 +3,7 @@ package com.r3corda.node.messaging
import com.r3corda.core.contracts.Attachment
import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.crypto.sha256
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.services.ServiceType
import com.r3corda.core.serialization.OpaqueBytes
@ -87,7 +88,7 @@ class AttachmentTests {
fun `malicious response`() {
// Make a node that doesn't do sanity checking at load time.
val n0 = network.createNode(null, -1, object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: NodeInfo?,
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: SingleMessageRecipient?,
advertisedServices: Set<ServiceType>, id: Int, keyPair: KeyPair?): MockNetwork.MockNode {
return object : MockNetwork.MockNode(dir, config, network, networkMapAddr, advertisedServices, id, keyPair) {
override fun start(): MockNetwork.MockNode {
@ -98,7 +99,7 @@ class AttachmentTests {
}
}
}, true, null, null, false, NetworkMapService.Type, SimpleNotaryService.Type)
val n1 = network.createNode(n0.info)
val n1 = network.createNode(n0.info.address)
// Insert an attachment into node zero's store directly.
val id = n0.storage.attachments.importAttachment(ByteArrayInputStream(fakeAttachment()))

View File

@ -5,6 +5,7 @@ package com.r3corda.node.messaging
import com.r3corda.core.messaging.Message
import com.r3corda.core.messaging.TopicStringValidator
import com.r3corda.core.node.services.DEFAULT_SESSION_ID
import com.r3corda.node.services.network.NetworkMapService
import com.r3corda.testing.node.MockNetwork
import org.junit.Before
import org.junit.Test
@ -38,9 +39,9 @@ class InMemoryMessagingTests {
@Test
fun basics() {
val node1 = network.createNode()
val node2 = network.createNode()
val node3 = network.createNode()
val node1 = network.createNode(advertisedServices = NetworkMapService.Type)
val node2 = network.createNode(networkMapAddress = node1.info.address)
val node3 = network.createNode(networkMapAddress = node1.info.address)
val bits = "test-content".toByteArray()
var finalDelivery: Message? = null
@ -67,9 +68,9 @@ class InMemoryMessagingTests {
@Test
fun broadcast() {
val node1 = network.createNode()
val node2 = network.createNode()
val node3 = network.createNode()
val node1 = network.createNode(advertisedServices = NetworkMapService.Type)
val node2 = network.createNode(networkMapAddress = node1.info.address)
val node3 = network.createNode(networkMapAddress = node1.info.address)
val bits = "test-content".toByteArray()
@ -86,8 +87,8 @@ class InMemoryMessagingTests {
*/
@Test
fun `skip unhandled messages`() {
val node1 = network.createNode()
val node2 = network.createNode()
val node1 = network.createNode(advertisedServices = NetworkMapService.Type)
val node2 = network.createNode(networkMapAddress = node1.info.address)
var received: Int = 0
node1.net.addMessageHandler("valid_message") { msg, reg ->

View File

@ -8,6 +8,7 @@ import com.r3corda.core.contracts.*
import com.r3corda.core.crypto.Party
import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.days
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.ServiceHub
import com.r3corda.core.node.services.ServiceType
@ -93,8 +94,8 @@ class TwoPartyTradeProtocolTests {
ledger {
val notaryNode = net.createNotaryNode(DUMMY_NOTARY.name, DUMMY_NOTARY_KEY)
val aliceNode = net.createPartyNode(notaryNode.info, ALICE.name, ALICE_KEY)
val bobNode = net.createPartyNode(notaryNode.info, BOB.name, BOB_KEY)
val aliceNode = net.createPartyNode(notaryNode.info.address, ALICE.name, ALICE_KEY)
val bobNode = net.createPartyNode(notaryNode.info.address, BOB.name, BOB_KEY)
bobNode.services.fillWithSomeTestCash(2000.DOLLARS)
val alicesFakePaper = fillUpForSeller(false, aliceNode.storage.myLegalIdentity.owningKey,
@ -139,11 +140,11 @@ class TwoPartyTradeProtocolTests {
fun `shutdown and restore`() {
ledger {
val notaryNode = net.createNotaryNode(DUMMY_NOTARY.name, DUMMY_NOTARY_KEY)
val aliceNode = net.createPartyNode(notaryNode.info, ALICE.name, ALICE_KEY)
var bobNode = net.createPartyNode(notaryNode.info, BOB.name, BOB_KEY)
val aliceNode = net.createPartyNode(notaryNode.info.address, ALICE.name, ALICE_KEY)
var bobNode = net.createPartyNode(notaryNode.info.address, BOB.name, BOB_KEY)
val bobAddr = bobNode.net.myAddress as InMemoryMessagingNetwork.Handle
val networkMapAddr = notaryNode.info
val networkMapAddr = notaryNode.info.address
net.runNetwork() // Clear network map registration messages
@ -202,7 +203,7 @@ class TwoPartyTradeProtocolTests {
// ... bring the node back up ... the act of constructing the SMM will re-register the message handlers
// that Bob was waiting on before the reboot occurred.
bobNode = net.createNode(networkMapAddr, bobAddr.id, object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: NodeInfo?,
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: SingleMessageRecipient?,
advertisedServices: Set<ServiceType>, id: Int, keyPair: KeyPair?): MockNetwork.MockNode {
return MockNetwork.MockNode(dir, config, network, networkMapAddr, advertisedServices, bobAddr.id, BOB_KEY)
}
@ -229,10 +230,10 @@ class TwoPartyTradeProtocolTests {
// 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(networkMapAddr: NodeInfo?, name: String, keyPair: KeyPair): MockNetwork.MockNode {
private fun makeNodeWithTracking(networkMapAddr: SingleMessageRecipient?, name: String, keyPair: KeyPair): MockNetwork.MockNode {
// Create a node in the mock network ...
return net.createNode(networkMapAddr, -1, object : MockNetwork.Factory {
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: NodeInfo?,
override fun create(dir: Path, config: NodeConfiguration, network: MockNetwork, networkMapAddr: SingleMessageRecipient?,
advertisedServices: Set<ServiceType>, id: Int, keyPair: KeyPair?): MockNetwork.MockNode {
return object : MockNetwork.MockNode(dir, config, network, networkMapAddr, advertisedServices, id, keyPair) {
// That constructs the storage service object in a customised way ...
@ -250,8 +251,8 @@ class TwoPartyTradeProtocolTests {
@Test
fun `check dependencies of sale asset are resolved`() {
val notaryNode = net.createNotaryNode(DUMMY_NOTARY.name, DUMMY_NOTARY_KEY)
val aliceNode = makeNodeWithTracking(notaryNode.info, ALICE.name, ALICE_KEY)
val bobNode = makeNodeWithTracking(notaryNode.info, BOB.name, BOB_KEY)
val aliceNode = makeNodeWithTracking(notaryNode.info.address, ALICE.name, ALICE_KEY)
val bobNode = makeNodeWithTracking(notaryNode.info.address, BOB.name, BOB_KEY)
ledger(aliceNode.services) {
@ -371,8 +372,8 @@ class TwoPartyTradeProtocolTests {
expectedMessageSubstring: String
) {
val notaryNode = net.createNotaryNode(DUMMY_NOTARY.name, DUMMY_NOTARY_KEY)
val aliceNode = net.createPartyNode(notaryNode.info, ALICE.name, ALICE_KEY)
val bobNode = net.createPartyNode(notaryNode.info, BOB.name, BOB_KEY)
val aliceNode = net.createPartyNode(notaryNode.info.address, ALICE.name, ALICE_KEY)
val bobNode = net.createPartyNode(notaryNode.info.address, BOB.name, BOB_KEY)
val issuer = MEGA_CORP.ref(1, 2, 3)
val bobKey = bobNode.keyManagement.freshKey()

View File

@ -16,7 +16,7 @@ class InMemoryNetworkMapCacheTest {
fun registerWithNetwork() {
val (n0, n1) = network.createTwoNodes()
val future = n1.services.networkMapCache.addMapService(n1.net, n0.info, false, null)
val future = n1.services.networkMapCache.addMapService(n1.net, n0.info.address, false, null)
network.runNetwork()
future.get()
}

View File

@ -37,9 +37,9 @@ class NotaryChangeTests {
legalName = DUMMY_NOTARY.name,
keyPair = DUMMY_NOTARY_KEY,
advertisedServices = *arrayOf(NetworkMapService.Type, SimpleNotaryService.Type))
clientNodeA = net.createNode(networkMapAddress = oldNotaryNode.info)
clientNodeB = net.createNode(networkMapAddress = oldNotaryNode.info)
newNotaryNode = net.createNode(networkMapAddress = oldNotaryNode.info, advertisedServices = SimpleNotaryService.Type)
clientNodeA = net.createNode(networkMapAddress = oldNotaryNode.info.address)
clientNodeB = net.createNode(networkMapAddress = oldNotaryNode.info.address)
newNotaryNode = net.createNode(networkMapAddress = oldNotaryNode.info.address, advertisedServices = SimpleNotaryService.Type)
net.runNetwork() // Clear network map registration messages
}

View File

@ -32,7 +32,7 @@ class NotaryServiceTests {
keyPair = DUMMY_NOTARY_KEY,
advertisedServices = *arrayOf(NetworkMapService.Type, SimpleNotaryService.Type)
)
clientNode = net.createNode(networkMapAddress = notaryNode.info, keyPair = MINI_CORP_KEY)
clientNode = net.createNode(networkMapAddress = notaryNode.info.address, keyPair = MINI_CORP_KEY)
net.runNetwork() // Clear network map registration messages
}

View File

@ -32,7 +32,7 @@ class ValidatingNotaryServiceTests {
keyPair = DUMMY_NOTARY_KEY,
advertisedServices = *arrayOf(NetworkMapService.Type, ValidatingNotaryService.Type)
)
clientNode = net.createNode(networkMapAddress = notaryNode.info, keyPair = MINI_CORP_KEY)
clientNode = net.createNode(networkMapAddress = notaryNode.info.address, keyPair = MINI_CORP_KEY)
net.runNetwork() // Clear network map registration messages
}

View File

@ -3,7 +3,7 @@ package com.r3corda.node.services.statemachine
import co.paralleluniverse.fibers.Fiber
import co.paralleluniverse.fibers.Suspendable
import com.r3corda.core.crypto.Party
import com.r3corda.core.node.NodeInfo
import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.protocols.ProtocolLogic
import com.r3corda.core.random63BitValue
import com.r3corda.testing.node.MockNetwork
@ -55,12 +55,13 @@ class StateMachineManagerTests {
node2.smm.add("test", ReceiveProtocol(topic, sessionID))
net.runNetwork()
node2.stop()
val restoredProtocol = node2.restartAndGetRestoredProtocol<ReceiveProtocol>(node1.info)
val restoredProtocol = node2.restartAndGetRestoredProtocol<ReceiveProtocol>(node1.info.address)
assertThat(restoredProtocol.receivedPayload).isEqualTo(payload)
}
private inline fun <reified P : NonTerminatingProtocol> MockNode.restartAndGetRestoredProtocol(networkMapAddress: NodeInfo? = null): P {
val node = mockNet.createNode(networkMapAddress, id)
private inline fun <reified P : NonTerminatingProtocol> MockNode.restartAndGetRestoredProtocol(networkMapAddress: SingleMessageRecipient? = null): P {
val servicesArray = advertisedServices.toTypedArray()
val node = mockNet.createNode(networkMapAddress, id, advertisedServices = *servicesArray)
return node.smm.findStateMachines(P::class.java).single().first
}