MCPcopy Create free account
hub / github.com/ElementsProject/elements / RandomTransaction

Function RandomTransaction

src/test/sighash_tests.cpp:94–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void static RandomTransaction(CMutableTransaction& tx, bool fSingle)
95{
96 tx.nVersion = int(InsecureRand32());
97 tx.vin.clear();
98 tx.vout.clear();
99 tx.nLockTime = (InsecureRandBool()) ? InsecureRand32() : 0;
100 int ins = (InsecureRandBits(2)) + 1;
101 int outs = fSingle ? ins : (InsecureRandBits(2)) + 1;
102 for (int in = 0; in < ins; in++) {
103 tx.vin.push_back(CTxIn());
104 CTxIn &txin = tx.vin.back();
105 txin.prevout.hash = InsecureRand256();
106 txin.prevout.n = InsecureRandBits(2);
107 RandomScript(txin.scriptSig);
108 txin.nSequence = (InsecureRandBool()) ? InsecureRand32() : std::numeric_limits<uint32_t>::max();
109 }
110 for (int out = 0; out < outs; out++) {
111 tx.vout.push_back(CTxOut());
112 CTxOut &txout = tx.vout.back();
113 txout.nValue = InsecureRandRange(100000000);
114 RandomScript(txout.scriptPubKey);
115 }
116}
117
118BOOST_FIXTURE_TEST_SUITE(sighash_tests, BasicTestingSetup)
119

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 10

InsecureRand32Function · 0.85
InsecureRandBoolFunction · 0.85
InsecureRandBitsFunction · 0.85
InsecureRand256Function · 0.85
RandomScriptFunction · 0.85
InsecureRandRangeFunction · 0.85
CTxInClass · 0.50
CTxOutClass · 0.50
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected