diff --git a/core/shared/src/main/scala/sigma/VersionContext.scala b/core/shared/src/main/scala/sigma/VersionContext.scala index 05dd39eb5a..14ed6e36b0 100644 --- a/core/shared/src/main/scala/sigma/VersionContext.scala +++ b/core/shared/src/main/scala/sigma/VersionContext.scala @@ -1,6 +1,6 @@ package sigma -import VersionContext.{EvolutionVersion, JitActivationVersion} +import VersionContext.{V6SoftForkVersion, JitActivationVersion} import scala.util.DynamicVariable @@ -24,7 +24,7 @@ case class VersionContext(activatedVersion: Byte, ergoTreeVersion: Byte) { /** @return true, if the activated script version of Ergo protocol on the network is * including Evolution update. */ - def isEvolutionActivated: Boolean = activatedVersion >= EvolutionVersion + def isV6SoftForkActivated: Boolean = activatedVersion >= V6SoftForkVersion } object VersionContext { @@ -46,7 +46,7 @@ object VersionContext { /** * The version of ErgoTree corresponding to "evolution" (6.0) soft-fork */ - val EvolutionVersion: Byte = 3 + val V6SoftForkVersion: Byte = 3 private val _defaultContext = VersionContext( activatedVersion = 1/* v4.x */, diff --git a/core/shared/src/test/scala/sigma/VersionTesting.scala b/core/shared/src/test/scala/sigma/VersionTesting.scala index 69e15ff491..bd3e3b8872 100644 --- a/core/shared/src/test/scala/sigma/VersionTesting.scala +++ b/core/shared/src/test/scala/sigma/VersionTesting.scala @@ -6,11 +6,11 @@ import scala.util.DynamicVariable trait VersionTesting { - /** Tests run for both version 2 & version 3 */ + /** Tests run for all supported versions starting from 0. */ protected val activatedVersions: Seq[Byte] = (0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray[Byte] - private[sigma] val _currActivatedVersion = new DynamicVariable[Byte](3) // v6.x by default + private[sigma] val _currActivatedVersion = new DynamicVariable[Byte](2) // v5.x by default /** Current activated version used in tests. */ def activatedVersionInTests: Byte = _currActivatedVersion.value diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index db8b1faf7f..34408d2bf0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -914,7 +914,7 @@ case object SBoolean extends SPrimType with SEmbeddable with SLogical with SProd .withInfo(PropertyCall, "Convert true to 1 and false to 0") protected override def getMethods(): Seq[SMethod] = { - if (VersionContext.current.isEvolutionActivated) { + if (VersionContext.current.isV6SoftForkActivated) { super.getMethods() ++ Seq(ToByteMethod) } else { super.getMethods() diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index 001c1c43d6..770a07e0dc 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -510,7 +510,7 @@ trait GraphBuilding extends SigmaLibrary { IR: IRContext => else error(s"The type of $obj is expected to be Collection to select 'size' property", obj.sourceContext.toOption) - case Select(obj, SBoolean.ToByte, _) if obj.tpe.isBoolean && VersionContext.current.isEvolutionActivated => + case Select(obj, SBoolean.ToByte, _) if obj.tpe.isBoolean && VersionContext.current.isV6SoftForkActivated => val bool = eval(obj.asBoolValue) bool.toByte diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index 559cb934fd..556f2bddd8 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -234,7 +234,7 @@ class ErgoTreeSpecification extends SigmaDslTesting with ContractsTestkit { { import SBoolean._ - if (VersionContext.current.isEvolutionActivated) { + if (VersionContext.current.isV6SoftForkActivated) { (SBoolean.typeId, Seq(MInfo(1, ToByteMethod)), true) } else { (SBoolean.typeId, Seq.empty[MInfo], true) diff --git a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala index 4d2266b805..65c8b2fa4a 100644 --- a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala @@ -9,7 +9,7 @@ import sigmastate.lang.Terms._ import org.ergoplatform._ import org.scalatest.BeforeAndAfterAll import scorex.util.encode.Base58 -import sigma.VersionContext.EvolutionVersion +import sigma.VersionContext.V6SoftForkVersion import sigma.util.Extensions.IntOps import sigmastate.crypto.CryptoConstants import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter} @@ -211,8 +211,8 @@ class TestingInterpreterSpecification extends CompilerTestingCommons | bool.toByte == 1.toByte && false.toByte == 0.toByte |} |""".stripMargin - if (activatedVersionInTests < EvolutionVersion) { - an [sigmastate.exceptions.MethodNotFound] should be thrownBy testEval(source) + if (activatedVersionInTests < V6SoftForkVersion) { + assertExceptionThrown(testEval(source), rootCauseLike[sigmastate.exceptions.MethodNotFound]("Cannot find method 'toByte'")) } else { testEval(source) }