Skip to content

Commit f3c45e9

Browse files
authored
Merge pull request #7677 from corda/adel/ENT-11504
ENT-11504: Bind to the same address that the server socket created.
2 parents db9017f + 0000c75 commit f3c45e9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

node/src/integration-test/kotlin/net/corda/node/AddressBindingFailureTests.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ import net.corda.testing.driver.internal.incrementalPortAllocation
1010
import net.corda.testing.node.NotarySpec
1111
import org.assertj.core.api.Assertions.assertThat
1212
import org.assertj.core.api.Assertions.assertThatThrownBy
13-
import org.junit.Ignore
1413
import org.junit.Test
1514
import java.net.InetSocketAddress
1615
import java.net.ServerSocket
1716

18-
@Ignore("TODO JDK17: Fixme")
1917
class AddressBindingFailureTests {
2018

2119
companion object {
2220
private val portAllocation = incrementalPortAllocation()
2321
}
2422

2523
@Test(timeout=300_000)
26-
fun `p2p address`() = assertBindExceptionForOverrides { address -> mapOf("p2pAddress" to address.toString()) }
24+
fun `p2p address`() = assertBindExceptionForOverrides("localhost") { address -> mapOf("p2pAddress" to address.toString()) }
2725

2826
@Test(timeout=300_000)
2927
fun `rpc address`() = assertBindExceptionForOverrides { address -> mapOf("rpcSettings" to mapOf("address" to address.toString())) }
@@ -54,11 +52,12 @@ class AddressBindingFailureTests {
5452
}
5553
}
5654

57-
private fun assertBindExceptionForOverrides(overrides: (NetworkHostAndPort) -> Map<String, Any?>) {
55+
private fun assertBindExceptionForOverrides(bindAddress: String? = null, overrides: (NetworkHostAndPort) -> Map<String, Any?>) {
5856

5957
ServerSocket(0).use { socket ->
6058

61-
val address = InetSocketAddress("localhost", socket.localPort).toNetworkHostAndPort()
59+
val address = bindAddress?.let { InetSocketAddress(it, socket.localPort).toNetworkHostAndPort() } ?:
60+
InetSocketAddress(socket.inetAddress, socket.localPort).toNetworkHostAndPort()
6261
driver(DriverParameters(startNodesInProcess = true,
6362
notarySpecs = emptyList(),
6463
inMemoryDB = false,

0 commit comments

Comments
 (0)