2014-03-18 10:11:00 +01:00
|
|
|
// Copyright (c) 2013 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-03-18 10:11:00 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2013-08-20 13:30:39 +02:00
|
|
|
#include "hash.h"
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
#include "utilstrencodings.h"
|
2015-03-12 09:34:42 +01:00
|
|
|
#include "test/test_bitcoin.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
2013-08-20 13:30:39 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2015-03-12 09:34:42 +01:00
|
|
|
BOOST_FIXTURE_TEST_SUITE(hash_tests, BasicTestingSetup)
|
2013-08-20 13:30:39 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(murmurhash3)
|
|
|
|
{
|
|
|
|
|
|
|
|
#define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), expected)
|
|
|
|
|
|
|
|
// Test MurmurHash3 with various inputs. Of course this is retested in the
|
|
|
|
// bloom filter tests - they would fail if MurmurHash3() had any problems -
|
|
|
|
// but is useful for those trying to implement Bitcoin libraries as a
|
|
|
|
// source of test data for their MurmurHash3() primitive during
|
|
|
|
// development.
|
|
|
|
//
|
|
|
|
// The magic number 0xFBA4C795 comes from CBloomFilter::Hash()
|
|
|
|
|
|
|
|
T(0x00000000, 0x00000000, "");
|
|
|
|
T(0x6a396f08, 0xFBA4C795, "");
|
|
|
|
T(0x81f16f39, 0xffffffff, "");
|
|
|
|
|
|
|
|
T(0x514e28b7, 0x00000000, "00");
|
|
|
|
T(0xea3f0b17, 0xFBA4C795, "00");
|
|
|
|
T(0xfd6cf10d, 0x00000000, "ff");
|
|
|
|
|
|
|
|
T(0x16c6b7ab, 0x00000000, "0011");
|
|
|
|
T(0x8eb51c3d, 0x00000000, "001122");
|
|
|
|
T(0xb4471bf8, 0x00000000, "00112233");
|
|
|
|
T(0xe2301fa8, 0x00000000, "0011223344");
|
|
|
|
T(0xfc2e4a15, 0x00000000, "001122334455");
|
|
|
|
T(0xb074502c, 0x00000000, "00112233445566");
|
|
|
|
T(0x8034d2a0, 0x00000000, "0011223344556677");
|
|
|
|
T(0xb4698def, 0x00000000, "001122334455667788");
|
|
|
|
|
|
|
|
#undef T
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|