Add test showing that the witness cache isn't being serialised
This commit is contained in:
@@ -43,10 +43,19 @@ public:
|
||||
Hash empty_root(size_t depth) {
|
||||
return empty_roots.at(depth);
|
||||
}
|
||||
template <size_t D, typename H>
|
||||
friend bool operator==(const EmptyMerkleRoots<D, H>& a,
|
||||
const EmptyMerkleRoots<D, H>& b);
|
||||
private:
|
||||
boost::array<Hash, Depth+1> empty_roots;
|
||||
};
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
bool operator==(const EmptyMerkleRoots<Depth, Hash>& a,
|
||||
const EmptyMerkleRoots<Depth, Hash>& b) {
|
||||
return a.empty_roots == b.empty_roots;
|
||||
}
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
class IncrementalWitness;
|
||||
|
||||
@@ -90,6 +99,10 @@ public:
|
||||
return emptyroots.empty_root(Depth);
|
||||
}
|
||||
|
||||
template <size_t D, typename H>
|
||||
friend bool operator==(const IncrementalMerkleTree<D, H>& a,
|
||||
const IncrementalMerkleTree<D, H>& b);
|
||||
|
||||
private:
|
||||
static EmptyMerkleRoots<Depth, Hash> emptyroots;
|
||||
boost::optional<Hash> left;
|
||||
@@ -104,6 +117,15 @@ private:
|
||||
void wfcheck() const;
|
||||
};
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
bool operator==(const IncrementalMerkleTree<Depth, Hash>& a,
|
||||
const IncrementalMerkleTree<Depth, Hash>& b) {
|
||||
return (a.emptyroots == b.emptyroots &&
|
||||
a.left == b.left &&
|
||||
a.right == b.right &&
|
||||
a.parents == b.parents);
|
||||
}
|
||||
|
||||
template <size_t Depth, typename Hash>
|
||||
class IncrementalWitness {
|
||||
friend class IncrementalMerkleTree<Depth, Hash>;
|
||||
@@ -130,6 +152,10 @@ public:
|
||||
cursor_depth = tree.next_depth(filled.size());
|
||||
}
|
||||
|
||||
template <size_t D, typename H>
|
||||
friend bool operator==(const IncrementalWitness<D, H>& a,
|
||||
const IncrementalWitness<D, H>& b);
|
||||
|
||||
private:
|
||||
IncrementalMerkleTree<Depth, Hash> tree;
|
||||
std::vector<Hash> filled;
|
||||
@@ -139,6 +165,15 @@ private:
|
||||
IncrementalWitness(IncrementalMerkleTree<Depth, Hash> tree) : tree(tree) {}
|
||||
};
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
bool operator==(const IncrementalWitness<Depth, Hash>& a,
|
||||
const IncrementalWitness<Depth, Hash>& b) {
|
||||
return (a.tree == b.tree &&
|
||||
a.filled == b.filled &&
|
||||
a.cursor == b.cursor &&
|
||||
a.cursor_depth == b.cursor_depth);
|
||||
}
|
||||
|
||||
class SHA256Compress : public uint256 {
|
||||
public:
|
||||
SHA256Compress() : uint256() {}
|
||||
|
||||
Reference in New Issue
Block a user