mirror of
https://github.com/corda/corda.git
synced 2024-12-24 07:06:44 +00:00
Fix bug in network simulator. (#830)
Fix bug in network simulator. It failed on cast when requesting signatures from notary, now it's not a SingleMessageRecipient but InMemoryMessagingNetwork.ServiceHandle.
This commit is contained in:
parent
d3de125166
commit
58c25b1115
@ -12,7 +12,6 @@ import javafx.scene.layout.VBox
|
|||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
import javafx.util.Duration
|
import javafx.util.Duration
|
||||||
import net.corda.core.crypto.commonName
|
import net.corda.core.crypto.commonName
|
||||||
import net.corda.core.messaging.SingleMessageRecipient
|
|
||||||
import net.corda.core.serialization.deserialize
|
import net.corda.core.serialization.deserialize
|
||||||
import net.corda.core.then
|
import net.corda.core.then
|
||||||
import net.corda.core.utilities.ProgressTracker
|
import net.corda.core.utilities.ProgressTracker
|
||||||
@ -112,7 +111,7 @@ class NetworkMapVisualiser : Application() {
|
|||||||
// Fire the message bullets between nodes.
|
// Fire the message bullets between nodes.
|
||||||
simulation.mockNet.messagingNetwork.sentMessages.observeOn(uiThread).subscribe { msg: InMemoryMessagingNetwork.MessageTransfer ->
|
simulation.mockNet.messagingNetwork.sentMessages.observeOn(uiThread).subscribe { msg: InMemoryMessagingNetwork.MessageTransfer ->
|
||||||
val senderNode: MockNetwork.MockNode = simulation.mockNet.addressToNode(msg.sender)
|
val senderNode: MockNetwork.MockNode = simulation.mockNet.addressToNode(msg.sender)
|
||||||
val destNode: MockNetwork.MockNode = simulation.mockNet.addressToNode(msg.recipients as SingleMessageRecipient)
|
val destNode: MockNetwork.MockNode = simulation.mockNet.addressToNode(msg.recipients)
|
||||||
|
|
||||||
if (transferIsInteresting(msg)) {
|
if (transferIsInteresting(msg)) {
|
||||||
viewModel.nodesToWidgets[senderNode]!!.pulseAnim.play()
|
viewModel.nodesToWidgets[senderNode]!!.pulseAnim.play()
|
||||||
|
@ -8,6 +8,7 @@ import net.corda.core.*
|
|||||||
import net.corda.core.crypto.entropyToKeyPair
|
import net.corda.core.crypto.entropyToKeyPair
|
||||||
import net.corda.flows.TxKeyFlow
|
import net.corda.flows.TxKeyFlow
|
||||||
import net.corda.core.identity.PartyAndCertificate
|
import net.corda.core.identity.PartyAndCertificate
|
||||||
|
import net.corda.core.messaging.MessageRecipients
|
||||||
import net.corda.core.messaging.RPCOps
|
import net.corda.core.messaging.RPCOps
|
||||||
import net.corda.core.messaging.SingleMessageRecipient
|
import net.corda.core.messaging.SingleMessageRecipient
|
||||||
import net.corda.core.node.CordaPluginRegistry
|
import net.corda.core.node.CordaPluginRegistry
|
||||||
@ -385,7 +386,16 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused") // This is used from the network visualiser tool.
|
@Suppress("unused") // This is used from the network visualiser tool.
|
||||||
fun addressToNode(address: SingleMessageRecipient): MockNode = nodes.single { it.network.myAddress == address }
|
fun addressToNode(msgRecipient: MessageRecipients): MockNode {
|
||||||
|
return when (msgRecipient) {
|
||||||
|
is SingleMessageRecipient -> nodes.single { it.network.myAddress == msgRecipient }
|
||||||
|
is InMemoryMessagingNetwork.ServiceHandle -> {
|
||||||
|
nodes.filter { it.advertisedServices.any { it == msgRecipient.service.info } }.firstOrNull()
|
||||||
|
?: throw IllegalArgumentException("Couldn't find node advertising service with info: ${msgRecipient.service.info} ")
|
||||||
|
}
|
||||||
|
else -> throw IllegalArgumentException("Method not implemented for different type of message recipients")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun startNodes() {
|
fun startNodes() {
|
||||||
require(nodes.isNotEmpty())
|
require(nodes.isNotEmpty())
|
||||||
|
Loading…
Reference in New Issue
Block a user