| 25 | |
| 26 | template<typename SetType> |
| 27 | void TestDepGraphSerialization(const std::vector<std::pair<FeeFrac, SetType>>& cluster, const std::string& hexenc) |
| 28 | { |
| 29 | // Construct DepGraph from cluster argument. |
| 30 | DepGraph<SetType> depgraph; |
| 31 | SetType holes; |
| 32 | for (DepGraphIndex i = 0; i < cluster.size(); ++i) { |
| 33 | depgraph.AddTransaction(cluster[i].first); |
| 34 | if (cluster[i] == HOLE) holes.Set(i); |
| 35 | } |
| 36 | for (DepGraphIndex i = 0; i < cluster.size(); ++i) { |
| 37 | depgraph.AddDependencies(cluster[i].second, i); |
| 38 | } |
| 39 | depgraph.RemoveTransactions(holes); |
| 40 | SanityCheck(depgraph); |
| 41 | |
| 42 | // There may be multiple serializations of the same graph, but DepGraphFormatter's serializer |
| 43 | // only produces one of those. Verify that hexenc matches that canonical serialization. |
| 44 | std::vector<unsigned char> encoding; |
| 45 | VectorWriter writer(encoding, 0); |
| 46 | writer << Using<DepGraphFormatter>(depgraph); |
| 47 | BOOST_CHECK_EQUAL(HexStr(encoding), hexenc); |
| 48 | |
| 49 | // Test that deserializing that encoding yields depgraph. This is effectively already implied |
| 50 | // by the round-trip test above (if depgraph is acyclic), but verify it explicitly again here. |
| 51 | SpanReader reader(encoding); |
| 52 | DepGraph<SetType> depgraph_read; |
| 53 | reader >> Using<DepGraphFormatter>(depgraph_read); |
| 54 | BOOST_CHECK(depgraph == depgraph_read); |
| 55 | } |
| 56 | |
| 57 | void TestOptimalLinearization(std::span<const uint8_t> enc, std::initializer_list<DepGraphIndex> optimal_linearization) |
| 58 | { |
nothing calls this directly
no test coverage detected