Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changedFeature not working with 6.0 changes #1024

Closed
kushti opened this issue Aug 1, 2024 · 1 comment
Closed

changedFeature not working with 6.0 changes #1024

kushti opened this issue Aug 1, 2024 · 1 comment
Assignees

Comments

@kushti
Copy link
Member

kushti commented Aug 1, 2024

Surprisingly, the following test is passing in LanguageSpecificationV6 , while it shouldn't .

  property("Option.getOrElse with lazy default") {
    verifyCases(
      Seq(
        Some(0L) -> Expected(Failure(new java.lang.ArithmeticException("/ by zero")), 6, CostDetails.ZeroCost, 1793,
          newVersionedResults = {
            Seq(0 -> (ExpectedResult(Success(6L), Some(1793)) -> None))
          } ),
        None -> Expected(Failure(new java.lang.ArithmeticException("/ by zero")), 6)
      ),
      changedFeature(
        { (x: Option[Long]) => val default = 1 / 0L; x.getOrElse(default) },
        { (x: Option[Long]) => if (VersionContext.current.isV6SoftForkActivated) {x.getOrElse(1 / 0L)} else {val default = 1 / 0L; x.getOrElse(default)} },
        "{ (x: Option[Long]) => x.getOrElse(1 / 0L) }",
        FuncValue(
          Array((1, SOption(SLong))),
          OptionGetOrElse(
            ValUse(1, SOption(SLong)),
            ArithOp(LongConstant(1L), LongConstant(0L), OpCode @@ (-99.toByte))
          )
        ),
        allowNewToSucceed = true,
        changedIn = VersionContext.V6SoftForkVersion
      )
    )
  }

And it seems interpreter 6.0 is not called inside ChangedFeature functions despite following settings in VersionTesting:

  /** Tests run for both version 2 & version 3 */
  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
@kushti
Copy link
Member Author

kushti commented Aug 2, 2024

can be found in 26809c9

@kushti kushti closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants