From ee66fb49d7f350753ea4580f6057f2431136f530 Mon Sep 17 00:00:00 2001 From: Raphael Salas Date: Thu, 27 Jun 2024 11:55:09 -0400 Subject: [PATCH] test(network): port assignment invariants --- packages/network/test/network-misc.test.js | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/network/test/network-misc.test.js b/packages/network/test/network-misc.test.js index 139253d86d2..968cdf41339 100644 --- a/packages/network/test/network-misc.test.js +++ b/packages/network/test/network-misc.test.js @@ -82,12 +82,29 @@ test('verify port allocation', async t => { const ibcPort = await when(portAllocator.allocateCustomIBCPort()); t.is(ibcPort.getLocalAddress(), '/ibc-port/port-1'); + const ibcPort2 = await when(portAllocator.allocateCustomIBCPort()); + t.not( + ibcPort.getLocalAddress(), + ibcPort2.getLocalAddress(), + 'unique ports must not collide', + ); + t.is(ibcPort2.getLocalAddress(), '/ibc-port/port-2'); const namedIbcPort = await when( portAllocator.allocateCustomIBCPort('test-1'), ); t.is(namedIbcPort.getLocalAddress(), '/ibc-port/custom-test-1'); + const ibcDuplicatePort = await when( + portAllocator.allocateCustomIBCPort('port-1'), + ); + t.not( + ibcPort.getLocalAddress(), + ibcDuplicatePort.getLocalAddress(), + 'named ports should not collide with unique ports', + ); + t.is(ibcDuplicatePort.getLocalAddress(), '/ibc-port/custom-port-1'); + const icaControllerPort1 = await when( portAllocator.allocateICAControllerPort(), ); @@ -99,12 +116,21 @@ test('verify port allocation', async t => { t.is(icaControllerPort2.getLocalAddress(), '/ibc-port/icacontroller-2'); const localPort = await when(portAllocator.allocateCustomLocalPort()); - t.is(localPort.getLocalAddress(), '/local/port-5'); + t.is(localPort.getLocalAddress(), '/local/port-7'); const namedLocalPort = await when( portAllocator.allocateCustomLocalPort('local-1'), ); t.is(namedLocalPort.getLocalAddress(), '/local/custom-local-1'); + const namedDuplicatePort = await when( + portAllocator.allocateCustomLocalPort('port-7'), + ); + t.not( + namedLocalPort.getLocalAddress(), + namedDuplicatePort.getLocalAddress(), + 'named ports should not collide with unique ports', + ); + t.is(namedDuplicatePort.getLocalAddress(), '/local/custom-port-7'); await t.throwsAsync(when(portAllocator.allocateCustomIBCPort('/test-1')), { message: 'Invalid IBC port name: /test-1',