1
0
Fork 0
forked from lthn/blockchain

fixed bugs with detach

This commit is contained in:
cryptozoidberg 2020-04-30 23:21:14 +02:00
parent 16de0b986f
commit 3d1a977991
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
2 changed files with 26 additions and 1 deletions

View file

@ -134,7 +134,7 @@ void wallet_chain_shortener::get_short_chain_history(std::list<crypto::hash>& id
uint64_t current_back_offset = ids.size()+1;
//self check
THROW_IF_FALSE_WALLET_INT_ERR_EX(current_back_offset == sz - i + 1, "Inernal error: current_back_offset{" << current_back_offset << "} == sz-i{" << sz << " - " << i << "} is not equal");
THROW_IF_FALSE_WALLET_INT_ERR_EX(current_back_offset == sz - i + 1 || !count, "Inernal error: current_back_offset{" << current_back_offset << "} == sz-i{" << sz << " - " << i << "} is not equal");
uint64_t current_offset_distance = 1;
while (current_back_offset < sz)

View file

@ -25,6 +25,31 @@ TEST(wallet_chain_shortener, wallet_chain_shortener)
{
LOG_PRINT_L0("{" << *((uint64_t*)&id) << "}{" << counter - *((uint64_t*)&id) << "}" << ENDL);
}
ws.detach(counter - 10000);
short_chain.clear();
ws.get_short_chain_history(short_chain);
for (auto& id : short_chain)
{
LOG_PRINT_L0("{" << *((uint64_t*)&id) << "}{" << counter - *((uint64_t*)&id) << "}" << ENDL);
}
for (counter = counter - 10000 + 1; counter != 1000000; counter++)
{
crypto::hash id_ = AUTO_VAL_INIT(id_);
*((uint64_t*)&id_) = counter;
ws.push_new_block_id(id_, counter);
}
short_chain.clear();
ws.get_short_chain_history(short_chain);
for (auto& id : short_chain)
{
LOG_PRINT_L0("{" << *((uint64_t*)&id) << "}{" << counter - *((uint64_t*)&id) << "}" << ENDL);
}
LOG_PRINT_L0("Finished");
}