Changeset View
Changeset View
Standalone View
Standalone View
src/test/coins_tests.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | |||||
// This test is similar to the previous test except the emphasis is on testing | // This test is similar to the previous test except the emphasis is on testing | ||||
// the functionality of UpdateCoins random txs are created and UpdateCoins is | // the functionality of UpdateCoins random txs are created and UpdateCoins is | ||||
// used to update the cache stack. In particular it is tested that spending a | // used to update the cache stack. In particular it is tested that spending a | ||||
// duplicate coinbase tx has the expected effect (the other duplicate is | // duplicate coinbase tx has the expected effect (the other duplicate is | ||||
// overwritten at all cache levels) | // overwritten at all cache levels) | ||||
BOOST_AUTO_TEST_CASE(updatecoins_simulation_test) { | BOOST_AUTO_TEST_CASE(updatecoins_simulation_test) { | ||||
SeedInsecureRand(/* deterministic */ true); | SeedInsecureRand(/* deterministic */ true); | ||||
g_mock_deterministic_tests = true; | |||||
bool spent_a_duplicate_coinbase = false; | bool spent_a_duplicate_coinbase = false; | ||||
// A simple map to track what we expect the cache stack to represent. | // A simple map to track what we expect the cache stack to represent. | ||||
std::map<COutPoint, Coin> result; | std::map<COutPoint, Coin> result; | ||||
// The cache stack. | // The cache stack. | ||||
// A CCoinsViewTest at the bottom. | // A CCoinsViewTest at the bottom. | ||||
CCoinsViewTest base; | CCoinsViewTest base; | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(updatecoins_simulation_test) { | ||||
// Clean up the stack. | // Clean up the stack. | ||||
while (stack.size() > 0) { | while (stack.size() > 0) { | ||||
delete stack.back(); | delete stack.back(); | ||||
stack.pop_back(); | stack.pop_back(); | ||||
} | } | ||||
// Verify coverage. | // Verify coverage. | ||||
BOOST_CHECK(spent_a_duplicate_coinbase); | BOOST_CHECK(spent_a_duplicate_coinbase); | ||||
g_mock_deterministic_tests = false; | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(coin_serialization) { | BOOST_AUTO_TEST_CASE(coin_serialization) { | ||||
// Good example | // Good example | ||||
CDataStream ss1( | CDataStream ss1( | ||||
ParseHex("97f23c835800816115944e077fe7c803cfa57f29b36bf87c1d35"), | ParseHex("97f23c835800816115944e077fe7c803cfa57f29b36bf87c1d35"), | ||||
SER_DISK, CLIENT_VERSION); | SER_DISK, CLIENT_VERSION); | ||||
Coin c1; | Coin c1; | ||||
▲ Show 20 Lines • Show All 400 Lines • Show Last 20 Lines |