Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockindex_tests.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(received_time) { | ||||
// Set to UINT32_MAX because that's the maximum value header.nTime can hold | // Set to UINT32_MAX because that's the maximum value header.nTime can hold | ||||
const int64_t expectedBlockTime = std::numeric_limits<uint32_t>::max(); | const int64_t expectedBlockTime = std::numeric_limits<uint32_t>::max(); | ||||
CBlockHeader header; | CBlockHeader header; | ||||
header.nTime = uint32_t(expectedBlockTime); | header.nTime = uint32_t(expectedBlockTime); | ||||
CBlockIndex index = CBlockIndex(header); | CBlockIndex index = CBlockIndex(header); | ||||
// nTimeReceived defaults to block time | // nTimeReceived defaults to 0 | ||||
BOOST_CHECK(index.nTimeReceived == expectedBlockTime); | BOOST_CHECK(index.nTimeReceived == 0); | ||||
// nTimeReceived can be updated to the actual received time, which may | // nTimeReceived can be updated to the actual received time, which may | ||||
// be before or after the miner's time. | // be before or after the miner's time. | ||||
for (int64_t receivedTime = expectedBlockTime - 10; | for (int64_t receivedTime = expectedBlockTime - 10; | ||||
// Make sure that receivedTime is tested beyond 32-bit values. | // Make sure that receivedTime is tested beyond 32-bit values. | ||||
receivedTime <= expectedBlockTime + 10; receivedTime++) { | receivedTime <= expectedBlockTime + 10; receivedTime++) { | ||||
index.nTimeReceived = receivedTime; | index.nTimeReceived = receivedTime; | ||||
BOOST_CHECK(index.GetBlockTime() == expectedBlockTime); | BOOST_CHECK(index.GetBlockTime() == expectedBlockTime); | ||||
▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines |