|
3 | 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
4 | 4 |
|
5 | 5 | #include <consensus/amount.h>
|
6 |
| -#include <net.h> |
| 6 | +#include <consensus/validation.h> |
7 | 7 | #include <net_processing.h>
|
| 8 | +#include <node/eviction.h> |
| 9 | +#include <policy/policy.h> |
8 | 10 | #include <primitives/transaction.h>
|
9 | 11 | #include <script/script.h>
|
10 | 12 | #include <sync.h>
|
@@ -99,16 +101,20 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
|
99 | 101 | [&] {
|
100 | 102 | bool have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
|
101 | 103 | // AddTx should return false if tx is too big or already have it
|
| 104 | + // tx weight is unknown, we only check when tx is already in orphanage |
102 | 105 | {
|
103 | 106 | LOCK(g_cs_orphans);
|
104 |
| - Assert(have_tx != orphanage.AddTx(tx, peer_id)); |
| 107 | + bool add_tx = orphanage.AddTx(tx, peer_id); |
| 108 | + // have_tx == true -> add_tx == false |
| 109 | + Assert(!have_tx || !add_tx); |
105 | 110 | }
|
106 | 111 | have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
|
107 |
| - // tx should already be added since it will not be too big in the test |
108 |
| - // have_tx should be true and AddTx should fail |
109 | 112 | {
|
110 | 113 | LOCK(g_cs_orphans);
|
111 |
| - Assert(have_tx && !orphanage.AddTx(tx, peer_id)); |
| 114 | + bool add_tx = orphanage.AddTx(tx, peer_id); |
| 115 | + // if have_tx is still false, it must be too big |
| 116 | + Assert(!have_tx == GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT); |
| 117 | + Assert(!have_tx || !add_tx); |
112 | 118 | }
|
113 | 119 | },
|
114 | 120 | [&] {
|
|
0 commit comments