Skip to content

Commit 7a66924

Browse files
committed
fixing Upcast issues in SubstConstantsSerializerSpecification for v3 trees
1 parent 9801daa commit 7a66924

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

interpreter/shared/src/test/scala/sigma/serialization/SubstConstantsSerializerSpecification.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sigma.serialization
22

33
import sigma.VersionContext
4-
import sigma.ast.{ConcreteCollection, EQ, IntArrayConstant, IntConstant, SInt, SubstConstants, Upcast}
4+
import sigma.ast.{ConcreteCollection, EQ, IntArrayConstant, IntConstant, SInt, SNumericType, SubstConstants, Upcast, Value}
55
import sigma.ast.syntax.IntValue
66
import sigma.serialization.ErgoTreeSerializer.DefaultSerializer
77
import sigmastate.CrossVersionProps
@@ -11,8 +11,12 @@ class SubstConstantsSerializerSpecification extends SerializationSpecification
1111

1212
property("SubstConstant deserialization round trip") {
1313
forAll(numExprTreeNodeGen) { propRaw =>
14-
val prop = if(VersionContext.current.isV3OrLaterErgoTreeVersion && propRaw.tpe.isInstanceOf[SInt.type]) {
15-
Upcast(propRaw, SInt)
14+
val prop = if(VersionContext.current.isV3OrLaterErgoTreeVersion) {
15+
val p = VersionContext.withVersions(2, 2) {
16+
// roundtrip to add Upcast nodes needed for v3 trees
17+
ValueSerializer.deserialize(ValueSerializer.serialize(propRaw))
18+
}
19+
Upcast(p.asInstanceOf[Value[SNumericType]], SInt)
1620
} else {
1721
propRaw
1822
}

0 commit comments

Comments
 (0)