17 #include <boost/test/unit_test.hpp>
27 return m_orphans.size();
33 std::map<Txid, OrphanTx>::iterator it;
35 if (it == m_orphans.end())
36 it = m_orphans.begin();
43 std::vector<unsigned char> keydata;
45 key.
Set(keydata.data(), keydata.data() + keydata.size(),
true);
66 for (
int i = 0; i < 50; i++)
70 tx.
vin[0].prevout.n = 0;
81 for (
int i = 0; i < 50; i++)
87 tx.
vin[0].prevout.n = 0;
88 tx.
vin[0].prevout.hash = txPrev->GetHash();
99 for (
int i = 0; i < 10; i++)
108 for (
unsigned int j = 0; j < tx.
vin.size(); j++)
110 tx.
vin[j].prevout.n = j;
111 tx.
vin[j].prevout.hash = txPrev->GetHash();
117 for (
unsigned int j = 1; j < tx.
vin.size(); j++)
118 tx.
vin[j].scriptSig = tx.
vin[0].scriptSig;
124 for (
NodeId i = 0; i < 3; i++)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
An encapsulated private key.
bool IsValid() const
Check whether this private key is valid.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
std::vector< B > randbytes(size_t len)
Generate random bytes.
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddKey(const CKey &key)
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphan...
void LimitOrphans(unsigned int max_orphans, FastRandomContext &rng) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Limit the orphanage to the given maximum.
bool AddTx(const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Add a new orphan transaction.
void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Erase all orphans announced by a peer (eg, after that peer disconnects)
size_t CountOrphans() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
CTransactionRef RandomOrphan() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
static transaction_identifier FromUint256(const uint256 &id)
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK(expr)
static void MakeNewKeyWithFastRandomContext(CKey &key)
BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr CAmount CENT
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType, SignatureData &sig_data)
Produce a satisfying script (scriptSig or witness).
A mutable version of CTransaction.
std::vector< CTxOut > vout
Testing setup that configures a complete environment.
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
static uint256 InsecureRand256()
#define EXCLUSIVE_LOCKS_REQUIRED(...)