16 #include <boost/test/unit_test.hpp>
26 return m_orphans.size();
32 std::map<uint256, OrphanTx>::iterator it;
34 if (it == m_orphans.end())
35 it = m_orphans.begin();
42 std::vector<unsigned char> keydata;
44 key.
Set(keydata.data(), keydata.data() + keydata.size(),
true);
65 for (
int i = 0; i < 50; i++)
69 tx.
vin[0].prevout.n = 0;
80 for (
int i = 0; i < 50; i++)
86 tx.
vin[0].prevout.n = 0;
87 tx.
vin[0].prevout.hash = txPrev->GetHash();
98 for (
int i = 0; i < 10; i++)
107 for (
unsigned int j = 0; j < tx.
vin.size(); j++)
109 tx.
vin[j].prevout.n = j;
110 tx.
vin[j].prevout.hash = txPrev->GetHash();
116 for (
unsigned int j = 1; j < tx.
vin.size(); j++)
117 tx.
vin[j].scriptSig = tx.
vin[0].scriptSig;
123 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...
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)
void LimitOrphans(unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Limit the orphanage to the given maximum.
size_t CountOrphans() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
CTransactionRef RandomOrphan() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
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(...)