diff --git a/Modules/Example Replication/jvm/src/test/scala/deltaAntiEntropy/tests/ORMapTest.scala b/Modules/Example Replication/jvm/src/test/scala/deltaAntiEntropy/tests/ORMapTest.scala index 47f375c75..5dabe4f6f 100644 --- a/Modules/Example Replication/jvm/src/test/scala/deltaAntiEntropy/tests/ORMapTest.scala +++ b/Modules/Example Replication/jvm/src/test/scala/deltaAntiEntropy/tests/ORMapTest.scala @@ -3,7 +3,9 @@ package deltaAntiEntropy.tests import com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker import deltaAntiEntropy.tools.{AntiEntropy, AntiEntropyContainer, Network} +import kofre.base.Bottom import kofre.datatypes.contextual.{AddWinsSet, ObserveRemoveMap} +import kofre.dotted.Dotted import replication.JsoniterCodecs.* import org.scalacheck.Prop.* @@ -12,6 +14,18 @@ import scala.collection.mutable class ORMapTest extends munit.ScalaCheckSuite { implicit val intCodec: JsonValueCodec[Int] = JsonCodecMaker.make + property("contains") { + given kofre.syntax.ReplicaId = kofre.syntax.ReplicaId.predefined("test") + given Bottom[Int] with + def empty = Int.MinValue + forAll{ (entries: List[Int]) => + val orMap = entries.foldLeft(Dotted(ObserveRemoveMap.empty[Int, Int])) {(curr, elem) => curr.update(elem, elem)} + orMap.entries.foreach{(k, v) => + assert(orMap.contains(k)) + } + } + } + property("mutateKey/queryKey") { forAll { (add: List[Int], remove: List[Int], k: Int) => diff --git a/Modules/RDTs/src/main/scala/kofre/datatypes/contextual/ObserveRemoveMap.scala b/Modules/RDTs/src/main/scala/kofre/datatypes/contextual/ObserveRemoveMap.scala index 21fec707d..f6553e8be 100644 --- a/Modules/RDTs/src/main/scala/kofre/datatypes/contextual/ObserveRemoveMap.scala +++ b/Modules/RDTs/src/main/scala/kofre/datatypes/contextual/ObserveRemoveMap.scala @@ -36,7 +36,7 @@ object ObserveRemoveMap { implicit class syntax[C, K, V](container: C) extends OpsSyntaxHelper[C, ObserveRemoveMap[K, V]](container) { - def contains(using PermQuery)(k: K): Boolean = current.contains(k) + def contains(using PermQuery)(k: K): Boolean = current.inner.repr.contains(k) def queryKey[A](using PermQuery, Bottom[V])(k: K): V = { current.inner.repr.getOrElse(k, Bottom[V].empty)