MCPcopy Create free account
hub / github.com/aria2/aria2 / testCreateMessage

Method testCreateMessage

test/BtHandshakeMessageTest.cc:74–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void BtHandshakeMessageTest::testCreateMessage()
75{
76 constexpr unsigned char infoHash[] = {
77 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
78 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
79 constexpr unsigned char peerId[] = {0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
80 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
81 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0};
82
83 auto msg = std::make_shared<BtHandshakeMessage>();
84 msg->setInfoHash(infoHash);
85 msg->setPeerId(peerId);
86
87 unsigned char data[68];
88 createHandshakeMessageData(data);
89 auto rawmsg = msg->createMessage();
90 CPPUNIT_ASSERT_EQUAL((size_t)68, rawmsg.size());
91 CPPUNIT_ASSERT_EQUAL(util::toHex((const unsigned char*)data, 68),
92 util::toHex(rawmsg.data(), 68));
93}
94
95void BtHandshakeMessageTest::testToString()
96{

Callers

nothing calls this directly

Calls 7

toHexFunction · 0.85
setInfoHashMethod · 0.80
dataMethod · 0.80
setPeerIdMethod · 0.45
createMessageMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected