aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Song <jaejoon@gmail.com>2017-04-25 07:26:43 -0700
committerJimmy Song <jaejoon@gmail.com>2017-04-25 10:17:04 -0700
commit1b144495d006e49999eb396858610eb817d99d38 (patch)
tree5a51deb6eb92484eaa8f559e03339dbd5bdb090e
parente0a7e1994e6f3ebbf076feb50552440a365fd317 (diff)
[test] Add Unit Test for GetListenPort
Add very basic unit test for GetListenPort in net_tests.cpp
-rw-r--r--src/test/net_tests.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index b9ed4952bb..0c7f3e5e23 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -11,6 +11,7 @@
#include "net.h"
#include "netbase.h"
#include "chainparams.h"
+#include "util.h"
class CAddrManSerializationMock : public CAddrMan
{
@@ -72,6 +73,18 @@ CDataStream AddrmanToStream(CAddrManSerializationMock& _addrman)
BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
+BOOST_AUTO_TEST_CASE(cnode_listen_port)
+{
+ // test default
+ unsigned short port = GetListenPort();
+ BOOST_CHECK(port == Params().GetDefaultPort());
+ // test set port
+ unsigned short altPort = 12345;
+ SoftSetArg("-port", std::to_string(altPort));
+ port = GetListenPort();
+ BOOST_CHECK(port == altPort);
+}
+
BOOST_AUTO_TEST_CASE(caddrdb_read)
{
CAddrManUncorrupted addrmanUncorrupted;