Refuse chain rollback past a checkpoint (#92)

This commit is contained in:
Lee *!* Clagett
2024-02-19 13:59:07 -05:00
committed by Lee *!* Clagett
parent d2ca5b4180
commit 55f6bbb386
4 changed files with 76 additions and 50 deletions

View File

@@ -28,6 +28,7 @@
#include "chain.test.h"
#include <cstdint>
#include "checkpoints/checkpoints.h" // monero/src
#include "db/storage.test.h"
#include "error.h"
@@ -112,6 +113,23 @@ LWS_CASE("db::storage::sync_chain")
lws_test::test_chain(lest_env, MONERO_UNWRAP(db.start_read()), last_block.id, fchain);
EXPECT(get_account().scan_height == lws::db::block_id(std::uint64_t(last_block.id) + 1));
}
SECTION("Fork past checkpoint")
{
const auto& checkpoints = lws::db::storage::get_checkpoints();
const auto& points = checkpoints.get_points();
EXPECT(!points.empty());
auto point = points.begin();
const crypto::hash fchain[3] = {
point->second,
crypto::rand<crypto::hash>(),
crypto::rand<crypto::hash>()
};
const auto sync_result = db.sync_chain(lws::db::block_id(point->first), fchain);
EXPECT(sync_result == lws::error::bad_blockchain);
}
}
}

View File

@@ -282,8 +282,6 @@ namespace
LWS_CASE("lws::scanner::sync and lws::scanner::run")
{
mlog_set_log_level(4);
cryptonote::account_keys keys{};
crypto::generate_keys(keys.m_account_address.m_spend_public_key, keys.m_spend_secret_key);
crypto::generate_keys(keys.m_account_address.m_view_public_key, keys.m_view_secret_key);