-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust default port numbers for tests. #6849
Conversation
UNIT_TEST_BASE_PORT := 39960 | ||
REST_TEST_BASE_PORT := 40990 | ||
MINIMAL_TESTNET_BASE_PORT := 35001 | ||
MAINNET_TESTNET_BASE_PORT := 36501 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.