aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver-test/zenserver-test.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2024-12-13 11:59:13 +0100
committerStefan Boberg <[email protected]>2024-12-13 11:59:13 +0100
commit6512c8214676662180a62d89a1aebb7b53df5e9b (patch)
treedd40a36dd89564d7f93df8a50fb880fb4438e559 /src/zenserver-test/zenserver-test.cpp
parentadded xxhash unit tests (which currently fail) (diff)
downloadzen-6512c8214676662180a62d89a1aebb7b53df5e9b.tar.xz
zen-6512c8214676662180a62d89a1aebb7b53df5e9b.zip
added ComputeOpKey so all instances of mapping key -> Oid is in a single place
Diffstat (limited to 'src/zenserver-test/zenserver-test.cpp')
-rw-r--r--src/zenserver-test/zenserver-test.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/zenserver-test/zenserver-test.cpp b/src/zenserver-test/zenserver-test.cpp
index 1eba769d2..33c4f99cf 100644
--- a/src/zenserver-test/zenserver-test.cpp
+++ b/src/zenserver-test/zenserver-test.cpp
@@ -2864,12 +2864,22 @@ TEST_CASE("project.remote")
ZEN_ASSERT(It == AttachmentSizes.end());
}
- auto AddOp = [](const CbObject& Op, std::unordered_map<Oid, uint32_t, Oid::Hasher>& Ops) {
+ // Note: This is a clone of the function in projectstore.cpp
+ auto ComputeOpKey = [](const CbObjectView& Op) -> Oid {
+ using namespace std::literals;
+
XXH3_128Stream KeyHasher;
Op["key"sv].WriteToStream([&](const void* Data, size_t Size) { KeyHasher.Append(Data, Size); });
- XXH3_128 KeyHash = KeyHasher.GetHash();
- Oid Id;
- memcpy(Id.OidBits, &KeyHash, sizeof Id.OidBits);
+ XXH3_128 KeyHash128 = KeyHasher.GetHash();
+
+ Oid KeyHash;
+ memcpy(&KeyHash, KeyHash128.Hash, sizeof KeyHash);
+
+ return KeyHash;
+ };
+
+ auto AddOp = [ComputeOpKey](const CbObject& Op, std::unordered_map<Oid, uint32_t, Oid::Hasher>& Ops) {
+ const Oid Id = ComputeOpKey(Op);
IoBuffer Buffer = Op.GetBuffer().AsIoBuffer();
const uint32_t OpCoreHash = uint32_t(XXH3_64bits(Buffer.GetData(), Buffer.GetSize()) & 0xffffFFFF);
Ops.insert({Id, OpCoreHash});