Skip to content

Commit

Permalink
Use VersionContext.EvolutionVersion for V3 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SethDusek committed Nov 28, 2023
1 parent 47f2272 commit 2d896c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
21 changes: 11 additions & 10 deletions sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import sigmastate.crypto.ProveDHTuple
import sigmastate.interpreter._
import org.scalactic.source.Position
import sigma.VersionContext
import sigma.VersionContext.EvolutionVersion
import sigmastate.helpers.SigmaPPrint
import sigmastate.exceptions.GraphBuildingException

Expand Down Expand Up @@ -5153,7 +5154,7 @@ class SigmaDslSpecification extends SigmaDslTesting
newVersionedResults = {
val expectedV3Costs = 2000 +: Seq.fill(3)(2002)
// V3 activation will have different costs due to deserialization cost
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
expectedV3Costs
} else {
Seq.fill(4)(1766)
Expand Down Expand Up @@ -5360,7 +5361,7 @@ class SigmaDslSpecification extends SigmaDslTesting
newVersionedResults = {
val expectedV3Costs = 2117 +: Seq.fill(3)(2121)
// V3 activation will have different costs due to deserialization cost
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
expectedV3Costs
} else {
Seq.fill(4)(1793)
Expand Down Expand Up @@ -6319,7 +6320,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1766,
newVersionedResults = {
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
1996 +: Seq.fill(3)(1998)
}
else {
Expand Down Expand Up @@ -6608,7 +6609,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1769,
newVersionedResults = {
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2019 +: Seq.fill(3)(2021)
} else {
Seq.fill(4)(1769)
Expand Down Expand Up @@ -7392,7 +7393,7 @@ class SigmaDslSpecification extends SigmaDslTesting
Seq(
Coll[GroupElement]() -> Expected(Success(Coll[Byte]()), 1773, CostDetails.ZeroCost, 1773,
newVersionedResults = {
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2027 +: Seq.fill(3)(2029)
}
else {
Expand Down Expand Up @@ -7453,7 +7454,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1840,
newVersionedResults = (0 to 3).map({ version =>
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2100 +: Seq.fill(3)(2104)
}
else {
Expand Down Expand Up @@ -9248,7 +9249,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1766,
newVersionedResults = Seq.tabulate(4)({ v =>
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2038 +: Seq.fill(3)(2042)
}
else {
Expand Down Expand Up @@ -9828,7 +9829,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1783,
newVersionedResults = {
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2051 +: Seq.fill(3)(2055)
}
else {
Expand All @@ -9846,7 +9847,7 @@ class SigmaDslSpecification extends SigmaDslTesting
expectedDetails = CostDetails.ZeroCost,
newCost = 1783,
newVersionedResults = {
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2051 +: Seq.fill(3)(2055)
}
else {
Expand Down Expand Up @@ -9920,7 +9921,7 @@ class SigmaDslSpecification extends SigmaDslTesting

if (lowerMethodCallsInTests) {
val error = new RuntimeException("any exception")
val costs = if (activatedVersionInTests >= 3) {
val costs = if (activatedVersionInTests >= EvolutionVersion) {
2140 +: Seq.fill(3)(2144)
}
else {
Expand Down
3 changes: 2 additions & 1 deletion sc/shared/src/test/scala/sigma/SigmaDslTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import scalan.Platform.threadSleepOrNoOp
import sigma.VersionContext.EvolutionVersion
import sigma.data.{CollType, OptionType, PairType, RType}
import sigma.util.BenchmarkUtil
import sigma.util.CollectionUtil._
Expand Down Expand Up @@ -990,7 +991,7 @@ class SigmaDslTesting extends AnyPropSpec
new Expected(ExpectedResult(value, Some(cost))) {
override val newResults = defaultNewResults.zipWithIndex.map {
case ((ExpectedResult(v, _), _), version) => {
var cost = if (activatedVersionInTests >= 3) expectedV3Costs(version) else expectedNewCost
var cost = if (activatedVersionInTests >= EvolutionVersion) expectedV3Costs(version) else expectedNewCost
(ExpectedResult(v, Some(cost)), Some(expectedDetails))
}
}
Expand Down

0 comments on commit 2d896c9

Please sign in to comment.