5#include <chainparams.h>
16#include <boost/test/unit_test.hpp>
32 CSeederNodeTest(
const CService &service, std::vector<CAddress> *vAddrIn)
35 void TestProcessMessage(
const std::string &strCommand,
CDataStream &message,
43 void setStartingHeight(
int starting_height) {
44 nStartingHeight = starting_height;
58 testNode = std::make_unique<CSeederNodeTest>(service, &
vAddr);
77 uint64_t addr_to_services = vAddr[0].nServices;
80 std::string user_agent =
"/Bitcoin ABC:0.0.0(seeder)/";
84 << addr_to_services << addr_to << serviceflags << addr_from
107 sendBuffer >> header;
112 sendBuffer >> header;
118 sendBuffer >> locator >> hashStop;
119 std::vector<BlockHash> expectedLocator = {
129 payload << sendAddrs;
139 int recentCheckpointHeight =
143 testNode->setStartingHeight(recentCheckpointHeight + 1);
147 headersMsg << header;
158 std::vector<CAddress> sendAddrs(
ADDR_SOFT_CAP - 1, vAddr[0]);
178 size_t expectedSize = vAddr.size() + 1;
179 for (
size_t i = 1; i < 10; i++) {
180 sendAddrs.resize(i, sendAddrs[0]);
196 maxHeaderMessages << header;
227 int recentCheckpointHeight =
234 testNode->setStartingHeight(recentCheckpointHeight + 1);
238 headersOnCorrectChain << header;
248 int recentCheckpointHeight =
254 testNode->setStartingHeight(recentCheckpointHeight - 1);
258 shortHeaderChain << header;
266 BOOST_CHECK(header.hashPrevBlock != recentCheckpoint);
267 testNode->setStartingHeight(recentCheckpointHeight + 1);
271 headersOnWrongChain << header;
278BOOST_AUTO_TEST_SUITE_END()
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
const CChainParams & Params()
Return the currently selected parameters.
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
static const std::string REGTEST
const CMessageHeader::MessageMagic & NetMagic() const
const CCheckpointData & Checkpoints() const
Double ended buffer combining vector and stream-like interfaces.
bool SetInternal(const std::string &name)
Create an "internal" address that represents a name or FQDN.
PeerMessagingState ProcessMessage(std::string strCommand, CDataStream &recv)
A combination of a network address (CNetAddr) and a (TCP) port.
static node::NodeContext testNode
const char * HEADERS
The headers message sends one or more block headers to a node which previously requested certain head...
const char * GETADDR
The getaddr message requests an addr message from the receiving node, preferably one with lots of IP ...
const char * ADDR
The addr (IP address) message relays connection information for peers on the network.
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
const char * GETHEADERS
The getheaders message requests a headers message that provides block headers starting from a particu...
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
static const unsigned int MAX_HEADERS_RESULTS
Number of headers sent in one getheaders result.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static const uint16_t SERVICE_PORT
static CDataStream CreateAddrMessage(std::vector< CAddress > sendAddrs, uint32_t nVersion=INIT_PROTO_VERSION)
std::ostream & operator<<(std::ostream &os, const PeerMessagingState &state)
BOOST_FIXTURE_TEST_CASE(process_verack_msg, MainNetSeederTestingSetup)
BOOST_AUTO_TEST_CASE(process_version_msg)
static const int SEEDER_INIT_VERSION
ServiceFlags
nServices flags.
static const unsigned int ADDR_SOFT_CAP
static int GetRequireHeight()
constexpr std::underlying_type< E >::type to_integral(E e)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
A BlockHash is a unqiue identifier for a block.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::vector< BlockHash > vHave
MapCheckpoints mapCheckpoints
MainNetSeederTestingSetup()
std::vector< CAddress > vAddr
std::unique_ptr< CSeederNodeTest > testNode
SeederTestingSetup(const std::string chain=CBaseChainParams::REGTEST)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation