Fix a race condition in the MockNode class that only shows up when used in thread-per-node mode. Witnessed in the unit tests.

This commit is contained in:
Mike Hearn 2016-07-06 14:00:29 +01:00
parent c38f99419f
commit f6e7ffdd31

View File

@ -121,7 +121,11 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false,
override val nearestCity: String = "Atlantis"
}
val node = nodeFactory.create(path, config, this, networkMapAddress, advertisedServices.toSet(), id, keyPair)
if (start) node.setup().start()
if (start) {
node.setup().start()
if (threadPerNode && networkMapAddress != null)
node.networkMapRegistrationFuture.get() // Block and wait for the node to register in the net map.
}
_nodes.add(node)
return node
}