Optimise serialization of MerklePath, avoiding ambiguity of std::vector<bool>
The serialization enforces a maximum supported Merkle tree depth of 64. Closes #2831.
This commit is contained in:
@@ -26,7 +26,7 @@ void expect_deser_same(const T& expected)
|
||||
CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss2 << object;
|
||||
|
||||
ASSERT_TRUE(serialized_size == ss2.size());
|
||||
ASSERT_EQ(serialized_size, ss2.size());
|
||||
ASSERT_TRUE(memcmp(&*ss1.begin(), &*ss2.begin(), serialized_size) == 0);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void expect_test_vector(T& v, const U& expected)
|
||||
std::string raw = v.get_str();
|
||||
CDataStream ss2(ParseHex(raw), SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
||||
ASSERT_TRUE(ss1.size() == ss2.size());
|
||||
ASSERT_EQ(ss1.size(), ss2.size());
|
||||
ASSERT_TRUE(memcmp(&*ss1.begin(), &*ss2.begin(), ss1.size()) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -40,16 +40,6 @@ void expect_deser_same(const ZCTestingIncrementalWitness& expected)
|
||||
// canonical serialized representation.
|
||||
}
|
||||
|
||||
template<>
|
||||
void expect_deser_same(const libzcash::MerklePath& expected)
|
||||
{
|
||||
// This deserialization check is pointless for MerklePath,
|
||||
// since we only serialize it to check it against test
|
||||
// vectors. See `expect_test_vector` for that. Also,
|
||||
// it doesn't seem that vector<bool> can be properly
|
||||
// deserialized by Bitcoin's serialization code.
|
||||
}
|
||||
|
||||
template<typename A, typename B, typename C>
|
||||
void expect_ser_test_vector(B& b, const C& c, const A& tree) {
|
||||
expect_test_vector<B, C>(b, c);
|
||||
|
||||
Reference in New Issue
Block a user