aboutsummaryrefslogtreecommitdiff
path: root/src/test/net_tests.cpp
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2022-06-08 15:22:41 -0400
committerMartin Zumsande <mzumsande@gmail.com>2022-06-10 10:50:07 -0400
commit99b9e5f3a9fa29bbc1e45fc958470fbcc207ef23 (patch)
tree2e750b7e17412ba97ba9e1f5a02937bfb224a1a1 /src/test/net_tests.cpp
parent455780b1aebae21ebd5d83d2f0ff6a2264ac9608 (diff)
downloadbitcoin-99b9e5f3a9fa29bbc1e45fc958470fbcc207ef23.tar.xz
p2p: always set nTime for self-advertisements
If we self-advertised to an inbound peer with the address they gave us, nTime was left default-initialized, so that our peer wouldn't relay it any further along.
Diffstat (limited to 'src/test/net_tests.cpp')
-rw-r--r--src/test/net_tests.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index e7c01bd6d0..115c4b9b24 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -675,10 +675,13 @@ BOOST_AUTO_TEST_CASE(get_local_addr_for_peer_port)
const uint16_t bind_port = 20001;
m_node.args->ForceSetArg("-bind", strprintf("3.4.5.6:%u", bind_port));
+ const uint32_t current_time = static_cast<uint32_t>(GetAdjustedTime());
+ SetMockTime(current_time);
+
// Our address:port as seen from the peer, completely different from the above.
in_addr peer_us_addr;
peer_us_addr.s_addr = htonl(0x02030405);
- const CAddress peer_us{CService{peer_us_addr, 20002}, NODE_NETWORK};
+ const CAddress peer_us{CService{peer_us_addr, 20002}, NODE_NETWORK, current_time};
// Create a peer with a routable IPv4 address (outbound).
in_addr peer_out_in_addr;
@@ -699,7 +702,7 @@ BOOST_AUTO_TEST_CASE(get_local_addr_for_peer_port)
// Without the fix peer_us:8333 is chosen instead of the proper peer_us:bind_port.
auto chosen_local_addr = GetLocalAddrForPeer(&peer_out);
BOOST_REQUIRE(chosen_local_addr);
- const CService expected{peer_us_addr, bind_port};
+ const CAddress expected{CService{peer_us_addr, bind_port}, NODE_NETWORK, current_time};
BOOST_CHECK(*chosen_local_addr == expected);
// Create a peer with a routable IPv4 address (inbound).