Skip to content

Commit

Permalink
Decompiler tests for calculateDelay() and replaceByIndex() (#3891)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 authored Oct 13, 2023
1 parent dbd8b10 commit d711d9a
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import com.wavesplatform.common.utils.{Base58, EitherExt2}
import com.wavesplatform.lang.Global
import com.wavesplatform.lang.contract.DApp
import com.wavesplatform.lang.contract.DApp.*
import com.wavesplatform.lang.directives.{DirectiveDictionary, DirectiveSet}
import com.wavesplatform.lang.directives.values.{DApp as DAppType, *}
import com.wavesplatform.lang.directives.{DirectiveDictionary, DirectiveSet}
import com.wavesplatform.lang.utils.getDecompilerContext
import com.wavesplatform.lang.v1.FunctionHeader.{Native, User}
import com.wavesplatform.lang.v1.compiler.*
import com.wavesplatform.lang.v1.compiler.Terms.*
import com.wavesplatform.lang.v1.compiler.Types.*
import com.wavesplatform.lang.v1.compiler.*
import com.wavesplatform.lang.v1.evaluator.ctx.impl.*
import com.wavesplatform.lang.v1.evaluator.ctx.impl.waves.WavesContext
import com.wavesplatform.lang.v1.parser.BinaryOperation.NE_OP
import com.wavesplatform.lang.v1.parser.Parser
import com.wavesplatform.lang.v1.traits.Environment
import com.wavesplatform.lang.v1.{FunctionHeader, compiler}
import com.wavesplatform.lang.utils.getDecompilerContext
import com.wavesplatform.protobuf.dapp.DAppMeta
import com.wavesplatform.test.PropSpec
import org.scalatest.Assertion
Expand Down Expand Up @@ -1032,14 +1032,14 @@ class DecompilerTest extends PropSpec {

property("BigInt unary minus") {
assertDecompile(
s"""
|let a = -toBigInt(1)
|true
""",
s"""
|let a = -(toBigInt(1))
|true
""",
"""
|let a = -toBigInt(1)
|true
""",
"""
|let a = -(toBigInt(1))
|true
""",
V5
)
}
Expand Down Expand Up @@ -1116,4 +1116,14 @@ class DecompilerTest extends PropSpec {
.filter(_ >= V6)
.foreach(assertDecompile(script, decompiledV6, _))
}

property("calculateDelay()") {
val script = "calculateDelay(base58'aaa', 123, Address(base58'bbb'), 456)"
assertDecompile(script, script, V8)
}

property("replaceByIndex()") {
val script = """replaceByIndex(["a", "b", "c"], 1, "x")"""
assertDecompile(script, script, V8)
}
}

0 comments on commit d711d9a

Please sign in to comment.