Skip to content

Commit e5100da

Browse files
committed
test: Add NODE_BIP444 service flag to peer connection tests
Add NODE_BIP444 flag to GetDesirableServiceFlags assertions in peerman_tests and to service flags in denialofservice_tests and net_tests peer setup. NODE_BIP444 (bit 27) signals BIP444/REDUCED_DATA enforcement and is now included in desirable service flags alongside NODE_NETWORK and NODE_WITNESS for peer connections.
1 parent 66c2363 commit e5100da

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/test/denialofservice_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
6868
connman.Handshake(
6969
/*node=*/dummyNode1,
7070
/*successfully_connected=*/true,
71-
/*remote_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS),
72-
/*local_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS),
71+
/*remote_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444),
72+
/*local_services=*/ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444),
7373
/*version=*/PROTOCOL_VERSION,
7474
/*relay_txs=*/true);
7575

src/test/net_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,15 +835,15 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
835835
/*inbound_onion=*/false,
836836
/*network_key=*/2};
837837

838-
const uint64_t services{NODE_NETWORK | NODE_WITNESS};
838+
const uint64_t services{NODE_NETWORK | NODE_WITNESS | NODE_BIP444};
839839
const int64_t time{0};
840840

841841
// Force ChainstateManager::IsInitialBlockDownload() to return false.
842842
// Otherwise PushAddress() isn't called by PeerManager::ProcessMessage().
843843
auto& chainman = static_cast<TestChainstateManager&>(*m_node.chainman);
844844
chainman.JumpOutOfIbd();
845845

846-
m_node.peerman->InitializeNode(peer, NODE_NETWORK);
846+
m_node.peerman->InitializeNode(peer, ServiceFlags(NODE_NETWORK | NODE_BIP444));
847847

848848
std::atomic<bool> interrupt_dummy{false};
849849
std::chrono::microseconds time_received_dummy{0};

src/test/peerman_tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(connections_desirable_service_flags)
3636

3737
// Check we start connecting to full nodes
3838
ServiceFlags peer_flags{NODE_WITNESS | NODE_NETWORK_LIMITED};
39-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS));
39+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444));
4040

4141
// Make peerman aware of the initial best block and verify we accept limited peers when we start close to the tip time.
4242
auto tip = WITH_LOCK(::cs_main, return m_node.chainman->ActiveChain().Tip());
@@ -45,15 +45,15 @@ BOOST_AUTO_TEST_CASE(connections_desirable_service_flags)
4545
peerman->SetBestBlock(tip_block_height, std::chrono::seconds{tip_block_time});
4646

4747
SetMockTime(tip_block_time + 1); // Set node time to tip time
48-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS));
48+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_BIP444));
4949

5050
// Check we don't disallow limited peers connections when we are behind but still recoverable (below the connection safety window)
5151
SetMockTime(GetTime<std::chrono::seconds>() + std::chrono::seconds{consensus.nPowTargetSpacing * (NODE_NETWORK_LIMITED_ALLOW_CONN_BLOCKS - 1)});
52-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS));
52+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_BIP444));
5353

5454
// Check we disallow limited peers connections when we are further than the limited peers safety window
5555
SetMockTime(GetTime<std::chrono::seconds>() + std::chrono::seconds{consensus.nPowTargetSpacing * 2});
56-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS));
56+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444));
5757

5858
// By now, we tested that the connections desirable services flags change based on the node's time proximity to the tip.
5959
// Now, perform the same tests for when the node receives a block.
@@ -62,15 +62,15 @@ BOOST_AUTO_TEST_CASE(connections_desirable_service_flags)
6262
// First, verify a block in the past doesn't enable limited peers connections
6363
// At this point, our time is (NODE_NETWORK_LIMITED_ALLOW_CONN_BLOCKS + 1) * 10 minutes ahead the tip's time.
6464
mineBlock(m_node, /*block_time=*/std::chrono::seconds{tip_block_time + 1});
65-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS));
65+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444));
6666

6767
// Verify a block close to the tip enables limited peers connections
6868
mineBlock(m_node, /*block_time=*/GetTime<std::chrono::seconds>());
69-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS));
69+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_BIP444));
7070

7171
// Lastly, verify the stale tip checks can disallow limited peers connections after not receiving blocks for a prolonged period.
7272
SetMockTime(GetTime<std::chrono::seconds>() + std::chrono::seconds{consensus.nPowTargetSpacing * NODE_NETWORK_LIMITED_ALLOW_CONN_BLOCKS + 1});
73-
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS));
73+
BOOST_CHECK(peerman->GetDesirableServiceFlags(peer_flags) == ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BIP444));
7474
}
7575

7676
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)