Skip to content

Commit 11a4d3e

Browse files
committed
activationType flag for LSV* tests
1 parent a14a257 commit 11a4d3e

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

sc/shared/src/test/scala/sigma/LanguageSpecificationV5.scala

+11-5
Original file line numberDiff line numberDiff line change
@@ -4876,7 +4876,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
48764876
Vector(),
48774877
Map()
48784878
)
4879-
)),
4879+
), activationType = 0),
48804880
preGeneratedSamples = Some(samples))
48814881

48824882
// test vectors to reproduce v4.x bug (see https://github.com/ScorexFoundation/sigmastate-interpreter/issues/603)
@@ -5136,6 +5136,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
51365136
)
51375137
)
51385138
),
5139+
activationType = 0,
51395140
allowNewToSucceed = true
51405141
),
51415142
preGeneratedSamples = Some(ArraySeq.empty))
@@ -6059,7 +6060,9 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
60596060
(x: Coll[Boolean]) => SigmaDsl.xorOf(x),
60606061
(x: Coll[Boolean]) => SigmaDsl.xorOf(x),
60616062
"{ (x: Coll[Boolean]) => xorOf(x) }",
6062-
FuncValue(Vector((1, SBooleanArray)), XorOf(ValUse(1, SBooleanArray)))))
6063+
FuncValue(Vector((1, SBooleanArray)), XorOf(ValUse(1, SBooleanArray))),
6064+
activationType = 0
6065+
))
60636066
}
60646067

60656068
property("LogicalNot equivalence") {
@@ -6334,7 +6337,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
63346337
(x: (Coll[Byte], Coll[Byte])) => SigmaDsl.xor(x._1, x._2),
63356338
(x: (Coll[Byte], Coll[Byte])) => SigmaDsl.xor(x._1, x._2),
63366339
"{ (x: (Coll[Byte], Coll[Byte])) => xor(x._1, x._2) }",
6337-
if (lowerMethodCallsInTests)
6340+
{if (lowerMethodCallsInTests)
63386341
FuncValue(
63396342
Vector((1, STuple(Vector(SByteArray, SByteArray)))),
63406343
Xor(
@@ -6366,7 +6369,8 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
63666369
),
63676370
Map()
63686371
)
6369-
)
6372+
)},
6373+
activationType = 0
63706374
))
63716375
}
63726376

@@ -8965,6 +8969,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
89658969
LongConstant(5L)
89668970
)
89678971
),
8972+
activationType = 0,
89688973
allowNewToSucceed = true),
89698974
preGeneratedSamples = Some(Nil))
89708975
}
@@ -9538,7 +9543,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
95389543
),
95399544
ConcreteCollection(Array(BoolToSigmaProp(FalseLeaf)), SSigmaProp)
95409545
)
9541-
)))
9546+
), activationType = 0))
95429547
}
95439548

95449549
// Original issue: https://github.com/ScorexFoundation/sigmastate-interpreter/issues/604
@@ -9687,6 +9692,7 @@ class LanguageSpecificationV5 extends LanguageSpecificationBase { suite =>
96879692
)
96889693
)
96899694
),
9695+
activationType = 0,
96909696
allowDifferentErrors = true,
96919697
allowNewToSucceed = true
96929698
),

sc/shared/src/test/scala/sigma/LanguageSpecificationV6.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,8 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite =>
14171417
),
14181418
ConcreteCollection(Array(BoolToSigmaProp(FalseLeaf)), SSigmaProp)
14191419
)
1420-
)
1420+
),
1421+
activationType = 1
14211422
)
14221423
)
14231424

sc/shared/src/test/scala/sigma/SigmaDslTesting.scala

+22-6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ class SigmaDslTesting extends AnyPropSpec
130130
/** Version in which the feature is first implemented of changed. */
131131
def sinceVersion: Byte
132132

133+
/** 0 = script version based activation, 1 = tree version based activation */
134+
def activationType: Byte
135+
133136
/** Script containing this feature. */
134137
def script: String
135138

@@ -407,8 +410,8 @@ class SigmaDslTesting extends AnyPropSpec
407410
}
408411

409412
val (expectedResult, expectedCost) = if (
410-
(activatedVersionInTests < VersionContext.V6SoftForkVersion && activatedVersionInTests < sinceVersion) ||
411-
(activatedVersionInTests < sinceVersion && ergoTreeVersionInTests < sinceVersion)
413+
(activationType == 0 && activatedVersionInTests < sinceVersion) ||
414+
(activationType == 1 && ergoTreeVersionInTests < sinceVersion)
412415
) {
413416
(expected.oldResult, expected.verificationCostOpt)
414417
} else {
@@ -519,6 +522,8 @@ class SigmaDslTesting extends AnyPropSpec
519522

520523
override def sinceVersion: Byte = 0
521524

525+
override val activationType = 0
526+
522527
override def isSupportedIn(vc: VersionContext): Boolean = true
523528

524529
/** in v5.x the old and the new interpreters are the same */
@@ -687,6 +692,7 @@ class SigmaDslTesting extends AnyPropSpec
687692
printExpectedExpr: Boolean = true,
688693
logScript: Boolean = LogScriptDefault,
689694
allowNewToSucceed: Boolean = false,
695+
override val activationType: Byte = 1,
690696
override val allowDifferentErrors: Boolean = false
691697
)(implicit IR: IRContext, override val evalSettings: EvalSettings, val tA: RType[A], val tB: RType[B])
692698
extends Feature[A, B] { feature =>
@@ -777,10 +783,16 @@ class SigmaDslTesting extends AnyPropSpec
777783
override def checkExpected(input: A, expected: Expected[B]): Unit = {
778784
// check the new implementation with Scala semantic function
779785
val newRes = VersionContext.withVersions(activatedVersionInTests, ergoTreeVersionInTests) {
780-
checkEq(scalaFuncNew)(newF)(input)
786+
checkEq(scalaFuncNew)(newF)(input)
787+
}
788+
789+
val checkOld = if(changedInVersion < V6SoftForkVersion) {
790+
VersionContext.current.activatedVersion < changedInVersion
791+
} else {
792+
VersionContext.current.ergoTreeVersion < changedInVersion
781793
}
782794

783-
if (VersionContext.current.activatedVersion < changedInVersion && VersionContext.current.ergoTreeVersion < changedInVersion) {
795+
if (checkOld) {
784796
// check the old implementation with Scala semantic
785797
val expectedOldRes = expected.value
786798

@@ -880,6 +892,7 @@ class SigmaDslTesting extends AnyPropSpec
880892
override val scalaFuncNew: A => B,
881893
expectedExpr: Option[SValue],
882894
printExpectedExpr: Boolean = true,
895+
override val activationType: Byte = 1,
883896
logScript: Boolean = LogScriptDefault
884897
)(implicit IR: IRContext, override val evalSettings: EvalSettings, val tA: RType[A], val tB: RType[B])
885898
extends Feature[A, B] {
@@ -1155,12 +1168,15 @@ class SigmaDslTesting extends AnyPropSpec
11551168
script: String,
11561169
expectedExpr: SValue = null,
11571170
allowNewToSucceed: Boolean = false,
1158-
allowDifferentErrors: Boolean = false
1171+
allowDifferentErrors: Boolean = false,
1172+
activationType: Byte = 1
11591173
)
11601174
(implicit IR: IRContext, evalSettings: EvalSettings): Feature[A, B] = {
11611175
ChangedFeature(changedInVersion, script, scalaFunc, scalaFuncNew, Option(expectedExpr),
11621176
allowNewToSucceed = allowNewToSucceed,
1163-
allowDifferentErrors = allowDifferentErrors)
1177+
allowDifferentErrors = allowDifferentErrors,
1178+
activationType = activationType
1179+
)
11641180
}
11651181

11661182
/** Describes a NEW language feature which must NOT be supported in v4 and

0 commit comments

Comments
 (0)