mirror of
https://github.com/corda/corda.git
synced 2025-01-30 08:04:16 +00:00
Merge pull request #7677 from corda/adel/ENT-11504
ENT-11504: Bind to the same address that the server socket created.
This commit is contained in:
commit
f3c45e9d1b
@ -10,12 +10,10 @@ import net.corda.testing.driver.internal.incrementalPortAllocation
|
|||||||
import net.corda.testing.node.NotarySpec
|
import net.corda.testing.node.NotarySpec
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.junit.Ignore
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.net.ServerSocket
|
import java.net.ServerSocket
|
||||||
|
|
||||||
@Ignore("TODO JDK17: Fixme")
|
|
||||||
class AddressBindingFailureTests {
|
class AddressBindingFailureTests {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -23,7 +21,7 @@ class AddressBindingFailureTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `p2p address`() = assertBindExceptionForOverrides { address -> mapOf("p2pAddress" to address.toString()) }
|
fun `p2p address`() = assertBindExceptionForOverrides("localhost") { address -> mapOf("p2pAddress" to address.toString()) }
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `rpc address`() = assertBindExceptionForOverrides { address -> mapOf("rpcSettings" to mapOf("address" to address.toString())) }
|
fun `rpc address`() = assertBindExceptionForOverrides { address -> mapOf("rpcSettings" to mapOf("address" to address.toString())) }
|
||||||
@ -54,11 +52,12 @@ class AddressBindingFailureTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertBindExceptionForOverrides(overrides: (NetworkHostAndPort) -> Map<String, Any?>) {
|
private fun assertBindExceptionForOverrides(bindAddress: String? = null, overrides: (NetworkHostAndPort) -> Map<String, Any?>) {
|
||||||
|
|
||||||
ServerSocket(0).use { socket ->
|
ServerSocket(0).use { socket ->
|
||||||
|
|
||||||
val address = InetSocketAddress("localhost", socket.localPort).toNetworkHostAndPort()
|
val address = bindAddress?.let { InetSocketAddress(it, socket.localPort).toNetworkHostAndPort() } ?:
|
||||||
|
InetSocketAddress(socket.inetAddress, socket.localPort).toNetworkHostAndPort()
|
||||||
driver(DriverParameters(startNodesInProcess = true,
|
driver(DriverParameters(startNodesInProcess = true,
|
||||||
notarySpecs = emptyList(),
|
notarySpecs = emptyList(),
|
||||||
inMemoryDB = false,
|
inMemoryDB = false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user