2011-09-27 20:16:07 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2011-10-12 01:50:06 +02:00
|
|
|
#include "uint256.h"
|
2012-04-17 20:37:47 +02:00
|
|
|
#include "util.h"
|
2011-09-27 20:16:07 +02:00
|
|
|
|
|
|
|
extern void SHA256Transform(void* pstate, void* pinput, const void* pinit);
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(miner_tests)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(sha256transform_equality)
|
|
|
|
{
|
|
|
|
unsigned int pSHA256InitState[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
|
|
|
|
|
|
|
|
2012-04-17 20:37:47 +02:00
|
|
|
// unsigned char pstate[32];
|
2011-10-05 20:33:49 +02:00
|
|
|
unsigned char pinput[64];
|
2011-09-27 20:16:07 +02:00
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
pinput[i] = i;
|
2011-10-05 20:33:49 +02:00
|
|
|
pinput[i+32] = 0;
|
2011-09-27 20:16:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint256 hash;
|
|
|
|
|
|
|
|
SHA256Transform(&hash, pinput, pSHA256InitState);
|
|
|
|
|
2011-10-05 20:33:49 +02:00
|
|
|
BOOST_TEST_MESSAGE(hash.GetHex());
|
2011-09-27 20:16:07 +02:00
|
|
|
|
|
|
|
uint256 hash_reference("0x2df5e1c65ef9f8cde240d23cae2ec036d31a15ec64bc68f64be242b1da6631f3");
|
|
|
|
|
|
|
|
BOOST_CHECK(hash == hash_reference);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|