Skip to content

Commit

Permalink
improved scaladoc, removing unused new code in SigmaTyper
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Sep 23, 2024
1 parent dfc448f commit 0ee89b1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions core/shared/src/main/scala/sigma/SigmaDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ trait SigmaDslBuilder {
/** Returns a byte-wise XOR of the two collections of bytes. */
def xor(l: Coll[Byte], r: Coll[Byte]): Coll[Byte]

/** Deserializes provided `bytes` into a value of type `T`. **/
def deserializeTo[T](tpe: SType, bytes: Coll[Byte])(implicit cT: RType[T]): T
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HeaderWithoutPow(val version: Byte, // 1 byte
val votes: Array[Byte], //3 bytes
val unparsedBytes: Array[Byte]) {
def toHeader(powSolution: AutolykosSolution, bytes: Array[Byte]): ErgoHeader =
new ErgoHeader(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
ErgoHeader(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
nBits, height, extensionRoot, powSolution, votes, unparsedBytes, bytes)

override def toString: String = {
Expand Down
10 changes: 0 additions & 10 deletions sc/shared/src/main/scala/sigma/compiler/phases/SigmaTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ class SigmaTyper(val builder: SigmaBuilder,
val newObj = assignType(env, obj)
val newArgs = args.map(assignType(env, _))
newObj.tpe match {
case SGlobal =>
SGlobalMethods.method(n) match {
case Some(method) =>
val srcCtx = sel.sourceContext
val genFunTpe = method.stype
val subst = Map(genFunTpe.tpeParams.head.ident -> rangeTpe)
processGlobalMethod(srcCtx, method, newArgs, subst)
case _ =>
error(s"Cannot find Global method: $n", bound.sourceContext)
}
case p: SProduct =>
MethodsContainer.getMethod(p, n) match {
case Some(method: SMethod) =>
Expand Down
20 changes: 20 additions & 0 deletions sc/shared/src/test/scala/sigma/LanguageSpecificationV6.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1561,4 +1561,24 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite =>
)
}

property("Global.deserializeTo - header") {
val headerBytes = "02ac2101807f0000ca01ff0119db227f202201007f62000177a080005d440896d05d3f80dcff7f5e7f59007294c180808d0158d1ff6ba10000f901c7f0ef87dcfff17fffacb6ff7f7f1180d2ff7f1e24ffffe1ff937f807f0797b9ff6ebdae007e5c8c00b8403d3701557181c8df800001b6d5009e2201c6ff807d71808c00019780f087adb3fcdbc0b3441480887f80007f4b01cf7f013ff1ffff564a0000b9a54f00770e807f41ff88c00240000080c0250000000003bedaee069ff4829500b3c07c4d5fe6b3ea3d3bf76c5c28c1d4dcdb1bed0ade0c0000000000003105"
val header1 = new CHeader(ErgoHeader.sigmaSerializer.fromBytes(Base16.decode(headerBytes).get))

def deserializeTo: Feature[Header, Boolean] = {
newFeature(
{ (x: Header) => CSigmaDslBuilder.deserializeTo[Header](SHeader, CSigmaDslBuilder.serialize(x)) == x},
"{ (x: Header) => Global.deserializeTo[Header](serialize(x)) == x }",
sinceVersion = VersionContext.V6SoftForkVersion
)
}

verifyCases(
Seq(
header1 -> new Expected(ExpectedResult(Success(true), None))
),
deserializeTo
)
}

}

0 comments on commit 0ee89b1

Please sign in to comment.