From 6ab76fb9ece657c637e7a1a162ce34387bc922c5 Mon Sep 17 00:00:00 2001
From: jbajic <jure.bajic@memgraph.com>
Date: Thu, 19 Jan 2023 17:50:04 +0100
Subject: [PATCH] Assert delta tag

---
 src/storage/v3/transaction.hpp        |  1 -
 tests/unit/storage_v3_shard_split.cpp | 26 +++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/storage/v3/transaction.hpp b/src/storage/v3/transaction.hpp
index 6c396d969..69953be53 100644
--- a/src/storage/v3/transaction.hpp
+++ b/src/storage/v3/transaction.hpp
@@ -65,7 +65,6 @@ struct Transaction {
   ~Transaction() {}
 
   std::list<Delta> CopyDeltas(CommitInfo *commit_info) const {
-    // TODO This does not solve the next and prev deltas that also need to be set
     std::list<Delta> copied_deltas;
     for (const auto &delta : deltas) {
       switch (delta.action) {
diff --git a/tests/unit/storage_v3_shard_split.cpp b/tests/unit/storage_v3_shard_split.cpp
index e6c9b897e..6c98fa924 100644
--- a/tests/unit/storage_v3_shard_split.cpp
+++ b/tests/unit/storage_v3_shard_split.cpp
@@ -72,6 +72,26 @@ void AssertEqVertexContainer(const VertexContainer &expected, const VertexContai
     auto *actual_delta = actual_it->second.delta;
     while (expected_delta != nullptr) {
       EXPECT_EQ(expected_delta->action, actual_delta->action);
+      switch (expected_delta->action) {
+        case Delta::Action::ADD_LABEL:
+        case Delta::Action::REMOVE_LABEL: {
+          EXPECT_EQ(expected_delta->label, actual_delta->label);
+          break;
+        }
+        case Delta::Action::SET_PROPERTY: {
+          EXPECT_EQ(expected_delta->property.key, actual_delta->property.key);
+          EXPECT_EQ(expected_delta->property.value, actual_delta->property.value);
+          break;
+        }
+        case Delta::Action::ADD_IN_EDGE:
+        case Delta::Action::ADD_OUT_EDGE:
+        case Delta::Action::REMOVE_IN_EDGE:
+        case Delta::Action::RECREATE_OBJECT:
+        case Delta::Action::DELETE_OBJECT:
+        case Delta::Action::REMOVE_OUT_EDGE: {
+          break;
+        }
+      }
       expected_delta = expected_delta->next;
       actual_delta = actual_delta->next;
     }
@@ -99,7 +119,9 @@ TEST_F(ShardSplitTest, TestBasicSplitWithVertices) {
   EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(2)}, {}).HasError());
   EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(3)}, {}).HasError());
   EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(4)}, {}).HasError());
-  EXPECT_FALSE(acc.CreateVertexAndValidate({secondary_label}, {PropertyValue(5)}, {}).HasError());
+  EXPECT_FALSE(
+      acc.CreateVertexAndValidate({secondary_label}, {PropertyValue(5)}, {{secondary_property, PropertyValue(121)}})
+          .HasError());
   EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(6)}, {}).HasError());
   auto current_hlc = GetNextHlc();
   acc.Commit(current_hlc);
@@ -116,11 +138,13 @@ TEST_F(ShardSplitTest, TestBasicSplitWithVertices) {
   Delta delta_delete2{Delta::DeleteObjectTag{}, &commit_info, 2};
   Delta delta_delete3{Delta::DeleteObjectTag{}, &commit_info, 3};
   Delta delta_add_label{Delta::RemoveLabelTag{}, secondary_label, &commit_info, 4};
+  Delta delta_add_property{Delta::SetPropertyTag{}, secondary_property, PropertyValue(), &commit_info, 4};
   VertexContainer expected_vertices;
   expected_vertices.emplace(PrimaryKey{PropertyValue{4}}, VertexData(&delta_delete1));
   auto [it, inserted] = expected_vertices.emplace(PrimaryKey{PropertyValue{5}}, VertexData(&delta_delete2));
   expected_vertices.emplace(PrimaryKey{PropertyValue{6}}, VertexData(&delta_delete3));
   it->second.labels.push_back(secondary_label);
+  AddDeltaToDeltaChain(&*it, &delta_add_property);
   AddDeltaToDeltaChain(&*it, &delta_add_label);
 
   AssertEqVertexContainer(expected_vertices, splitted_data.vertices);