Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2024 Status Research & Development GmbH. Licensed under
# Copyright (c) 2019-2025 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
Expand Down Expand Up @@ -210,10 +210,10 @@ libbacktrace:
# - --base-el-rpc-port + --el-port-offset * [0, --nodes + --light-clients)
# - --base-el-ws-port + --el-port-offset * [0, --nodes + --light-clients)
# - --base-el-auth-rpc-port + --el-port-offset * [0, --nodes + --light-clients)
UNIT_TEST_BASE_PORT := 9960
REST_TEST_BASE_PORT := 9990
MINIMAL_TESTNET_BASE_PORT := 5001
MAINNET_TESTNET_BASE_PORT := 6501
UNIT_TEST_BASE_PORT := 39960
REST_TEST_BASE_PORT := 40990
MINIMAL_TESTNET_BASE_PORT := 35001
MAINNET_TESTNET_BASE_PORT := 36501
Comment on lines +213 to +216
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeral ports could be in use randomly, https://en.wikipedia.org/wiki/Ephemeral_port#Range - unfortunately it's quite platform specific which OS uses what ports.

Copy link
Copy Markdown
Member

@richard-ramos richard-ramos Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps something like this would work? (after replacing nim by $(ENV_SCRIPT) $(NIMC). That way the port numbers wouldn't have to be hardcoded, and the port number would be obtained by nim automatically regardless of the OS being used.

UNIT_TEST_BASE_PORT := $(shell nim r -d:release --eval:"import net; let s=newSocket(); s.bindAddr(Port(0)); echo s.getLocalAddr()[1]; s.close()")
REST_TEST_BASE_PORT := $(shell nim r -d:release --eval:"import net; let s=newSocket(); s.bindAddr(Port(0)); echo s.getLocalAddr()[1]; s.close()")
MINIMAL_TESTNET_BASE_PORT := $(shell nim r -d:release --eval:"import net; let s=newSocket(); s.bindAddr(Port(0)); echo s.getLocalAddr()[1]; s.close()")
MAINNET_TESTNET_BASE_PORT := $(shell nim r -d:release --eval:"import net; let s=newSocket(); s.bindAddr(Port(0)); echo s.getLocalAddr()[1]; s.close()")

main:
	@echo "Port1: $(UNIT_TEST_BASE_PORT)"
	@echo "Port2: $(REST_TEST_BASE_PORT)"
	@echo "Port3: $(MINIMAL_TESTNET_BASE_PORT)"
	@echo "Port4: $(MAINNET_TESTNET_BASE_PORT)"

Copy link
Copy Markdown
Contributor Author

@cheatfate cheatfate Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, but it will not work because there is a big gap in time between this variables being used and your incredible script being executed.
One more thing, your script does not work when executed many times, it will always provide you with same port number.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, there are entire ranges of port being used that add on top of the base port xD With the script you could even get the same port multiple times.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well. RIP my script idea
image


restapi-test:
./tests/simulation/restapi.sh \
Expand Down