mirror of
https://github.com/corda/corda.git
synced 2025-06-22 09:08:49 +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:
committed by
GitHub
parent
d3de125166
commit
58c25b1115
@ -8,6 +8,7 @@ import net.corda.core.*
|
||||
import net.corda.core.crypto.entropyToKeyPair
|
||||
import net.corda.flows.TxKeyFlow
|
||||
import net.corda.core.identity.PartyAndCertificate
|
||||
import net.corda.core.messaging.MessageRecipients
|
||||
import net.corda.core.messaging.RPCOps
|
||||
import net.corda.core.messaging.SingleMessageRecipient
|
||||
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.
|
||||
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() {
|
||||
require(nodes.isNotEmpty())
|
||||
|
Reference in New Issue
Block a user