Skip to content

Commit

Permalink
version test for nbits
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Apr 11, 2024
1 parent 815b224 commit 4fc62c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/shared/src/main/scala/sigma/ast/methods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sealed trait MethodsContainer {
}
ms
}
private lazy val _methodsMap: Map[Byte, Map[Byte, SMethod]] = methods
private def _methodsMap: Map[Byte, Map[Byte, SMethod]] = methods //todo: consider versioned caching
.groupBy(_.objType.typeId)
.map { case (typeId, ms) => (typeId -> ms.map(m => m.methodId -> m).toMap) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package sigma.serialization

import sigma.VersionContext
import sigma.ast._
import sigma.validation.ValidationException

class MethodCallSerializerSpecification extends SerializationSpecification {

Expand All @@ -23,12 +25,24 @@ class MethodCallSerializerSpecification extends SerializationSpecification {
}

property("MethodCall deserialization round trip for BigInt.nbits") {
val bi = BigIntConstant(5)
val expr = MethodCall(bi,
SBigIntMethods.ToNBits,
Vector(),
Map()
)
roundTripTest(expr)
def code = {
val bi = BigIntConstant(5)
val expr = MethodCall(bi,
SBigIntMethods.ToNBits,
Vector(),
Map()
)
roundTripTest(expr)
}

VersionContext.withVersions(VersionContext.V6SoftForkVersion, 1) {
code
}

an[ValidationException] should be thrownBy (
VersionContext.withVersions((VersionContext.V6SoftForkVersion - 1).toByte, 1) {
code
}
)
}
}

0 comments on commit 4fc62c6

Please sign in to comment.