mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-05 05:14:51 +02:00
txgraph: Add internal sanity check function (tests)
To make testing more powerful, expose a function to perform an internal sanity check on the state of a TxGraph. This is especially important as TxGraphImpl contains many redundantly represented pieces of information: * graph contains clusters, which refer to entries, but the entries refer back * graph maintains pointers to Ref objects, which point back to the graph. This lets us make sure they are always in sync.
This commit is contained in:
@@ -363,6 +363,11 @@ FUZZ_TARGET(txgraph)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After running all modifications, perform an internal sanity check (before invoking
|
||||
// inspectors that may modify the internal state).
|
||||
real->SanityCheck();
|
||||
|
||||
// Compare simple properties of the graph with the simulation.
|
||||
assert(real->GetTransactionCount() == sim.GetTransactionCount());
|
||||
|
||||
@@ -411,6 +416,9 @@ FUZZ_TARGET(txgraph)
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity check again (because invoking inspectors may modify internal unobservable state).
|
||||
real->SanityCheck();
|
||||
|
||||
// Remove all remaining transactions, because Refs cannot be destroyed otherwise (this will be
|
||||
// addressed in a follow-up commit).
|
||||
for (auto i : sim.graph.Positions()) {
|
||||
|
||||
Reference in New Issue
Block a user