@@ -45,6 +45,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
45
45
// if true, allow duplicate input when constructing tx
46
46
const bool duplicate_input = fuzzed_data_provider.ConsumeBool ();
47
47
48
+ CTransactionRef ptx_potential_parent = nullptr ;
49
+
48
50
LIMITED_WHILE (outpoints.size () < 200'000 && fuzzed_data_provider.ConsumeBool (), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
49
51
{
50
52
// construct transaction
@@ -78,16 +80,34 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
78
80
return new_tx;
79
81
}();
80
82
83
+ // Trigger orphanage functions that are called using parents. ptx_potential_parent is a tx we constructed in a
84
+ // previous loop and potentially the parent of this tx.
85
+ if (ptx_potential_parent) {
86
+ // Set up future GetTxToReconsider call.
87
+ orphanage.AddChildrenToWorkSet (*ptx_potential_parent);
88
+
89
+ // Check that all txns returned from GetChildrenFrom* are indeed a direct child of this tx.
90
+ NodeId peer_id = fuzzed_data_provider.ConsumeIntegral <NodeId>();
91
+ for (const auto & child : orphanage.GetChildrenFromSamePeer (ptx_potential_parent, peer_id)) {
92
+ assert (std::any_of (child->vin .cbegin (), child->vin .cend (), [&](const auto & input) {
93
+ return input.prevout .hash == ptx_potential_parent->GetHash ();
94
+ }));
95
+ }
96
+ for (const auto & [child, peer] : orphanage.GetChildrenFromDifferentPeer (ptx_potential_parent, peer_id)) {
97
+ assert (std::any_of (child->vin .cbegin (), child->vin .cend (), [&](const auto & input) {
98
+ return input.prevout .hash == ptx_potential_parent->GetHash ();
99
+ }));
100
+ assert (peer != peer_id);
101
+ }
102
+ }
103
+
81
104
// trigger orphanage functions
82
105
LIMITED_WHILE (fuzzed_data_provider.ConsumeBool (), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
83
106
{
84
107
NodeId peer_id = fuzzed_data_provider.ConsumeIntegral <NodeId>();
85
108
86
109
CallOneOf (
87
110
fuzzed_data_provider,
88
- [&] {
89
- orphanage.AddChildrenToWorkSet (*tx);
90
- },
91
111
[&] {
92
112
{
93
113
CTransactionRef ref = orphanage.GetTxToReconsider (peer_id);
@@ -136,6 +156,12 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
136
156
orphanage.LimitOrphans (limit, limit_orphans_rng);
137
157
Assert (orphanage.Size () <= limit);
138
158
});
159
+
160
+ }
161
+ // Set tx as potential parent to be used for future GetChildren() calls.
162
+ if (!ptx_potential_parent || fuzzed_data_provider.ConsumeBool ()) {
163
+ ptx_potential_parent = tx;
139
164
}
165
+
140
166
}
141
167
}
0 commit comments