MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / RandomTransaction

Function RandomTransaction

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

Source from the content-addressed store, hash-verified

93}
94
95void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
96 tx.nVersion = insecure_rand();
97 tx.vin.clear();
98 tx.vout.clear();
99 tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0;
100 int ins = (insecure_rand() % 4) + 1;
101 int outs = fSingle ? ins : (insecure_rand() % 4) + 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 = GetRandHash();
106 txin.prevout.n = insecure_rand() % 4;
107 RandomScript(txin.scriptSig);
108 txin.nSequence = (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1;
109 }
110 for (int out = 0; out < outs; out++) {
111 tx.vout.push_back(CTxOut());
112 CTxOut &txout = tx.vout.back();
113 txout.nValue = insecure_rand() % 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 7

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

Tested by

no test coverage detected