@@ -89,7 +89,7 @@ class AddrManTest : public AddrMan
8989 deterministic = makeDeterministic;
9090 }
9191
92- AddrInfo* Find (const CNetAddr & addr, int * pnId = nullptr )
92+ AddrInfo* Find (const CService & addr, int * pnId = nullptr )
9393 {
9494 LOCK (m_impl->cs );
9595 return m_impl->Find (addr, pnId);
@@ -222,15 +222,15 @@ BOOST_AUTO_TEST_CASE(addrman_ports)
222222 BOOST_CHECK_EQUAL (addrman.size (), 1U );
223223
224224 CService addr1_port = ResolveService (" 250.1.1.1" , 8334 );
225- BOOST_CHECK (! addrman.Add ({CAddress (addr1_port, NODE_NONE)}, source));
226- BOOST_CHECK_EQUAL (addrman.size (), 1U );
225+ BOOST_CHECK (addrman.Add ({CAddress (addr1_port, NODE_NONE)}, source));
226+ BOOST_CHECK_EQUAL (addrman.size (), 2U );
227227 auto addr_ret2 = addrman.Select ().first ;
228- BOOST_CHECK_EQUAL (addr_ret2.ToString (), " 250.1.1.1:8333" );
228+ BOOST_CHECK (addr_ret2.ToString () == " 250.1.1.1:8333" || addr_ret2. ToString () == " 250.1.1.1:8334 " );
229229
230- // Test: Add same IP but diff port to tried table, it doesn't get added.
231- // Perhaps this is not ideal behavior but it is the current behavior .
230+ // Test: Add same IP but diff port to tried table; this converts the entry with
231+ // the specified port to tried, but not the other .
232232 addrman.Good (CAddress (addr1_port, NODE_NONE));
233- BOOST_CHECK_EQUAL (addrman.size (), 1U );
233+ BOOST_CHECK_EQUAL (addrman.size (), 2U );
234234 bool newOnly = true ;
235235 auto addr_ret3 = addrman.Select (newOnly).first ;
236236 BOOST_CHECK_EQUAL (addr_ret3.ToString (), " 250.1.1.1:8333" );
@@ -369,18 +369,18 @@ BOOST_AUTO_TEST_CASE(addrman_find)
369369 CNetAddr source2 = ResolveIP (" 250.1.2.2" );
370370
371371 BOOST_CHECK (addrman.Add ({addr1}, source1));
372- BOOST_CHECK (! addrman.Add ({addr2}, source2));
372+ BOOST_CHECK (addrman.Add ({addr2}, source2));
373373 BOOST_CHECK (addrman.Add ({addr3}, source1));
374374
375- // Test: ensure Find returns an IP matching what we searched on.
375+ // Test: ensure Find returns an IP/port matching what we searched on.
376376 AddrInfo* info1 = addrman.Find (addr1);
377377 BOOST_REQUIRE (info1);
378378 BOOST_CHECK_EQUAL (info1->ToString (), " 250.1.2.1:8333" );
379379
380- // Test 18 ; Find does not discriminate by port number.
380+ // Test; Find discriminates by port number.
381381 AddrInfo* info2 = addrman.Find (addr2);
382382 BOOST_REQUIRE (info2);
383- BOOST_CHECK_EQUAL (info2->ToString (), info1-> ToString () );
383+ BOOST_CHECK_EQUAL (info2->ToString (), " 250.1.2.1:9999 " );
384384
385385 // Test: Find returns another IP matching what we searched on.
386386 AddrInfo* info3 = addrman.Find (addr3);
0 commit comments