Changeset View
Changeset View
Standalone View
Standalone View
src/test/pmt_tests.cpp
// Copyright (c) 2012-2016 The Bitcoin Core developers | // Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "arith_uint256.h" | #include <arith_uint256.h> | ||||
#include "consensus/merkle.h" | #include <consensus/merkle.h> | ||||
#include "merkleblock.h" | #include <merkleblock.h> | ||||
#include "serialize.h" | #include <serialize.h> | ||||
#include "streams.h" | #include <streams.h> | ||||
#include "test/test_bitcoin.h" | #include <uint256.h> | ||||
#include "uint256.h" | #include <version.h> | ||||
#include "version.h" | |||||
#include <vector> | #include <test/test_bitcoin.h> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
#include <vector> | |||||
class CPartialMerkleTreeTester : public CPartialMerkleTree { | class CPartialMerkleTreeTester : public CPartialMerkleTree { | ||||
public: | public: | ||||
// flip one bit in one of the hashes - this should break the authentication | // flip one bit in one of the hashes - this should break the authentication | ||||
void Damage() { | void Damage() { | ||||
unsigned int n = InsecureRandRange(vHash.size()); | unsigned int n = InsecureRandRange(vHash.size()); | ||||
int bit = InsecureRandBits(8); | int bit = InsecureRandBits(8); | ||||
*(vHash[n].begin() + (bit >> 3)) ^= 1 << (bit & 7); | *(vHash[n].begin() + (bit >> 3)) ^= 1 << (bit & 7); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |