88#include " uint256.h"
99#include " arith_uint256.h"
1010#include " version.h"
11+ #include " random.h"
1112
1213#include < vector>
1314
@@ -21,8 +22,8 @@ class CPartialMerkleTreeTester : public CPartialMerkleTree
2122public:
2223 // flip one bit in one of the hashes - this should break the authentication
2324 void Damage () {
24- unsigned int n = rand () % vHash.size ();
25- int bit = rand () % 256 ;
25+ unsigned int n = insecure_rand () % vHash.size ();
26+ int bit = insecure_rand () % 256 ;
2627 *(vHash[n].begin () + (bit>>3 )) ^= 1 <<(bit&7 );
2728 }
2829};
@@ -31,6 +32,7 @@ BOOST_AUTO_TEST_SUITE(pmt_tests)
3132
3233BOOST_AUTO_TEST_CASE(pmt_test1)
3334{
35+ seed_insecure_rand (false );
3436 static const unsigned int nTxCounts[] = {1 , 4 , 7 , 17 , 56 , 100 , 127 , 256 , 312 , 513 , 1000 , 4095 };
3537
3638 for (int n = 0 ; n < 12 ; n++) {
@@ -40,7 +42,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
4042 CBlock block;
4143 for (unsigned int j=0 ; j<nTx; j++) {
4244 CMutableTransaction tx;
43- tx.nLockTime = rand () ; // actual transaction data doesn't matter; just make the nLockTime's unique
45+ tx.nLockTime = j ; // actual transaction data doesn't matter; just make the nLockTime's unique
4446 block.vtx .push_back (CTransaction (tx));
4547 }
4648
@@ -61,7 +63,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
6163 std::vector<bool > vMatch (nTx, false );
6264 std::vector<uint256> vMatchTxid1;
6365 for (unsigned int j=0 ; j<nTx; j++) {
64- bool fInclude = (rand () & ((1 << (att/2 )) - 1 )) == 0 ;
66+ bool fInclude = (insecure_rand () & ((1 << (att/2 )) - 1 )) == 0 ;
6567 vMatch[j] = fInclude ;
6668 if (fInclude )
6769 vMatchTxid1.push_back (vTxid[j]);
0 commit comments