15 #include <boost/test/unit_test.hpp> 30 CSeederNodeTest(
const CService &service, std::vector<CAddress> *vAddrIn)
33 void TestProcessMessage(
const std::string &strCommand,
CDataStream &message,
52 testNode = std::make_unique<CSeederNodeTest>(service, &vAddr);
63 int32_t start_height, uint32_t nVersion,
65 std::string user_agent =
"/bitcoin-cash-seeder:0.15/") {
69 payload << nVersion << uint64_t(serviceflags) << now << addrTo << addrFrom
70 << nonce << user_agent << start_height;
103 sendBuffer >> header;
104 BOOST_CHECK(header.IsValidWithoutConfig(netMagic));
108 sendBuffer >> header;
109 BOOST_CHECK(header.IsValidWithoutConfig(netMagic));
114 sendBuffer >> locator >> hashStop;
115 std::vector<BlockHash> expectedLocator = {
125 payload << sendAddrs;
131 std::vector<CAddress> sendAddrs(
ADDR_SOFT_CAP - 1, vAddr[0]);
151 size_t expectedSize = vAddr.size() + 1;
152 for (
size_t i = 1; i < 10; i++) {
153 sendAddrs.resize(i, sendAddrs[0]);
ServiceFlags
nServices flags.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
static const std::string REGTEST
const char * GETADDR
The getaddr message requests an addr message from the receiving node, preferably one with lots of IP ...
static CDataStream CreateVersionMessage(int64_t now, CAddress addrTo, CAddress addrFrom, int32_t start_height, uint32_t nVersion, uint64_t nonce=0, std::string user_agent="/bitcoin-cash-seeder:0.15/")
static const int SEEDER_INIT_VERSION
static NodeContext testNode
Double ended buffer combining vector and stream-like interfaces.
const CCheckpointData & Checkpoints() const
std::vector< CAddress > vAddr
std::ostream & operator<<(std::ostream &os, const PeerMessagingState &state)
CSeederNode(const CService &ip, std::vector< CAddress > *vAddrIn)
static const unsigned short SERVICE_PORT
const char * GETHEADERS
The getheaders message requests a headers message that provides block headers starting from a particu...
PeerMessagingState ProcessMessage(std::string strCommand, CDataStream &recv)
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
A combination of a network address (CNetAddr) and a (TCP) port.
A CService with information about it as peer.
static int GetRequireHeight()
const char * ADDR
The addr (IP address) message relays connection information for peers on the network.
static const unsigned int ADDR_SOFT_CAP
std::unique_ptr< CSeederNodeTest > testNode
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
static CDataStream CreateAddrMessage(std::vector< CAddress > sendAddrs, uint32_t nVersion=INIT_PROTO_VERSION)
MapCheckpoints mapCheckpoints
#define BOOST_FIXTURE_TEST_SUITE(a, b)
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
#define BOOST_CHECK_EQUAL(v1, v2)
const CChainParams & Params()
Return the currently selected parameters.
#define BOOST_AUTO_TEST_SUITE_END()
bool SetInternal(const std::string &name)
Try to make this a dummy address that maps the specified name into IPv6 like so: (0xFD + sha256("bitc...
int64_t GetTime()
Return system time (or mocked time, if set)
BOOST_AUTO_TEST_CASE(process_version_msg)
constexpr std::underlying_type< E >::type to_integral(E e)
const CMessageHeader::MessageMagic & NetMagic() const
#define BOOST_CHECK(expr)