mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-19 00:42:58 -05:00
AchievementManager: APPROVED_LIST_HASH quality of life improvements
APPROVED_LIST_HASH is moved to a separate file, making tests compilation faster after changing it. The error message prints the hash in a way that it can be directly copy-pasted (though it still needs clang-format).
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/JsonUtil.h"
|
||||
#include "Core/AchievementManager.h"
|
||||
#include "Core/AchievementApprovedHash.h"
|
||||
#include "Core/ActionReplay.h"
|
||||
#include "Core/GeckoCode.h"
|
||||
#include "Core/GeckoCodeConfig.h"
|
||||
@@ -128,23 +128,24 @@ TEST(PatchAllowlist, VerifyHashes)
|
||||
auto context = Common::SHA1::CreateContext();
|
||||
context->Update(new_allowlist_str);
|
||||
auto digest = context->Finish();
|
||||
if (digest != AchievementManager::APPROVED_LIST_HASH)
|
||||
if (digest != ACHIEVEMENT_APPROVED_LIST_HASH)
|
||||
{
|
||||
ADD_FAILURE() << "Approved list hash does not match the one in AchievementMananger."
|
||||
ADD_FAILURE() << "Approved list hash does not match the one in AchievementApprovedHash.h."
|
||||
<< std::endl
|
||||
<< "Please update APPROVED_LIST_HASH to the following:" << std::endl
|
||||
<< Common::SHA1::DigestToString(digest);
|
||||
<< Common::SHA1::DigestToSource(digest);
|
||||
}
|
||||
// Compare with old allowlist
|
||||
static constexpr std::string_view APPROVED_LIST_FILENAME = "ApprovedInis.json";
|
||||
std::string old_allowlist;
|
||||
std::string error;
|
||||
const auto& list_filepath = fmt::format("{}{}{}", sys_directory, DIR_SEP, APPROVED_LIST_FILENAME);
|
||||
const auto& list_filepath =
|
||||
fmt::format("{}{}{}", sys_directory, DIR_SEP, ACHIEVEMENT_APPROVED_LIST_FILENAME);
|
||||
if (!File::ReadFileToString(list_filepath, old_allowlist) || old_allowlist != new_allowlist_str)
|
||||
{
|
||||
static constexpr std::string_view NEW_APPROVED_LIST_FILENAME = "New-ApprovedInis.json";
|
||||
static constexpr std::string_view NEW_ACHIEVEMENT_APPROVED_LIST_FILENAME =
|
||||
"New-ApprovedInis.json";
|
||||
const auto& new_list_filepath =
|
||||
fmt::format("{}{}{}", sys_directory, DIR_SEP, NEW_APPROVED_LIST_FILENAME);
|
||||
fmt::format("{}{}{}", sys_directory, DIR_SEP, NEW_ACHIEVEMENT_APPROVED_LIST_FILENAME);
|
||||
if (!JsonToFile(new_list_filepath, picojson::value(new_allowlist), false))
|
||||
{
|
||||
ADD_FAILURE() << "Failed to write new approved list to " << list_filepath;
|
||||
|
||||
Reference in New Issue
Block a user