MCPcopy Create free account
hub / github.com/LUX-Core/lux / RandomTransaction

Function RandomTransaction

src/test/sighash_tests.cpp:96–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
97 tx.nVersion = insecure_rand();
98 tx.vin.clear();
99 tx.vout.clear();
100 tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0;
101 int ins = (insecure_rand() % 4) + 1;
102 int outs = fSingle ? ins : (insecure_rand() % 4) + 1;
103 for (int in = 0; in < ins; in++) {
104 tx.vin.push_back(CTxIn());
105 CTxIn &txin = tx.vin.back();
106 txin.prevout.hash = GetRandHash();
107 txin.prevout.n = insecure_rand() % 4;
108 RandomScript(txin.scriptSig);
109 txin.nSequence = (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1;
110 }
111 for (int out = 0; out < outs; out++) {
112 tx.vout.push_back(CTxOut());
113 CTxOut &txout = tx.vout.back();
114 txout.nValue = insecure_rand() % 100000000;
115 RandomScript(txout.scriptPubKey);
116 }
117}
118
119BOOST_AUTO_TEST_SUITE(sighash_tests)
120

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

insecure_randFunction · 0.85
GetRandHashFunction · 0.85
RandomScriptFunction · 0.85
backMethod · 0.80
CTxInClass · 0.50
CTxOutClass · 0.50
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected