mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
scripted-diff: use insecure_rand256/randrange more
-BEGIN VERIFY SCRIPT- sed -i "s/\<GetRandHash(/insecure_rand256(/" src/test/*_tests.cpp sed -i "s/\<GetRand(/insecure_randrange(/" src/test/*_tests.cpp src/test/test_bitcoin.cpp sed -i 's/\<insecure_rand() % \([0-9]\+\)/insecure_randrange(\1)/g' src/test/*_tests.cpp -END VERIFY SCRIPT-
This commit is contained in:
@@ -89,7 +89,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un
|
||||
void static RandomScript(CScript &script) {
|
||||
static const opcodetype oplist[] = {OP_FALSE, OP_1, OP_2, OP_3, OP_CHECKSIG, OP_IF, OP_VERIF, OP_RETURN, OP_CODESEPARATOR};
|
||||
script = CScript();
|
||||
int ops = (insecure_rand() % 10);
|
||||
int ops = (insecure_randrange(10));
|
||||
for (int i=0; i<ops; i++)
|
||||
script << oplist[insecure_rand() % (sizeof(oplist)/sizeof(oplist[0]))];
|
||||
}
|
||||
@@ -98,21 +98,21 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
|
||||
tx.nVersion = insecure_rand();
|
||||
tx.vin.clear();
|
||||
tx.vout.clear();
|
||||
tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0;
|
||||
int ins = (insecure_rand() % 4) + 1;
|
||||
int outs = fSingle ? ins : (insecure_rand() % 4) + 1;
|
||||
tx.nLockTime = (insecure_randrange(2)) ? insecure_rand() : 0;
|
||||
int ins = (insecure_randrange(4)) + 1;
|
||||
int outs = fSingle ? ins : (insecure_randrange(4)) + 1;
|
||||
for (int in = 0; in < ins; in++) {
|
||||
tx.vin.push_back(CTxIn());
|
||||
CTxIn &txin = tx.vin.back();
|
||||
txin.prevout.hash = GetRandHash();
|
||||
txin.prevout.n = insecure_rand() % 4;
|
||||
txin.prevout.hash = insecure_rand256();
|
||||
txin.prevout.n = insecure_randrange(4);
|
||||
RandomScript(txin.scriptSig);
|
||||
txin.nSequence = (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1;
|
||||
txin.nSequence = (insecure_randrange(2)) ? insecure_rand() : (unsigned int)-1;
|
||||
}
|
||||
for (int out = 0; out < outs; out++) {
|
||||
tx.vout.push_back(CTxOut());
|
||||
CTxOut &txout = tx.vout.back();
|
||||
txout.nValue = insecure_rand() % 100000000;
|
||||
txout.nValue = insecure_randrange(100000000);
|
||||
RandomScript(txout.scriptPubKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user