Repository navigation
Expand file tree
/
Copy pathinv_tests.cpp
More file actions
42 lines (34 loc) · 1.46 KB
/
Copy pathinv_tests.cpp
File metadata and controls
42 lines (34 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2017 Amaury SÉCHET
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <protocol.h>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(inv_tests)
static void CheckType(int type, int expected, bool IsTx, bool IsBlock) {
CInv inv(type, uint256());
BOOST_CHECK_EQUAL(inv.GetKind(), expected);
BOOST_CHECK_EQUAL(inv.IsTx(), IsTx);
BOOST_CHECK_EQUAL(inv.IsSomeBlock(), IsBlock);
}
/* Validate various inv facilities. */
BOOST_AUTO_TEST_CASE(validate_kind) {
CheckType(GetDataMsg::UNDEFINED, GetDataMsg::UNDEFINED, false, false);
CheckType(GetDataMsg::MSG_TX, GetDataMsg::MSG_TX, true, false);
CheckType(GetDataMsg::MSG_BLOCK, GetDataMsg::MSG_BLOCK, false, true);
CheckType(GetDataMsg::MSG_FILTERED_BLOCK, GetDataMsg::MSG_FILTERED_BLOCK,
false, true);
CheckType(GetDataMsg::MSG_CMPCT_BLOCK, GetDataMsg::MSG_CMPCT_BLOCK, false,
true);
}
static void CheckCommand(int type, const std::string &expected) {
CInv inv(type, uint256());
BOOST_CHECK_EQUAL(inv.GetCommand(), expected);
}
/* Validate various inv facilities. */
BOOST_AUTO_TEST_CASE(validate_cmd) {
CheckCommand(GetDataMsg::MSG_TX, "tx");
CheckCommand(GetDataMsg::MSG_BLOCK, "block");
CheckCommand(GetDataMsg::MSG_FILTERED_BLOCK, "merkleblock");
CheckCommand(GetDataMsg::MSG_CMPCT_BLOCK, "cmpctblock");
}
BOOST_AUTO_TEST_SUITE_END()