aboutsummaryrefslogtreecommitdiff
path: root/src/test/sighash_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-05-23 15:28:45 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-06-05 12:45:44 -0700
commitefee1db21a652019e0ab18fffc233d91bb7f1816 (patch)
tree32b2fc3ecb73daa71075df246975fb5e2dae7590 /src/test/sighash_tests.cpp
parent1119927df03c94f9306e4d92f55d147b900522fb (diff)
downloadbitcoin-efee1db21a652019e0ab18fffc233d91bb7f1816.tar.xz
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-
Diffstat (limited to 'src/test/sighash_tests.cpp')
-rw-r--r--src/test/sighash_tests.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
index f796216e5f..564fc6b944 100644
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -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);
}
}