aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/txorphan.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2022-10-07 14:25:47 +1000
committerAnthony Towns <aj@erisian.com.au>2022-10-11 23:35:32 +1000
commit733d85f79cde353d8c9b54370f296b1031fa33d9 (patch)
treed82f4afe95a9e61ff84eeac104d118013c44a372 /src/test/fuzz/txorphan.cpp
parenta936f41a5d5f7bb97425f82ec64dfae62e840a56 (diff)
downloadbitcoin-733d85f79cde353d8c9b54370f296b1031fa33d9.tar.xz
Move all g_cs_orphans locking to txorphanage
Diffstat (limited to 'src/test/fuzz/txorphan.cpp')
-rw-r--r--src/test/fuzz/txorphan.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp
index b200f94144..02743051e8 100644
--- a/src/test/fuzz/txorphan.cpp
+++ b/src/test/fuzz/txorphan.cpp
@@ -85,12 +85,10 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
CallOneOf(
fuzzed_data_provider,
[&] {
- LOCK(g_cs_orphans);
orphanage.AddChildrenToWorkSet(*tx, peer_id);
},
[&] {
{
- LOCK(g_cs_orphans);
NodeId originator;
bool more = true;
CTransactionRef ref = orphanage.GetTxToReconsider(peer_id, originator, more);
@@ -107,14 +105,12 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
// AddTx should return false if tx is too big or already have it
// tx weight is unknown, we only check when tx is already in orphanage
{
- LOCK(g_cs_orphans);
bool add_tx = orphanage.AddTx(tx, peer_id);
// have_tx == true -> add_tx == false
Assert(!have_tx || !add_tx);
}
have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
{
- LOCK(g_cs_orphans);
bool add_tx = orphanage.AddTx(tx, peer_id);
// if have_tx is still false, it must be too big
Assert(!have_tx == (GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT));
@@ -125,25 +121,22 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
bool have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
// EraseTx should return 0 if m_orphans doesn't have the tx
{
- LOCK(g_cs_orphans);
Assert(have_tx == orphanage.EraseTx(tx->GetHash()));
}
have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
// have_tx should be false and EraseTx should fail
{
- LOCK(g_cs_orphans);
Assert(!have_tx && !orphanage.EraseTx(tx->GetHash()));
}
},
[&] {
- LOCK(g_cs_orphans);
orphanage.EraseForPeer(peer_id);
},
[&] {
// test mocktime and expiry
SetMockTime(ConsumeTime(fuzzed_data_provider));
auto limit = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
- WITH_LOCK(g_cs_orphans, orphanage.LimitOrphans(limit));
+ orphanage.LimitOrphans(limit);
Assert(orphanage.Size() <= limit);
});
}