diff --git a/src/blockfilter.h b/src/blockfilter.h --- a/src/blockfilter.h +++ b/src/blockfilter.h @@ -81,8 +81,9 @@ constexpr uint8_t BASIC_FILTER_P = 19; constexpr uint32_t BASIC_FILTER_M = 784931; -enum BlockFilterType : uint8_t { +enum class BlockFilterType : uint8_t { BASIC = 0, + INVALID = 255, }; /** @@ -91,7 +92,7 @@ */ class BlockFilter { private: - BlockFilterType m_filter_type; + BlockFilterType m_filter_type = BlockFilterType::INVALID; uint256 m_block_hash; GCSFilter m_filter; diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -249,6 +249,8 @@ params.m_P = BASIC_FILTER_P; params.m_M = BASIC_FILTER_M; return true; + case BlockFilterType::INVALID: + return false; } return false; diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -116,11 +116,19 @@ stream << block_filter; stream >> block_filter2; - BOOST_CHECK_EQUAL(block_filter.GetFilterType(), - block_filter2.GetFilterType()); + BOOST_CHECK(block_filter.GetFilterType() == block_filter2.GetFilterType()); BOOST_CHECK(block_filter.GetBlockHash() == block_filter2.GetBlockHash()); BOOST_CHECK(block_filter.GetEncodedFilter() == block_filter2.GetEncodedFilter()); + + BlockFilter default_ctor_block_filter_1; + BlockFilter default_ctor_block_filter_2; + BOOST_CHECK(default_ctor_block_filter_1.GetFilterType() == + default_ctor_block_filter_2.GetFilterType()); + BOOST_CHECK(default_ctor_block_filter_1.GetBlockHash() == + default_ctor_block_filter_2.GetBlockHash()); + BOOST_CHECK(default_ctor_block_filter_1.GetEncodedFilter() == + default_ctor_block_filter_2.GetEncodedFilter()); } BOOST_AUTO_TEST_CASE(blockfilters_json_test) {