Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 242fd6c

Browse files
committed
Add test for ENR updated in NodeTable
1 parent f9ccb51 commit 242fd6c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/unittests/libp2p/net.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,13 +1267,15 @@ BOOST_AUTO_TEST_CASE(changingHostEndpoint)
12671267
auto& nodeTable = nodeTableHost.nodeTable;
12681268

12691269
auto const originalHostEndpoint = nodeTable->m_hostNodeEndpoint;
1270+
auto const originalHostENR = nodeTable->hostENR();
12701271
uint16_t const newPort = originalHostEndpoint.udpPort() + 1;
12711272
auto const newHostEndpoint = NodeIPEndpoint{
12721273
bi::address::from_string(c_localhostIp), newPort, nodeTable->m_hostNodeEndpoint.tcpPort()};
12731274

12741275
for (int i = 0; i < 10; ++i)
12751276
{
12761277
BOOST_CHECK_EQUAL(nodeTable->m_hostNodeEndpoint, originalHostEndpoint);
1278+
BOOST_CHECK(nodeTable->hostENR().signature() == originalHostENR.signature());
12771279

12781280
// socket receiving PING
12791281
TestUDPSocketHost nodeSocketHost;
@@ -1302,7 +1304,12 @@ BOOST_AUTO_TEST_CASE(changingHostEndpoint)
13021304
nodeTable->packetsReceived.pop();
13031305
}
13041306

1305-
BOOST_REQUIRE_EQUAL(nodeTable->m_hostNodeEndpoint, newHostEndpoint);
1307+
BOOST_CHECK_EQUAL(nodeTable->m_hostNodeEndpoint, newHostEndpoint);
1308+
1309+
ENR const newENR = nodeTable->hostENR();
1310+
BOOST_CHECK_EQUAL(newENR.ip(), newHostEndpoint.address());
1311+
BOOST_CHECK_EQUAL(newENR.udpPort(), newHostEndpoint.udpPort());
1312+
BOOST_CHECK_EQUAL(newENR.tcpPort(), newHostEndpoint.tcpPort());
13061313
}
13071314

13081315

0 commit comments

Comments
 (0)