diff options
Diffstat (limited to 'src/test/pmt_tests.cpp')
-rw-r--r-- | src/test/pmt_tests.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index a1cb32019a..c1d216d094 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -10,11 +10,9 @@ #include "arith_uint256.h" #include "version.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <vector> -#include <boost/assign/list_of.hpp> #include <boost/test/unit_test.hpp> class CPartialMerkleTreeTester : public CPartialMerkleTree @@ -22,8 +20,8 @@ class CPartialMerkleTreeTester : public CPartialMerkleTree public: // flip one bit in one of the hashes - this should break the authentication void Damage() { - unsigned int n = insecure_rand() % vHash.size(); - int bit = insecure_rand() % 256; + unsigned int n = InsecureRandRange(vHash.size()); + int bit = InsecureRandBits(8); *(vHash[n].begin() + (bit>>3)) ^= 1<<(bit&7); } }; @@ -32,7 +30,7 @@ BOOST_FIXTURE_TEST_SUITE(pmt_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(pmt_test1) { - seed_insecure_rand(false); + SeedInsecureRand(false); static const unsigned int nTxCounts[] = {1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1000, 4095}; for (int i = 0; i < 12; i++) { @@ -63,7 +61,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1) std::vector<bool> vMatch(nTx, false); std::vector<uint256> vMatchTxid1; for (unsigned int j=0; j<nTx; j++) { - bool fInclude = (insecure_rand() & ((1 << (att/2)) - 1)) == 0; + bool fInclude = InsecureRandBits(att / 2) == 0; vMatch[j] = fInclude; if (fInclude) vMatchTxid1.push_back(vTxid[j]); @@ -110,14 +108,15 @@ BOOST_AUTO_TEST_CASE(pmt_test1) BOOST_AUTO_TEST_CASE(pmt_malleability) { - std::vector<uint256> vTxid = boost::assign::list_of - (ArithToUint256(1))(ArithToUint256(2)) - (ArithToUint256(3))(ArithToUint256(4)) - (ArithToUint256(5))(ArithToUint256(6)) - (ArithToUint256(7))(ArithToUint256(8)) - (ArithToUint256(9))(ArithToUint256(10)) - (ArithToUint256(9))(ArithToUint256(10)); - std::vector<bool> vMatch = boost::assign::list_of(false)(false)(false)(false)(false)(false)(false)(false)(false)(true)(true)(false); + std::vector<uint256> vTxid = { + ArithToUint256(1), ArithToUint256(2), + ArithToUint256(3), ArithToUint256(4), + ArithToUint256(5), ArithToUint256(6), + ArithToUint256(7), ArithToUint256(8), + ArithToUint256(9), ArithToUint256(10), + ArithToUint256(9), ArithToUint256(10), + }; + std::vector<bool> vMatch = {false, false, false, false, false, false, false, false, false, true, true, false}; CPartialMerkleTree tree(vTxid, vMatch); std::vector<unsigned int> vIndex; |