diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index aa46cd1b063..3d14418423d 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -97,6 +97,33 @@ jobs: name: waves-all - run: find -name "*.ride" -type f -exec java -cp '*' com.wavesplatform.lang.FileCompiler {} +; + ride-js-tests: + name: RIDE JS bundle tests + runs-on: ubuntu-latest + needs: check-pr + if: needs.check-pr.outputs.lang-changed == 'true' + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: 'temurin' + java-version: '17' + cache: 'sbt' + - uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1.1.22 + - name: Build combined ScalaJS artifact into ride-js-bundle/scalajs + run: sbt --batch replJS/fullOptJS + - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: '>=24.7.0' + - run: corepack enable + - name: Build & test @waves/ride-js + env: + COREPACK_ENABLE_DOWNLOAD_PROMPT: '0' + run: | + cd ride-js-bundle + pnpm install --frozen-lockfile + pnpm test + run-integration-tests: name: Run integration tests # needs: check-pr diff --git a/.github/workflows/publish-to-npmjs.yml b/.github/workflows/publish-to-npmjs.yml index a4ac90d601d..674b66bb234 100644 --- a/.github/workflows/publish-to-npmjs.yml +++ b/.github/workflows/publish-to-npmjs.yml @@ -37,11 +37,22 @@ jobs: java-version: '17' cache: 'sbt' - uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1.1.22 - - run: sbt -Dproject.version=${{ steps.ghd.outputs.describe }} --batch ';lang-tests/test;lang-tests-js/test;repl/test;langJS/fullOptJS;replJS/fullOptJS' + # Emits the single combined ScalaJS artifact directly into ride-js-bundle/scalajs + # (see repl/js/build.sbt). lang-js is compiled transitively as a dependency of repl-js. + - run: sbt -Dproject.version=${{ steps.ghd.outputs.describe }} --batch ';lang-tests/test;repl/test;replJS/fullOptJS' - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: registry-url: 'https://registry.npmjs.org' node-version: '>=24.7.0' # Trusted publishing requires npm CLI version 11.5.1 or later. + - run: corepack enable + - name: Build & test @waves/ride-js + env: + COREPACK_ENABLE_DOWNLOAD_PROMPT: '0' + run: | + cd ride-js-bundle + pnpm install --frozen-lockfile + pnpm run build + pnpm test - if: github.event_name == 'workflow_dispatch' run: echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV @@ -52,10 +63,7 @@ jobs: echo "TAG=latest" >> $GITHUB_ENV - id: publish run: | - cd lang/js - npm version $VERSION --no-git-tag-version - npm publish --provenance --access public --tag $TAG - cd ../../repl/js - npm version $VERSION --no-git-tag-version + cd ride-js-bundle + npm version $VERSION --no-git-tag-version --allow-same-version npm publish --provenance --access public --tag $TAG - echo "url=https://www.npmjs.com/package/@waves/ride-lang/v/$VERSION" >> "$GITHUB_OUTPUT" + echo "url=https://www.npmjs.com/package/@waves/ride-js/v/$VERSION" >> "$GITHUB_OUTPUT" diff --git a/build.sbt b/build.sbt index 1c7fb9045dc..9b01786ad1b 100644 --- a/build.sbt +++ b/build.sbt @@ -79,15 +79,6 @@ lazy val `lang-tests` = project .in(file("lang/tests")) .dependsOn(`lang-testkit`) -lazy val `lang-tests-js` = project - .in(file("lang/tests-js")) - .enablePlugins(ScalaJSPlugin) - .dependsOn(`lang-js`) - .settings( - libraryDependencies += Dependencies.scalaJsTest.value, - testFrameworks += new TestFramework("utest.runner.Framework") - ) - lazy val node = project.dependsOn(`lang-jvm`) lazy val `node-testkit` = project @@ -154,7 +145,6 @@ lazy val `waves-node` = (project in file(".")) `lang-js`, `lang-jvm`, `lang-tests`, - `lang-tests-js`, `lang-testkit`, `repl-js`, `repl-jvm`, @@ -257,7 +247,7 @@ checkPRRaw := Def compilePRRaw, Def.sequential( test.all( - ScopeFilter(inProjects(`lang-tests`, `repl-jvm`, `lang-tests-js`, `grpc-server`, `node-tests`, `ride-runner`), inConfigurations(Test)) + ScopeFilter(inProjects(`lang-tests`, `repl-jvm`, `grpc-server`, `node-tests`, `ride-runner`), inConfigurations(Test)) ), fullOptJS.all(ScopeFilter(inProjects(`lang-js`, `repl-js`), inConfigurations(Compile))), assembly.all(ScopeFilter(inProjects(node))), diff --git a/lang/js/package.json b/lang/js/package.json deleted file mode 100644 index 9d0bb6c9b17..00000000000 --- a/lang/js/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@waves/ride-lang", - "version": "0.1.0", - "description": "RIDE Compiler and Evaluator", - "main": "dist/lang.js", - "module": "dist/lang.js", - "browser": "dist/lang.js", - "files": ["dist/"], - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/wavesplatform/Waves" - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/DAppComplexities.scala b/lang/tests-js/src/test/scala/com/wavesplatform/DAppComplexities.scala deleted file mode 100644 index 892522f1c59..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/DAppComplexities.scala +++ /dev/null @@ -1,9 +0,0 @@ -package com.wavesplatform - -case class DAppComplexities( - complexity: Int, - verifierComplexity: Int, - callableComplexities: Map[String, Int], - userFunctionComplexities: Map[String, Int], - globalVariableComplexities: Map[String, Int] -) diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/Global.scala b/lang/tests-js/src/test/scala/com/wavesplatform/Global.scala deleted file mode 100644 index 99a61503521..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/Global.scala +++ /dev/null @@ -1,12 +0,0 @@ -package com.wavesplatform - -import scala.scalajs.js.annotation.JSExportTopLevel -import scala.scalajs.js.typedarray.ArrayBuffer - -object Global { - @JSExportTopLevel("blake2b256") - def blake2b256(message: ArrayBuffer): ArrayBuffer = message - - @JSExportTopLevel("keccak256") - def keccak256(message: ArrayBuffer): ArrayBuffer = message -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/JsAPITest.scala b/lang/tests-js/src/test/scala/com/wavesplatform/JsAPITest.scala deleted file mode 100644 index d7394c16103..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/JsAPITest.scala +++ /dev/null @@ -1,242 +0,0 @@ -package com.wavesplatform - -import com.wavesplatform.lang.directives.values.{V5, V6} -import utest.* - -import scala.scalajs.js.{Array, Dictionary, Dynamic, JSON} - -object JsAPITest extends JsTestBase { - private def simpleDApp(result: String): String = - dApp( - s""" - |@Callable(i) - |func f() = $result - """.stripMargin, - V6 - ) - - val tests: Tests = Tests { - test("expression error and success") { - assertCompileError("1 + 1", "Script should return boolean") - assertCompileSuccess("true") - } - - test("dApp error and success") { - assertCompileError(simpleDApp("true"), "CallableFunction needs to return") - assertCompileSuccess(simpleDApp("[]")) - } - - test("expression complexity") { - expressionComplexity("sigVerify(base16'', base58'', base64'')", V5) ==> 200 - expressionComplexity("sigVerify(base16'', base58'', base64'')") ==> 180 - } - - test("dApp complexities") { - val r = dAppComplexities( - """ - | let x = 1 + 1 - | func f(list: List[Int]) =list.size() - | - | @Callable(i) - | func c1() = [] - | - | @Callable(i) - | func c2() = [IntegerEntry("key", x)] - | - | @Verifier(tx) - | func verify() = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) - """.stripMargin - ) - r.complexity ==> 182 - r.verifierComplexity ==> 182 - r.callableComplexities ==> Map("c1" -> 1, "c2" -> 4) - r.userFunctionComplexities ==> Map("f" -> 2) - r.globalVariableComplexities ==> Map("x" -> 1) - } - - test("AST result type for declarations") { - val compiled = JsAPI.parseAndCompile( - dApp( - """ - | func sum(acc: List[Int], elem: Int) = acc :+ elem - | let arr = [1, 2, 3, 4, 5] - | let letFold = FOLD<5>(arr, [], sum) - | - | @Callable(i) - | func default() = { - | let letCall = i.caller.toString() - | let letIf = if (true) then 1 else "" - | let letMatch = match letIf { - | case _: Int => true - | case _: String => Address(base58'') - | } - | func funcRef() = letCall - | [] - | } - """.stripMargin, - V6 - ), - 3 - ) - val callables = compiled.dAppAst.annFuncList.asInstanceOf[Array[Dynamic]] - - val invocation = callables(0).func.expr.dec.expr.args.asInstanceOf[Array[Dynamic]].apply(0).ref - invocation.name ==> "i" - invocation.resultType.`type` ==> "Invocation" - - val letCall = callables(0).func.expr.dec - letCall.name.value ==> "letCall" - letCall.expr.resultType.`type` ==> "String" - - val letIf = callables(0).func.expr.body.dec - letIf.name.value ==> "letIf" - JSON.stringify(letIf.expr.resultType.unionTypes) ==> """[{"type":"Int"},{"type":"String"}]""" - - val letMatch = callables(0).func.expr.body.body.dec - letMatch.name.value ==> "letMatch" - JSON.stringify(letMatch.expr.resultType.unionTypes) ==> """[{"type":"Boolean"},{"type":"Address"}]""" - - val funcRef = callables(0).func.expr.body.body.body.dec - funcRef.name.value ==> "funcRef" - funcRef.expr.resultType.`type` ==> "String" - - val letFold = compiled.dAppAst.decList.asInstanceOf[Array[Dynamic]].apply(2) - letFold.name.value ==> "letFold" - JSON.stringify(letFold.expr.resultType) ==> """{"listOf":{"type":"Int"}}""" - } - - test("AST result should be fixed while using libraries") { - val script = - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# IMPORT lib1, lib2, lib3 #-} - | let a = 5 - | func f() = 3 - | true - """.stripMargin - - val import1 = - "lib1" -> - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# CONTENT_TYPE LIBRARY #-} - | func inc(a: Int) = a + 1 - """.stripMargin - - val anotherImport1 = - "lib1" -> - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# CONTENT_TYPE LIBRARY #-} - | func inc(a: Int) = { - | if (true) then throw() else a + 1 - | } - """.stripMargin - - val import2 = - "lib2" -> - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# CONTENT_TYPE LIBRARY #-} - | func dec(a: Int) = a - 1 - """.stripMargin - - val import3 = - "lib3" -> - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# CONTENT_TYPE LIBRARY #-} - | func multiply(a: Int, b: Int) = a * b - """.stripMargin - - val r1 = JsAPI.parseAndCompile(script, 3, libraries = Dictionary(import1, import2, import3)) - val r2 = JsAPI.parseAndCompile(script, 3, libraries = Dictionary(anotherImport1, import2, import3)) - - def checkPos(expr: Dynamic) = { - val let = expr.exprAst.expr.body.body.body.dec - let.`type` ==> "LET" - let.name.value ==> "a" - let.posStart ==> 64 - let.posEnd ==> 73 - - val func = expr.exprAst.expr.body.body.body.body.dec - func.`type` ==> "FUNC" - func.name.value ==> "f" - func.posStart ==> 75 - func.posEnd ==> 87 - } - - checkPos(r1) - checkPos(r2) - } - - test("correct AST for library") { - val library = - """ - | {-# SCRIPT_TYPE ACCOUNT #-} - | {-# CONTENT_TYPE LIBRARY #-} - | func f() = 1 - """.stripMargin - - val result = JsAPI.parseAndCompile(library, 3) - val expected = """ - |{ - | "dec": { - | "type": "FUNC", - | "posStart": 62, - | "posEnd": 74, - | "name": { - | "value": "f", - | "posStart": 67, - | "posEnd": 68 - | }, - | "argList": [], - | "expr": { - | "type": "CONST_LONG", - | "posStart": 73, - | "posEnd": 74, - | "resultType": { - | "type": "Int" - | }, - | "ctx": [] - | } - | }, - | "body": { - | "type": "TRUE", - | "posStart": 84, - | "posEnd": 88, - | "resultType": { - | "type": "Boolean" - | }, - | "ctx": [] - | }, - | "type": "BLOCK", - | "posStart": 62, - | "posEnd": 88, - | "resultType": { - | "type": "Boolean" - | }, - | "ctx": [] - |} - """.stripMargin - JSON.stringify(result.exprAst.expr) ==> JSON.stringify(JSON.parse(expected)) - JSON.stringify(result.errorList) ==> "[]" - } - - test("ill-formed characters") { - val invalidChar = '\ud87e' - val script = - s""" - |{-# STDLIB_VERSION 6 #-} - |{-# CONTENT_TYPE DAPP #-} - |{-# SCRIPT_TYPE ACCOUNT #-} - | - |func call(a: String, b: Int) = { - | let zzz = "aaa${invalidChar}bbb" - | ([], zzz) - |} - """.stripMargin - assertCompileError(script, "contains ill-formed characters") - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/JsTestBase.scala b/lang/tests-js/src/test/scala/com/wavesplatform/JsTestBase.scala deleted file mode 100644 index 599f14b368d..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/JsTestBase.scala +++ /dev/null @@ -1,73 +0,0 @@ -package com.wavesplatform - -import com.wavesplatform.lang.directives.values.{StdLibVersion, V6} -import testHelpers.TestDataConstantsAndMethods -import utest.{TestSuite, assert} - -import scala.scalajs.js.{Dictionary, isUndefined} - -abstract class JsTestBase extends TestSuite { - - protected val testData: TestDataConstantsAndMethods.type = TestDataConstantsAndMethods - protected def assertCompileError(code: String, expectingError: String, estimator: Int = 3): Unit = { - val error = JsAPI.compile(code, estimator).error - assert(error.toString.contains(expectingError)) - } - - protected def assertCompileErrorDApp(code: String, version: StdLibVersion, expectingError: String, estimator: Int = 3): Unit = { - val error = JsAPI.compile(dApp(code, version), estimator).error - assert(error.toString.contains(expectingError)) - } - - protected def assertCompileErrorExpression(code: String, version: StdLibVersion, expectingError: String, estimator: Int = 3): Unit = { - val error = JsAPI.compile(expression(code, version), estimator).error - assert(error.toString.contains(expectingError)) - } - - protected def assertCompileSuccess(code: String, estimator: Int = 3): Unit = { - val error = JsAPI.compile(code, estimator).error - assert(isUndefined(error)) - } - - protected def assertCompileSuccessDApp(code: String, version: StdLibVersion, estimator: Int = 3): Unit = { - val error = JsAPI.compile(dApp(code, version), estimator).error - assert(isUndefined(error)) - } - - protected def assertCompileSuccessExpression(code: String, version: StdLibVersion, estimator: Int = 3): Unit = { - val error = JsAPI.compile(expression(code, version), estimator).error - assert(isUndefined(error)) - } - - protected def expressionComplexity(code: String, version: StdLibVersion = V6, estimator: Int = 3): Int = - JsAPI.compile(expression(code, version), estimator).complexity.asInstanceOf[Int] - - protected def dAppComplexities(code: String, version: StdLibVersion = V6, estimator: Int = 3): DAppComplexities = { - val result = JsAPI.compile(dApp(code, version), estimator) - DAppComplexities( - result.complexity.asInstanceOf[Int], - result.verifierComplexity.asInstanceOf[Int], - result.callableComplexities.asInstanceOf[Dictionary[Int]].toMap, - result.userFunctionComplexities.asInstanceOf[Dictionary[Int]].toMap, - result.globalVariableComplexities.asInstanceOf[Dictionary[Int]].toMap - ) - } - - protected def expression(code: String, version: StdLibVersion): String = - s""" - |{-# STDLIB_VERSION ${version.id} #-} - |{-# CONTENT_TYPE EXPRESSION #-} - |{-# SCRIPT_TYPE ACCOUNT #-} - | - |$code - """.stripMargin - - protected def dApp(code: String, version: StdLibVersion): String = - s""" - |{-# STDLIB_VERSION ${version.id} #-} - |{-# CONTENT_TYPE DAPP #-} - |{-# SCRIPT_TYPE ACCOUNT #-} - | - |$code - """.stripMargin -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/NegativeTestsOfUnsupportedMethods.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/NegativeTestsOfUnsupportedMethods.scala deleted file mode 100644 index 61928f77acd..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/NegativeTestsOfUnsupportedMethods.scala +++ /dev/null @@ -1,123 +0,0 @@ -package com.wavesplatform.test.builtInFunctions - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{ - CANT_FIND_FUNCTION, - GreaterV3ResultBinaryEntry, - UNDEFINED_TYPE, - intList, - oldVersions, - rideV3Result, - stringList -} -import utest.{Tests, test} - -object NegativeTestsOfUnsupportedMethods extends JsTestBase { - private val toBigInt = "toBigInt(callerTestData)" - private val toBigIntArgBeforeFunc = "callerTestData.toBigInt()" - private val invokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" - - private val blake2b256_16Kb = "blake2b256_16Kb(callerTestData)" - private val blake2b256_32Kb = "blake2b256_32Kb(callerTestData)" - private val blake2b256_64Kb = "blake2b256_64Kb(callerTestData)" - private val blake2b256_128Kb = "blake2b256_128Kb(callerTestData)" - private val keccak256_16Kb = "keccak256_16Kb(callerTestData)" - private val keccak256_32Kb = "keccak256_32Kb(callerTestData)" - private val keccak256_64Kb = "keccak256_64Kb(callerTestData)" - private val keccak256_128Kb = "keccak256_128Kb(callerTestData)" - - private val containsElement = "containsElement(foo, bar)" - private val indexOf = "indexOf(bar, foo)" - private val removeByIndex = "removeByIndex(bar, foo)" - - private val max = "max(callerTestData)" - private val min = "min(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-280. toBigInt function should throw a compilation error for RIDE versions V3 and V4.") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, toBigInt, UNDEFINED_TYPE), - (randomStringArrayElement, toBigIntArgBeforeFunc, UNDEFINED_TYPE) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-281. compilation error 'invalid data invoke' should occur for RIDE versions V3 and V4 when an argument is placed before the function.") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - val script = precondition.codeForDAppInvocation(randomByteVectorArrayElement, randomAddressDataArrayElement, invokeArgBeforeFunc) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - - test("RIDE-282. blake2b256 functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - for ( - (data, function, error) <- Seq( - (randomByteVectorArrayElement, blake2b256_16Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, blake2b256_32Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, blake2b256_64Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, blake2b256_128Kb, CANT_FIND_FUNCTION) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, V3, error) - } - } - - test("RIDE-283. keccak256 functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - for ( - (data, function, error) <- Seq( - (randomByteVectorArrayElement, keccak256_16Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, keccak256_32Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, keccak256_64Kb, CANT_FIND_FUNCTION), - (randomByteVectorArrayElement, keccak256_128Kb, CANT_FIND_FUNCTION) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, V3, error) - } - } - - test("RIDE-284. containsElement functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - val script = precondition.simpleRideCode(randomStringArrayElement, stringList, containsElement) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - - test("RIDE-285. indexOf functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - val script = precondition.simpleRideCode(randomInt.toString, intList, indexOf) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - - test("RIDE-286. max functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - val script = precondition.simpleRideCode(randomInt.toString, intList, max) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - - test("RIDE-287. min functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - val script = precondition.simpleRideCode(randomInt.toString, intList, min) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - - test("RIDE-288. removeByIndex functions should throw an error for RIDE version V3.") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - val script = precondition.simpleRideCode(randomInt.toString, intList, removeByIndex) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBinary.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBinary.scala deleted file mode 100644 index f192f4af3a2..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBinary.scala +++ /dev/null @@ -1,97 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.accountDataStorage - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, rideV3Result, thisVariable} -import utest.{Tests, test} - -object GetBinary extends JsTestBase { - // getBinary - private val getBinary = s"getBinary(callerTestData, $randomStringArrayElement)" - private val getBinaryArgBeforeFunc = s"callerTestData.getBinary($randomStringArrayElement)" - private val ownDataGetBinary = s"getBinary($randomStringArrayElement)" - private val ownDataGetBinaryArgBeforeFunc = s"$randomStringArrayElement.getBinary()" - - // getBinaryValue - private val getBinaryValue = s"getBinaryValue(callerTestData, $randomStringArrayElement)" - private val getBinaryValueArgBeforeFunc = s"callerTestData.getBinaryValue($randomStringArrayElement)" - private val ownDataGetBinaryValue = s"getBinaryValue($randomStringArrayElement)" - private val ownDataGetBinaryValueArgBeforeFunc = s"$randomStringArrayElement.getBinaryValue()" - - private val invalidGetBinary = s"getBinary(callerTestData)" - private val invalidGetBinaryValue = s"getBinaryValue(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-4. Compile getBinary functions for address, alias, and 'this'") { - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (addressOrAlias, binary) <- Seq( - (randomAddressDataArrayElement, getBinary), - (randomAddressDataArrayElement, getBinaryArgBeforeFunc), - (randomAliasDataArrayElement, getBinary), - (randomAliasDataArrayElement, getBinaryArgBeforeFunc), - (randomAddressDataArrayElement, getBinaryValue), - (randomAddressDataArrayElement, getBinaryValueArgBeforeFunc), - (randomAliasDataArrayElement, getBinaryValue), - (randomAliasDataArrayElement, getBinaryValueArgBeforeFunc), - (thisVariable, getBinary), - (thisVariable, getBinaryArgBeforeFunc), - (thisVariable, getBinaryValue), - (thisVariable, getBinaryValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-5. Compile own data getBinary functions for address, alias, and 'this'") { - for (version <- testData.versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for (ownData <- Seq(ownDataGetBinary, ownDataGetBinaryArgBeforeFunc, ownDataGetBinaryValueArgBeforeFunc, ownDataGetBinaryValue)) { - val script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-6. Test negative scenarios for getBinary functions") { - val invalidFunction = s"getBinaryValue($randomInt)" - val invalidArgBeforeFunction = s"$randomInt.getBinaryValue()" - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (addressOrAlias, binary) <- Seq( - (randomAddressDataArrayElement, invalidGetBinary), - (randomAliasDataArrayElement, invalidGetBinaryValue), - (randomInt.toString, getBinary), - (randomInt.toString, getBinaryValue), - (randomInt.toString, invalidFunction), - (randomInt.toString, invalidArgBeforeFunction), - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-7. Ensure no overload of own data Binary accountDataStorage for old versions") { - for (version <- testData.oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (addressOrAlias, binary) <- Seq( - (randomAddressDataArrayElement, ownDataGetBinaryValue), - (randomAliasDataArrayElement, ownDataGetBinaryValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBoolean.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBoolean.scala deleted file mode 100644 index fbd9506e11e..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetBoolean.scala +++ /dev/null @@ -1,97 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.accountDataStorage - -import com.wavesplatform.JsTestBase -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import _root_.testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBooleanEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object GetBoolean extends JsTestBase { - // getBoolean - private val getBoolean = s"getBoolean(callerTestData, $randomStringArrayElement)" - private val getBooleanArgBeforeFunc = s"callerTestData.getBoolean($randomStringArrayElement)" - private val ownDataGetBoolean = s"getBoolean($randomStringArrayElement)" - private val ownDataGetBooleanArgBeforeFunc = s"$randomStringArrayElement.getBoolean()" - - // getBooleanValue - private val getBooleanValue = s"getBooleanValue(callerTestData, $randomStringArrayElement)" - private val getBooleanValueArgBeforeFunc = s"callerTestData.getBooleanValue($randomStringArrayElement)" - private val ownDataGetBooleanValue = s"getBooleanValue($randomStringArrayElement)" - private val ownDataGetBooleanValueArgBeforeFunc = s"$randomStringArrayElement.getBooleanValue()" - - private val invalidGetBoolean = s"getBoolean(callerTestData)" - private val invalidGetBooleanValue = s"getBooleanValue(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-8. Compile getBoolean functions for address, alias, and 'this'") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, booleanData) <- Seq( - (randomAddressDataArrayElement, getBoolean), - (randomAddressDataArrayElement, getBooleanArgBeforeFunc), - (randomAliasDataArrayElement, getBoolean), - (randomAliasDataArrayElement, getBooleanArgBeforeFunc), - (randomAddressDataArrayElement, getBooleanValue), - (randomAddressDataArrayElement, getBooleanValueArgBeforeFunc), - (randomAliasDataArrayElement, getBooleanValue), - (randomAliasDataArrayElement, getBooleanValueArgBeforeFunc), - (thisVariable, getBoolean), - (thisVariable, getBooleanArgBeforeFunc), - (thisVariable, getBooleanValue), - (thisVariable, getBooleanValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-9. Compile own data getBoolean functions for address, alias, and 'this'") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for (ownData <- Seq(ownDataGetBoolean, ownDataGetBooleanArgBeforeFunc, ownDataGetBooleanValueArgBeforeFunc, ownDataGetBooleanValue)) { - val script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-10. Negative tests for getBoolean functions") { - val invalidFunction = s"getBooleanValue($randomInt)" - val invalidArgBeforeFunction = s"$randomInt.getBooleanValue()" - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, booleanData) <- Seq( - (randomAddressDataArrayElement, invalidGetBoolean), - (randomAliasDataArrayElement, invalidGetBooleanValue), - (randomInt.toString, getBoolean), - (randomInt.toString, getBooleanValue), - (randomInt.toString, invalidFunction), - (randomInt.toString, invalidArgBeforeFunction), - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-11. Ensure no overload of own data Boolean accountDataStorage for old Versions") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, booleanData) <- Seq( - (randomAddressDataArrayElement, ownDataGetBooleanValue), - (randomAliasDataArrayElement, ownDataGetBooleanValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetInteger.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetInteger.scala deleted file mode 100644 index 65e7715c890..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetInteger.scala +++ /dev/null @@ -1,97 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.accountDataStorage - -import com.wavesplatform.JsTestBase -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import _root_.testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultIntegerEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object GetInteger extends JsTestBase { - // getInteger - private val getInteger = s"getInteger(callerTestData, $randomStringArrayElement)" - private val getIntegerArgBeforeFunc = s"callerTestData.getInteger($randomStringArrayElement)" - private val ownDataGetInt = s"getInteger($randomStringArrayElement)" - private val ownDataGetIntArgBeforeFunc = s"$randomStringArrayElement.getInteger()" - - // getIntegerValue - private val getIntegerValue = s"getIntegerValue(callerTestData, $randomStringArrayElement)" - private val getIntegerValueArgBeforeFunc = s"callerTestData.getIntegerValue($randomStringArrayElement)" - private val ownDataGetIntValue = s"getIntegerValue($randomStringArrayElement)" - private val ownDataGetIntValueArgBeforeFunc = s"$randomStringArrayElement.getIntegerValue()" - - private val invalidGetInt = s"getInteger(callerTestData)" - private val invalidGetIntValue = s"getIntegerValue(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-12. Compile getInteger functions for address, alias, and 'this'") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (addressOrAlias, intData) <- Seq( - (randomAddressDataArrayElement, getInteger), - (randomAddressDataArrayElement, getIntegerArgBeforeFunc), - (randomAliasDataArrayElement, getInteger), - (randomAliasDataArrayElement, getIntegerArgBeforeFunc), - (randomAddressDataArrayElement, getIntegerValue), - (randomAddressDataArrayElement, getIntegerValueArgBeforeFunc), - (randomAliasDataArrayElement, getIntegerValue), - (randomAliasDataArrayElement, getIntegerValueArgBeforeFunc), - (thisVariable, getInteger), - (thisVariable, getIntegerArgBeforeFunc), - (thisVariable, getIntegerValue), - (thisVariable, getIntegerValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-13. Compile own data getInteger functions for address, alias, and 'this'") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for (ownData <- Seq(ownDataGetInt, ownDataGetIntArgBeforeFunc, ownDataGetIntValueArgBeforeFunc, ownDataGetIntValue)) { - val script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-14. Test negative scenarios for getInteger functions") { - val invalidFunction = s"getIntegerValue($randomInt)" - val invalidArgBeforeFunction = s"$randomInt.getIntegerValue()" - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (addressOrAlias, intData) <- Seq( - (randomAddressDataArrayElement, invalidGetInt), - (randomAliasDataArrayElement, invalidGetIntValue), - (randomInt.toString, getInteger), - (randomInt.toString, getIntegerValue), - (randomInt.toString, invalidFunction), - (randomInt.toString, invalidArgBeforeFunction), - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-15. Ensure no overload of own data Integer accountDataStorage for old versions") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (addressOrAlias, intData) <- Seq( - (randomAddressDataArrayElement, ownDataGetIntValue), - (randomAliasDataArrayElement, ownDataGetIntValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetString.scala deleted file mode 100644 index fa6d8a6ce89..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/GetString.scala +++ /dev/null @@ -1,97 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.accountDataStorage - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultStringEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object GetString extends JsTestBase { - // getString - private val getString = s"getString(callerTestData, $randomStringArrayElement)" - private val getStringArgBeforeFunc = s"callerTestData.getString($randomStringArrayElement)" - private val ownDataGetString = s"getString($randomStringArrayElement)" - private val ownDataGetStringArgBeforeFunc = s"$randomStringArrayElement.getString()" - - // getStringValue - private val getStringValue = s"getStringValue(callerTestData, $randomStringArrayElement)" - private val getStringValueArgBeforeFunc = s"callerTestData.getStringValue($randomStringArrayElement)" - private val ownDataGetStringValue = s"getStringValue($randomStringArrayElement)" - private val ownDataGetStringValueArgBeforeFunc = s"$randomStringArrayElement.getStringValue()" - - private val invalidGetString = s"getString(callerTestData)" - private val invalidGetStringValue = s"getStringValue(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-16. Compile getString functions for address, alias, and 'this'") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (addressOrAlias, stringData) <- Seq( - (randomAddressDataArrayElement, getString), - (randomAddressDataArrayElement, getStringArgBeforeFunc), - (randomAliasDataArrayElement, getString), - (randomAliasDataArrayElement, getStringArgBeforeFunc), - (randomAddressDataArrayElement, getStringValue), - (randomAddressDataArrayElement, getStringValueArgBeforeFunc), - (randomAliasDataArrayElement, getStringValue), - (randomAliasDataArrayElement, getStringValueArgBeforeFunc), - (thisVariable, getString), - (thisVariable, getStringArgBeforeFunc), - (thisVariable, getStringValue), - (thisVariable, getStringValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-17. Compile own data getString functions for address, alias, and 'this'") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for (ownData <- Seq(ownDataGetString, ownDataGetStringArgBeforeFunc, ownDataGetStringValueArgBeforeFunc, ownDataGetStringValue)) { - val script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-18. Test negative scenarios for getString functions") { - val invalidFunction = s"getStringValue($randomInt)" - val invalidArgBeforeFunction = s"$randomInt.getStringValue()" - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (addressOrAlias, stringData) <- Seq( - (randomAddressDataArrayElement, invalidGetString), - (randomAliasDataArrayElement, invalidGetStringValue), - (randomInt.toString, getString), - (randomInt.toString, getStringValue), - (randomInt.toString, invalidFunction), - (randomInt.toString, invalidArgBeforeFunction), - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-19. Ensure no overload of own data Integer accountDataStorage for old versions") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (addressOrAlias, stringData) <- Seq( - (randomAddressDataArrayElement, ownDataGetStringValue), - (randomAliasDataArrayElement, ownDataGetStringValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/IsDataStorageUntouched.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/IsDataStorageUntouched.scala deleted file mode 100644 index e5c1f9f3d37..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/accountDataStorage/IsDataStorageUntouched.scala +++ /dev/null @@ -1,90 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.accountDataStorage - -import com.wavesplatform.JsTestBase -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import _root_.testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt} -import testHelpers.TestDataConstantsAndMethods.{ - GreaterV3ResultBooleanEntry, - invalidFunctionError, - nonMatchingTypes, - oldVersions, - rideV3Result, - thisVariable, - versionsSupportingTheNewFeatures -} -import utest.{Tests, test} - -object IsDataStorageUntouched extends JsTestBase { - private val isDataStorageUntouched = "isDataStorageUntouched(callerTestData)" - private val isDataStorageUntouchedArgBeforeFunc = "callerTestData.isDataStorageUntouched()" - private val invalidFunction = "isDataStorageUntouched()" - private val invalidFunctionErrorResult: String = invalidFunctionError("isDataStorageUntouched", 1) - - val tests: Tests = Tests { - test("RIDE-20. Compile isDataStorageUntouched functions for address, alias, and 'this'") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, dataStorage) <- Seq( - (randomAddressDataArrayElement, isDataStorageUntouched), - (randomAddressDataArrayElement, isDataStorageUntouchedArgBeforeFunc), - (randomAliasDataArrayElement, isDataStorageUntouched), - (randomAliasDataArrayElement, isDataStorageUntouchedArgBeforeFunc), - (thisVariable, isDataStorageUntouched), - (thisVariable, isDataStorageUntouchedArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-21. Non-matching types for function isDataStorageUntouched") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, dataStorage) <- Seq( - (randomInt.toString, isDataStorageUntouched), - (randomInt.toString, isDataStorageUntouchedArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, nonMatchingTypes("Address|Alias")) - } - } - } - - test("RIDE-22. Invalid data for functions isDataStorageUntouched") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, dataStorage) <- Seq( - (randomAddressDataArrayElement, invalidFunction), - (randomAliasDataArrayElement, invalidFunction), - (thisVariable, invalidFunction) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, invalidFunctionErrorResult) - } - } - } - - test("RIDE-23. Can't find functions isDataStorageUntouched dataStorage accountDataStorage for old Versions") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (addressOrAlias, dataStorage) <- Seq( - (randomAddressDataArrayElement, isDataStorageUntouchedArgBeforeFunc), - (thisVariable, isDataStorageUntouchedArgBeforeFunc), - (randomAliasDataArrayElement, isDataStorageUntouched) - ) - ) { - val script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, testData.CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AddressFromRecipient.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AddressFromRecipient.scala deleted file mode 100644 index d5a277f471f..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AddressFromRecipient.scala +++ /dev/null @@ -1,61 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import _root_.testHelpers.RandomDataGenerator.* -import com.wavesplatform.JsTestBase -import testHelpers.TestDataConstantsAndMethods.thisVariable -import utest.{Tests, test} - -object AddressFromRecipient extends JsTestBase { - private val addressFromRecipient = "addressFromRecipient(addressOrAlias)" - private val addressFromRecipientArgBeforeFunc = "addressOrAlias.addressFromRecipient()" - private val invalidFunc = "addressFromRecipient()" - - val tests: Tests = Tests { - test("RIDE-24. Compile addressFromRecipient function for address, alias, and 'this'") { - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (addressOrAlias, function, address) <- Seq( - (randomAddressDataArrayElement, addressFromRecipient, randomAddressDataArrayElement), - (randomAliasDataArrayElement, addressFromRecipient, randomAddressDataArrayElement), - (thisVariable, addressFromRecipient, randomAddressDataArrayElement), - (randomAddressDataArrayElement, addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement), - (randomAliasDataArrayElement, addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement), - (thisVariable, addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement) - ) - ) { - val script = precondition.codeForAddressFromRecipient(addressOrAlias, function, address) - assertCompileSuccessExpression(script, version) - } - } - } - - test("RIDE-25. Invalid data for functions addressFromRecipient") { - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (addressOrAlias, function, address) <- Seq( - (randomInt.toString, addressFromRecipient, randomAddressDataArrayElement), - (randomInt.toString, addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement) - ) - ) { - val script = precondition.codeForAddressFromRecipient(addressOrAlias, function, address) - assertCompileErrorExpression(script, version, testData.nonMatchingTypes("Address|Alias")) - } - } - } - - test("RIDE-26. Function 'addressFromRecipient' requires 1 arguments") { - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - val script = precondition.codeForAddressFromRecipient( - randomAddressDataArrayElement, - invalidFunc, - randomAddressDataArrayElement - ) - assertCompileErrorExpression(script, version, testData.invalidFunctionError("addressFromRecipient", 1)) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetBalance.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetBalance.scala deleted file mode 100644 index 934d92fe8fa..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetBalance.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultIntegerEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result, thisVariable} -import utest.{Tests, test} - -object AssetBalance extends JsTestBase { - private val address: String = randomAddressDataArrayElement - private val alias: String = randomAliasDataArrayElement - private val byteVector: String = randomByteVectorArrayElement - - private val assetBalance = s"assetBalance(callerTestData, $byteVector)" - private val assetBalanceArgBeforeFunc = s"callerTestData.assetBalance($byteVector)" - private val invalidAssetBalanceFunc = "assetBalance()" - - val tests: Tests = Tests { - test("RIDE-27. Compile assetBalance function for address, alias, and 'this'") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (addressOrAlias, function) <- Seq( - (address, assetBalance), - (alias, assetBalance), - (thisVariable, assetBalance), - (address, assetBalanceArgBeforeFunc), - (alias, assetBalanceArgBeforeFunc), - (thisVariable, assetBalanceArgBeforeFunc), - ) - ) { - val script = precondition.codeWithoutMatcher(addressOrAlias, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-28. Invalid data must be validated") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (addressOrAlias, function, error) <- Seq( - (address, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)), - (alias, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)), - (thisVariable, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)), - (randomUnionArrayElement, assetBalance, nonMatchingTypes("Address|Alias")), - (randomByteVectorArrayElement, assetBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")), - ) - ) { - val script = precondition.codeWithoutMatcher(addressOrAlias, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetInfo.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetInfo.scala deleted file mode 100644 index 2fc98649e25..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/AssetInfo.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import _root_.testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomInt} -import com.wavesplatform.JsTestBase -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object AssetInfo extends JsTestBase { - - private val assetInfo = "assetInfo(callerTestData)" - private val assetInfoArgBeforeFunc = "callerTestData.assetInfo()" - - private val invalidAssetInfo = "assetInfo()" - private val invalidAssetInfoArg = s"$randomInt.assetInfo()" - - - val tests: Tests = Tests { - test("RIDE-30. Compile assetInfo function for asset") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Asset", version) - for ( - (asset, function) <- Seq( - (randomByteVectorArrayElement, assetInfo), - (randomByteVectorArrayElement, assetInfoArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(asset, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-29. Invalid data must be validated") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Asset", version) - for ( - (asset, function, error) <- Seq( - (randomByteVectorArrayElement, invalidAssetInfo, invalidFunctionError("assetInfo", 1)), - (randomByteVectorArrayElement, invalidAssetInfoArg, nonMatchingTypes("ByteVector")), - (randomAliasDataArrayElement, assetInfo, nonMatchingTypes("ByteVector")), - (randomBoolean.toString, assetInfoArgBeforeFunc, nonMatchingTypes("ByteVector")), - ) - ) { - val script = precondition.onlyMatcherContract(asset, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/BlockInfoByHeight.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/BlockInfoByHeight.scala deleted file mode 100644 index e5489909ab9..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/BlockInfoByHeight.scala +++ /dev/null @@ -1,47 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomBoolean, randomInt} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object BlockInfoByHeight extends JsTestBase { - private val blockInfoByHeight = "blockInfoByHeight(callerTestData)" - private val blockInfoByHeightArgBeforeFunc = "callerTestData.blockInfoByHeight()" - - private val invalidBlockInfoByHeight = "blockInfoByHeight()" - - val tests: Tests = Tests { - test("RIDE-31. BlockInfoByHeight function should compile") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("BlockInfo", version) - for ( - (intData, function) <- Seq( - (randomInt.toString, blockInfoByHeight), - (randomInt.toString, blockInfoByHeightArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(intData, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-32. Negative cases for blockInfoByHeight function when invalid arguments are passed") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("BlockInfo", version) - for ( - (intData, function, error) <- Seq( - (randomInt.toString, invalidBlockInfoByHeight, invalidFunctionError("blockInfoByHeight", 1)), - (randomAliasDataArrayElement, blockInfoByHeight, nonMatchingTypes("Int")), - (randomBoolean.toString, blockInfoByHeightArgBeforeFunc, nonMatchingTypes("Int")) - ) - ) { - val script = precondition.onlyMatcherContract(intData, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateAssetId.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateAssetId.scala deleted file mode 100644 index a0779d32e80..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateAssetId.scala +++ /dev/null @@ -1,60 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.RandomDataGenerator.{randomDigestAlgorithmTypeArrayElement, randomIssuesArrayElement} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object CalculateAssetId extends JsTestBase { - private val calculateAssetId = "calculateAssetId(issue)" - private val calculateAssetIdArgBeforeFunc = "issue.calculateAssetId()" - private val invalidCalculateAssetId = "calculateAssetId()" - - val tests: Tests = Tests { - test("RIDE-33. CalculateAssetId function should compile for version V4 and higher when called for Issue operatio") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomIssuesArrayElement, calculateAssetId), - (randomIssuesArrayElement, calculateAssetIdArgBeforeFunc) - ) - ) { - val script = precondition.codeForCalculateAssetId(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-34. Negative cases for CalculateAssetId function for version V4 and higher") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, calculateAssetId, nonMatchingTypes("Issue")), - (randomDigestAlgorithmTypeArrayElement, calculateAssetIdArgBeforeFunc, nonMatchingTypes("Issue")), - (randomDigestAlgorithmTypeArrayElement, invalidCalculateAssetId, invalidFunctionError("calculateAssetId", 1)), - ) - ) { - val script = precondition.codeForCalculateAssetId(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-35. Negative cases for CalculateAssetId function for version V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - for ( - (data, function) <- Seq( - (randomIssuesArrayElement, calculateAssetId), - (randomIssuesArrayElement, calculateAssetIdArgBeforeFunc) - ) - ) { - val script = precondition.codeForCalculateAssetId(data, function) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateLeaseId.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateLeaseId.scala deleted file mode 100644 index 2cfc43abf61..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/CalculateLeaseId.scala +++ /dev/null @@ -1,64 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomDigestAlgorithmTypeArrayElement, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, CANT_FIND_FUNCTION, invalidFunctionError, oldVersions, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object CalculateLeaseId extends JsTestBase { - private val calculateLeaseId = "calculateLeaseId(lease)" - private val calculateLeaseIdArgBeforeFunc = "lease.calculateLeaseId()" - private val invalidCalculateLeaseId = "calculateLeaseId()" - - val tests: Tests = Tests { - test("RIDE-36. calculateLeaseId function should compile for version V5 and higher when called for an address") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, calculateLeaseId), - (randomAddressDataArrayElement, calculateLeaseIdArgBeforeFunc), - (randomAliasDataArrayElement, calculateLeaseId), - (randomAliasDataArrayElement, calculateLeaseIdArgBeforeFunc) - ) - ) { - val script = precondition.codeForCalculateLeaseId(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-37. Negative cases for calculateLeaseId function for version V5 and higher") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function, error) <- Seq( - (randomStringArrayElement, calculateLeaseId, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomDigestAlgorithmTypeArrayElement, calculateLeaseIdArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomAddressDataArrayElement, invalidCalculateLeaseId, invalidFunctionError("calculateLeaseId", 1)), - (randomAliasDataArrayElement, invalidCalculateLeaseId, invalidFunctionError("calculateLeaseId", 1)), - ) - ) { - val script = precondition.codeForCalculateLeaseId(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-38. Negative cases for calculateLeaseId function for versions V3 and V4") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomIssuesArrayElement, calculateLeaseId), - (randomIssuesArrayElement, calculateLeaseIdArgBeforeFunc) - ) - ) { - val script = precondition.codeForCalculateLeaseId(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/ScriptHash.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/ScriptHash.scala deleted file mode 100644 index 7939e97a755..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/ScriptHash.scala +++ /dev/null @@ -1,82 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomStringArrayElement -} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{ - CANT_FIND_FUNCTION, - GreaterV3ResultBinaryEntry, - invalidFunctionError, - nonMatchingTypes, - oldVersions, - rideV3Result, - thisVariable, - versionsSupportingTheNewFeatures -} -import utest.{Tests, test} - -object ScriptHash extends JsTestBase { - private val scriptHash = "scriptHash(callerTestData)" - private val scriptHashArgBeforeFunc = "callerTestData.scriptHash()" - private val invalidScriptHash = "scriptHash(callerTestData, callerTestData)" - private val invalidScriptHashArgBeforeFunc = s"callerTestData.scriptHash($randomStringArrayElement)" - - val tests: Tests = Tests { - test("RIDE-39. ScriptHash function should compile for version V5 and higher when called for an address") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, scriptHash), - (randomAddressDataArrayElement, scriptHashArgBeforeFunc), - (randomAliasDataArrayElement, scriptHash), - (randomAliasDataArrayElement, scriptHashArgBeforeFunc), - (thisVariable, scriptHash), - (thisVariable, scriptHashArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("Ride-40. Negative cases for ScriptHash function for version V5 and higher") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomStringArrayElement, scriptHash, nonMatchingTypes("Address|Alias")), - (randomDigestAlgorithmTypeArrayElement, scriptHashArgBeforeFunc, nonMatchingTypes("Address|Alias")), - (randomAddressDataArrayElement, invalidScriptHash, invalidFunctionError("scriptHash", 1)), - (randomAliasDataArrayElement, invalidScriptHash, invalidFunctionError("scriptHash", 1)), - (thisVariable, invalidScriptHashArgBeforeFunc, invalidFunctionError("scriptHash", 1)) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-41. Negative cases for ScriptHash function for versions V3 and V4") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, scriptHash), - (randomAliasDataArrayElement, scriptHashArgBeforeFunc) - ) - ) { - val script = precondition.codeForCalculateLeaseId(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransactionHeightById.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransactionHeightById.scala deleted file mode 100644 index e5073c55e0a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransactionHeightById.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object TransactionHeightById extends JsTestBase { - private val transactionHeightById = "transactionHeightById(callerTestData)" - private val transactionHeightByIdArgBeforeFunc = "callerTestData.transactionHeightById()" - - private val invalidTransactionHeightById = "transactionHeightById()" - private val invalidTransactionHeightByIdArg = s"callerTestData.transactionHeightById(callerTestData)" - - - val tests: Tests = Tests { - test("RIDE-42. TransactionHeightById function should compile") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, transactionHeightById), - (randomByteVectorArrayElement, transactionHeightByIdArgBeforeFunc), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-43. Negative cases for TransactionHeightById function") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, transactionHeightById, nonMatchingTypes("ByteVector")), - (randomStringArrayElement, transactionHeightByIdArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidTransactionHeightById, invalidFunctionError("transactionHeightById", 1)), - (randomByteVectorArrayElement, invalidTransactionHeightByIdArg, invalidFunctionError("transactionHeightById", 1)) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransferTransactionById.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransferTransactionById.scala deleted file mode 100644 index eceb3cdf48e..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/TransferTransactionById.scala +++ /dev/null @@ -1,53 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import testHelpers.RandomDataGenerator.{ - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomStringArrayElement -} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object TransferTransactionById extends JsTestBase { - private val transferTransactionById = "transferTransactionById(callerTestData)" - private val transferTransactionByIdArgBeforeFunc = "callerTestData.transferTransactionById()" - - private val invalidTransferTransactionById = "transferTransactionById()" - private val invalidTransferTransactionByIdArg = s"callerTestData.transferTransactionById(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-44. TransactionHeightById function should compile") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Unit", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, transferTransactionById), - (randomByteVectorArrayElement, transferTransactionByIdArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-45. Negative cases for TransactionHeightById function") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Unit", version) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, transferTransactionById, nonMatchingTypes("ByteVector")), - (randomStringArrayElement, transferTransactionByIdArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidTransferTransactionById, invalidFunctionError("transferTransactionById", 1)), - (randomByteVectorArrayElement, invalidTransferTransactionByIdArg, invalidFunctionError("transferTransactionById", 1)) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/WavesBalance.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/WavesBalance.scala deleted file mode 100644 index 0947de58311..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/blockchain/WavesBalance.scala +++ /dev/null @@ -1,85 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.blockchain - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, thisVariable} -import utest.{Tests, test} - -object WavesBalance extends JsTestBase { - private val wavesBalance = "wavesBalance(callerTestData)" - private val wavesBalanceArgBeforeFunc = "callerTestData.wavesBalance()" - private val invalidWavesBalance = "wavesBalance()" - private val invalidWavesBalanceArg = s"callerTestData.wavesBalance(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-46. wavesBalance function for version V4 and more should compile for address, alias, and 'this'") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("BalanceDetails", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, wavesBalance), - (randomAliasDataArrayElement, wavesBalance), - (thisVariable, wavesBalance), - (randomAddressDataArrayElement, wavesBalanceArgBeforeFunc), - (randomAliasDataArrayElement, wavesBalanceArgBeforeFunc), - (thisVariable, wavesBalanceArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-47. Negative cases for wavesBalance function for version V4 and more") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("BalanceDetails", version) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, wavesBalance, nonMatchingTypes("Address|Alias")), - (randomStringArrayElement, wavesBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")), - (randomAddressDataArrayElement, invalidWavesBalanceArg, invalidFunctionError("wavesBalance", 1)), - (randomAliasDataArrayElement, invalidWavesBalance, invalidFunctionError("wavesBalance", 1)) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-48. Functions wavesBalance for V3 compiles for address, alias and 'this'") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, wavesBalance), - (randomAliasDataArrayElement, wavesBalance), - (thisVariable, wavesBalance), - (randomAddressDataArrayElement, wavesBalanceArgBeforeFunc), - (randomAliasDataArrayElement, wavesBalanceArgBeforeFunc), - (thisVariable, wavesBalanceArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-49. compilation error: wavesBalance for V3 Non-matching type") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, wavesBalance, nonMatchingTypes("Address|Alias")), - (randomStringArrayElement, wavesBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")), - (randomAddressDataArrayElement, invalidWavesBalanceArg, invalidFunctionError("wavesBalance", 1)), - (randomAliasDataArrayElement, invalidWavesBalance, invalidFunctionError("wavesBalance", 1)) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, V3, error) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Drop.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Drop.scala deleted file mode 100644 index c73ff10bb68..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Drop.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.byteArray - -import com.wavesplatform.JsTestBase -import _root_.testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement} -import _root_.testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Drop extends JsTestBase { - private val drop = s"drop(callerTestData, $randomInt)" - private val dropArgBeforeFunction = s"callerTestData.drop($randomInt)" - private val invalidDrop = s"drop(callerTestData)" - private val invalidDropNotInt = s"drop(callerTestData, $randomByteVectorArrayElement)" - private val invalidDropArgBeforeFunc = s"callerTestData.drop(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-50. Drop function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, drop), - (randomByteVectorArrayElement, dropArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-51. Drop function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, drop), - (randomUnionArrayElement, dropArgBeforeFunction), - (randomByteVectorArrayElement, invalidDrop), - (randomByteVectorArrayElement, invalidDropNotInt), - (randomByteVectorArrayElement, invalidDropArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/DropRight.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/DropRight.scala deleted file mode 100644 index 164d5e942ff..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/DropRight.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.byteArray - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object DropRight extends JsTestBase { - private val dropRight = s"dropRight(callerTestData, $randomInt)" - private val dropRightArgBeforeFunction = s"callerTestData.dropRight($randomInt)" - private val invalidDropRight = s"dropRight(callerTestData)" - private val invalidDropRightNotInt = s"dropRight(callerTestData, $randomByteVectorArrayElement)" - private val invalidDropRightArgBeforeFunc = s"callerTestData.dropRight(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-52. DropRight function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, dropRight), - (randomByteVectorArrayElement, dropRightArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-53. DropRight function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, dropRight), - (randomUnionArrayElement, dropRightArgBeforeFunction), - (randomByteVectorArrayElement, invalidDropRight), - (randomByteVectorArrayElement, invalidDropRightArgBeforeFunc), - (randomByteVectorArrayElement, invalidDropRightNotInt) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Size.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Size.scala deleted file mode 100644 index e6717d440a7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Size.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.byteArray - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Size extends JsTestBase { - private val size = s"size(callerTestData)" - private val sizeArgBeforeFunction = s"callerTestData.size()" - private val invalidSize = s"size()" - private val invalidSizeArgBeforeFunc = s"callerTestData.size(callerTestData, callerTestData)" - - val tests: Tests = Tests { - test("RIDE-54. Size function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, size), - (randomByteVectorArrayElement, sizeArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-55. Size function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, size), - (randomUnionArrayElement, sizeArgBeforeFunction), - (randomByteVectorArrayElement, invalidSize), - (randomByteVectorArrayElement, invalidSizeArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Take.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Take.scala deleted file mode 100644 index 9ebecfa3302..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/Take.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.byteArray - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Take extends JsTestBase { - private val take = s"take(callerTestData, $randomInt)" - private val takeArgBeforeFunction = s"callerTestData.take($randomInt)" - private val invalidTake = s"take(callerTestData)" - private val invalidTakeArgBeforeFunc = s"callerTestData.take(callerTestData, $randomInt)" - private val invalidTakeNotInt = s"take(callerTestData, $randomByteVectorArrayElement)" - - val tests: Tests = Tests { - test("RIDE-56. Take function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, take), - (randomByteVectorArrayElement, takeArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-57. Take function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, take), - (randomUnionArrayElement, takeArgBeforeFunction), - (randomByteVectorArrayElement, invalidTake), - (randomByteVectorArrayElement, invalidTakeArgBeforeFunc), - (randomByteVectorArrayElement, invalidTakeNotInt) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/TakeRight.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/TakeRight.scala deleted file mode 100644 index 90cce3dc752..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/byteArray/TakeRight.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.byteArray - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object TakeRight extends JsTestBase { - private val takeRight = s"takeRight(callerTestData, $randomInt)" - private val takeRightArgBeforeFunction = s"callerTestData.takeRight($randomInt)" - private val invalidTakeRight = s"takeRight(callerTestData)" - private val invalidTakeRightArgBeforeFunc = s"callerTestData.takeRight(callerTestData, $randomInt)" - private val invalidTakeRightNotInt = s"takeRight(callerTestData, $randomByteVectorArrayElement)" - - val tests: Tests = Tests { - test("RIDE-58. TakeRight function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, takeRight), - (randomByteVectorArrayElement, takeRightArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-59. TakeRight function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, takeRight), - (randomUnionArrayElement, takeRightArgBeforeFunction), - (randomByteVectorArrayElement, invalidTakeRight), - (randomByteVectorArrayElement, invalidTakeRightArgBeforeFunc), - (randomByteVectorArrayElement, invalidTakeRightNotInt) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/AddressFromPublicKey.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/AddressFromPublicKey.scala deleted file mode 100644 index 34038f28eba..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/AddressFromPublicKey.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object AddressFromPublicKey extends JsTestBase { - private val addressFromPublicKey = s"addressFromPublicKey(callerTestData)" - private val addressFromPublicKeyArgBeforeFunction = s"callerTestData.addressFromPublicKey()" - private val invalidAddressFromPublicKey = s"addressFromPublicKey()" - private val invalidAddressFromPublicKeyArgBeforeFunc = s"callerTestData.addressFromPublicKey(callerTestData, callerTestData)" - private val invalidAddressFromPublicKeyData = s"addressFromPublicKey(callerTestData, $randomUnionArrayElement)" - - val tests: Tests = Tests { - test("RIDE-60. AddressFromPublicKey function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Address", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, addressFromPublicKey), - (randomByteVectorArrayElement, addressFromPublicKeyArgBeforeFunction) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-61. AddressFromPublicKey function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomAddressDataArrayElement, addressFromPublicKey, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, addressFromPublicKeyArgBeforeFunction, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidAddressFromPublicKey, invalidFunctionError("addressFromPublicKey", 1)), - (randomAddressDataArrayElement, invalidAddressFromPublicKeyArgBeforeFunc, invalidFunctionError("addressFromPublicKey", 1)), - (randomAddressDataArrayElement, invalidAddressFromPublicKeyData, invalidFunctionError("addressFromPublicKey", 1)) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseBigInt.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseBigInt.scala deleted file mode 100644 index 3dab78972fc..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseBigInt.scala +++ /dev/null @@ -1,118 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{UNDEFINED_TYPE, nonMatchingTypes, oldVersions, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ParseBigInt extends JsTestBase { - private val parseBigInt = "parseBigInt(callerTestData)" - private val parseBigIntArgBeforeFunc = "callerTestData.parseBigInt()" - private val invalidFunctionParseBigInt = "parseBigInt()" - private val invalidValueParseBigIntArgBeforeFunc = "callerTestData.parseBigInt(callerTestData, callerTestData)" - private val invalidFunctionErrorResultParseBigInt: String = testData.invalidFunctionError("parseBigInt", 1) - - private val parseBigIntValue = "parseBigIntValue(callerTestData)" - private val parseBigIntValueArgBeforeFunc = "callerTestData.parseBigIntValue()" - private val invalidFunctionParseBigIntValue = "parseBigIntValue()" - private val invalidValueParseBigIntValueArgBeforeFunc = "callerTestData.parseBigIntValue(callerTestData,callerTestData)" - - private val invalidFunctionErrorResultParseBigIntValue: String = testData.invalidFunctionError("parseBigIntValue", 1) - - val tests: Tests = Tests { - test("RIDE-62. ParseBigInt function should compile for valid values") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, parseBigInt), - (randomStringArrayElement, parseBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-63. ParseBigInt function throws an error for invalid values") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomStringArrayElement, parseBigInt, UNDEFINED_TYPE), - (randomStringArrayElement, parseBigIntArgBeforeFunc, UNDEFINED_TYPE), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-64. Function parseBigInt should throw an error for invalid functions") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, parseBigInt, nonMatchingTypes("String")), - (randomBoolean.toString, parseBigIntArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidFunctionParseBigInt, invalidFunctionErrorResultParseBigInt), - (randomStringArrayElement, invalidValueParseBigIntArgBeforeFunc, invalidFunctionErrorResultParseBigInt), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-65. ParseBigIntValue function should compile for valid values") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, parseBigIntValue), - (randomStringArrayElement, parseBigIntValueArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-66. ParseBigIntValue function throws an error for invalid values") { - for (version <- oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomStringArrayElement, parseBigIntValue, UNDEFINED_TYPE), - (randomStringArrayElement, parseBigIntValueArgBeforeFunc, UNDEFINED_TYPE), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-67. Function parseBigIntValue should throw an error for invalid functions") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, parseBigIntValue, nonMatchingTypes("String")), - (randomBoolean.toString, parseBigIntValueArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidFunctionParseBigIntValue, invalidFunctionErrorResultParseBigIntValue), - (randomStringArrayElement, invalidValueParseBigIntValueArgBeforeFunc, invalidFunctionErrorResultParseBigIntValue), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseInt.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseInt.scala deleted file mode 100644 index f2adab3e6a9..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ParseInt.scala +++ /dev/null @@ -1,87 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultIntegerEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object ParseInt extends JsTestBase { - // parseInt - private val parseInt = "parseInt(callerTestData)" - private val parseIntArgBeforeFunc = "callerTestData.parseInt()" - private val invalidParseInt = "parseInt()" - private val invalidParseIntArgBeforeFunc = "callerTestData.parseInt(callerTestData)" - - // parseIntValue - private val parseIntValue = "parseIntValue(callerTestData)" - private val parseIntValueArgBeforeFunc = "callerTestData.parseIntValue()" - private val invalidParseIntValue = "parseIntValue()" - private val invalidParseIntValueArgBeforeFunc = "callerTestData.parseIntValue(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-68. ParseInt function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, parseInt), - (randomStringArrayElement, parseIntArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-69. ParseInt function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, parseInt, nonMatchingTypes("String")), - (randomAliasDataArrayElement, parseIntArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidParseInt, invalidFunctionError("parseInt", 1)), - (randomStringArrayElement, invalidParseIntArgBeforeFunc, invalidFunctionError("parseInt", 1)) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-70. parseIntValue function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, parseIntValue), - (randomStringArrayElement, parseIntValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-71. parseIntValue function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, parseIntValue, nonMatchingTypes("String")), - (randomAliasDataArrayElement, parseIntValueArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidParseIntValue, invalidFunctionError("parseIntValue", 1)), - (randomStringArrayElement, invalidParseIntValueArgBeforeFunc, invalidFunctionError("parseIntValue", 1)) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBigInt.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBigInt.scala deleted file mode 100644 index e34f8042cef..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBigInt.scala +++ /dev/null @@ -1,58 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ToBigInt extends JsTestBase { - private val toBigInt = "toBigInt(callerTestData)" - private val toBigIntArgBeforeFunc = "callerTestData.toBigInt()" - private val toBigIntOnIndex = s"toBigInt(callerTestData, 1, $randomInt)" - private val toBigIntOnIndexArgBeforeFunc = s"callerTestData.toBigInt(9, $randomInt)" - private val invalidFunctionParseBigInt = "toBigInt()" - private val invalidParseBigIntArgBeforeFunc = s"callerTestData.toBigInt(callerTestData, 123, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-72. ToBigInt function should compile for valid values") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomInt.toString, toBigInt), - (randomByteVectorArrayElement, toBigInt), - (randomInt.toString, toBigIntArgBeforeFunc), - (randomByteVectorArrayElement, toBigIntArgBeforeFunc), - (randomByteVectorArrayElement, toBigIntOnIndex), - (randomByteVectorArrayElement, toBigIntOnIndexArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-73. ToBigInt function throws an error for invalid values") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function, error) <- Seq( - (randomBoolean.toString, toBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomUnionArrayElement, toBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomInt.toString, invalidFunctionParseBigInt, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomDigestAlgorithmTypeArrayElement, toBigIntOnIndex, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomBoolean.toString, toBigIntOnIndexArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomInt.toString, toBigIntOnIndexArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomByteVectorArrayElement, invalidFunctionParseBigInt, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomByteVectorArrayElement, invalidParseBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBytes.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBytes.scala deleted file mode 100644 index 0cd18362c34..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToBytes.scala +++ /dev/null @@ -1,68 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomBoolean, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ToBytes extends JsTestBase { - // toBytes - private val toBytes = "toBytes(callerTestData)" - private val toBytesArgBeforeFunc = "callerTestData.toBytes()" - private val invalidToBytes = "toBytes()" - private val invalidToBytesArgBeforeFunc = "callerTestData.toBytes(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-74. toBytes function should compile for valid values int, string, boolean") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, toBytes), - (randomInt.toString, toBytes), - (randomBoolean.toString, toBytes), - (randomStringArrayElement, toBytesArgBeforeFunc), - (randomInt.toString, toBytesArgBeforeFunc), - (randomBoolean.toString, toBytesArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-75. toBytes function should compile with bigInt for V5, V6 versions") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (s"toBigInt($randomInt)", toBytes), - (s"toBigInt($randomInt)", toBytesArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-76. toBytes function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomAddressDataArrayElement, toBytes, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomUnionArrayElement, toBytesArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomInt.toString, invalidToBytes, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomStringArrayElement, invalidToBytesArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToInt.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToInt.scala deleted file mode 100644 index 632112619f3..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToInt.scala +++ /dev/null @@ -1,75 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomInt, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ToInt extends JsTestBase { - private val toInt = "toInt(callerTestData)" - private val toIntArgBeforeFunc = "callerTestData.toInt()" - private val toIntOnIndex = s"toInt(callerTestData, $randomInt)" - private val toIntOnIndexArgBeforeFunc = s"callerTestData.toInt($randomInt)" - private val invalidFunctionParseInt = "toInt()" - private val invalidParseIntArgBeforeFunc = s"callerTestData.toInt(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-77. Functions toInt function should compile for valid ByteVector") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, toInt), - (randomByteVectorArrayElement, toIntOnIndex), - (randomByteVectorArrayElement, toIntArgBeforeFunc), - (randomByteVectorArrayElement, toIntOnIndexArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-78. ToInt function should compile with bigInt for V5, V6 versions") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (s"toBigInt($randomInt)", toInt), - (s"toBigInt($randomInt)", toIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-79. ToInt function throws an error for invalid values") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomDigestAlgorithmTypeArrayElement, toInt), - (randomStringArrayElement, toIntOnIndex), - (randomUnionArrayElement, toIntOnIndexArgBeforeFunc), - (randomInt.toString, toIntArgBeforeFunc), - (s"toBigInt($randomInt)", invalidFunctionParseInt), - (randomByteVectorArrayElement, invalidParseIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToString.scala deleted file mode 100644 index 1df311f3dd5..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToString.scala +++ /dev/null @@ -1,73 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomBoolean, - randomDigestAlgorithmTypeArrayElement, - randomInt, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ToString extends JsTestBase { - private val toStr = "toString(callerTestData)" - private val toStrArgBeforeFunc = "callerTestData.toString()" - private val invalidToStr = "toString()" - private val invalidToStrArgBeforeFunc = "callerTestData.toString(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-80. Functions toString function should compile with int, string, boolean") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, toStr), - (randomInt.toString, toStr), - (randomBoolean.toString, toStr), - (randomAddressDataArrayElement, toStrArgBeforeFunc), - (randomInt.toString, toStrArgBeforeFunc), - (randomBoolean.toString, toStrArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-81. Functions toString should compile with bigInt for V5, V6 versions") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, function) <- Seq( - (s"toBigInt($randomInt)", toStr), - (s"toBigInt($randomInt)", toStrArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-82. toString function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, toStr, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomDigestAlgorithmTypeArrayElement, toStrArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomInt.toString, invalidToStr, CANT_FIND_A_FUNCTION_OVERLOAD), - (randomAddressDataArrayElement, invalidToStrArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToUtf8String.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToUtf8String.scala deleted file mode 100644 index 6f3c196bdff..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/ToUtf8String.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultStringEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object ToUtf8String extends JsTestBase { - private val toUtf8String = "toUtf8String(callerTestData)" - private val toUtf8StringArgBeforeFunc = "callerTestData.toUtf8String()" - private val invalidToUtf8String = "toUtf8String()" - private val invalidToUtf8StringArgBeforeFunc = "callerTestData.toUtf8String(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-83. Functions toUtf8String function should compile for valid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ((data, function) <- Seq( - (randomByteVectorArrayElement, toUtf8String), - (randomByteVectorArrayElement, toUtf8StringArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-84. toUtf8String function throws an error for invalid values") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ((data, function, error) <- Seq( - (randomUnionArrayElement, toUtf8String, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, toUtf8StringArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidToUtf8String, invalidFunctionError("toUtf8String", 1)), - (randomByteVectorArrayElement, invalidToUtf8StringArgBeforeFunc, invalidFunctionError("toUtf8String", 1)) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} \ No newline at end of file diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/TransferTransactionFromProto.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/TransferTransactionFromProto.scala deleted file mode 100644 index b800d9b2306..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/converting/TransferTransactionFromProto.scala +++ /dev/null @@ -1,66 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.converting - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object TransferTransactionFromProto extends JsTestBase { - private val transferTransactionFromProto = "transferTransactionFromProto(callerTestData)" - private val transferTransactionFromProtoArgBeforeFunc = "callerTestData.transferTransactionFromProto()" - private val invalidTransferTransactionFromProto = "transferTransactionFromProto()" - private val invalidTransferTransactionFromProtoArgBeforeFunction = "transferTransactionFromProto()" - - val tests: Tests = Tests { - test("RIDE-85. transferTransactionFromProto function should compile for Issue V4 and more") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("TransferTransaction", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, transferTransactionFromProto), - (randomByteVectorArrayElement, transferTransactionFromProtoArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-86. transferTransactionFromProto function throws an error for invalid values for V4 and more") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("TransferTransaction", version) - for ( - (data, function, error) <- Seq( - (randomDigestAlgorithmTypeArrayElement, transferTransactionFromProto, nonMatchingTypes("ByteVector")), - (randomDigestAlgorithmTypeArrayElement, transferTransactionFromProtoArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidTransferTransactionFromProto, invalidFunctionError("transferTransactionFromProto", 1)), - ( - randomByteVectorArrayElement, - invalidTransferTransactionFromProtoArgBeforeFunction, - invalidFunctionError("transferTransactionFromProto", 1) - ) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-87. transferTransactionFromProto function should throw a compilation error for Ride V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("TransferTransaction", V3) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, transferTransactionFromProto), - (randomByteVectorArrayElement, transferTransactionFromProtoArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/Invoke.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/Invoke.scala deleted file mode 100644 index 97a40182221..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/Invoke.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dappToDappInvocation - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object Invoke extends JsTestBase { - private val invoke = "invoke(addressFromStringValue(dapp2),\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val invokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val invalidInvokeFunction = "invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val invalidInvokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke([AttachedPayment(byteVector, payment)])" - private val invalidFunctionErrorResult: String = invalidFunctionError("invoke", 4) - - val tests: Tests = Tests { - test("RIDE-88. Invoke function should compile for Issue RIDE V5 and more") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (byteVector, data, function) <- Seq( - (randomByteVectorArrayElement, randomInt.toString, invoke), - (randomByteVectorArrayElement, randomInt.toString, invokeArgBeforeFunc) - ) - ) { - val script = precondition.codeForDAppInvocation(byteVector, data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-89. Invoke function throws an error for invalid values for RIDE V5 and more") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (byteVector, data, function, error) <- Seq( - (randomByteVectorArrayElement, randomAddressDataArrayElement, invoke, nonMatchingTypes("Int")), - (randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, invokeArgBeforeFunc, nonMatchingTypes("Int")), - (randomStringArrayElement, randomInt.toString, invoke, nonMatchingTypes("ByteVector|Unit")), - (randomStringArrayElement, randomInt.toString, invokeArgBeforeFunc, nonMatchingTypes("ByteVector|Unit")), - (randomByteVectorArrayElement, randomInt.toString, invalidInvokeFunction, invalidFunctionErrorResult), - (randomByteVectorArrayElement, randomInt.toString, invalidInvokeArgBeforeFunc, invalidFunctionErrorResult) - ) - ) { - val script = precondition.codeForDAppInvocation(byteVector, data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/ReentrantInvoke.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/ReentrantInvoke.scala deleted file mode 100644 index b45c83af313..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dappToDappInvocation/ReentrantInvoke.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dappToDappInvocation - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{nonMatchingTypes, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object ReentrantInvoke extends JsTestBase { - private val reentrantInvoke = "reentrantInvoke(addressFromStringValue(dapp2),\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val reentrantInvokeArgBeforeFunc = "addressFromStringValue(dapp2).reentrantInvoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val invalidReentrantInvokeFunction = "reentrantInvoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" - private val invalidReentrantInvokeArgBeforeFunc = "addressFromStringValue(dapp2).reentrantInvoke([AttachedPayment(byteVector, payment)])" - private val invalidFunctionErrorResult: String = testData.invalidFunctionError("reentrantInvoke", 4) - - val tests: Tests = Tests { - test("RIDE-90. ReentrantInvoke function should compile for Issue RIDE V5 and more") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (byteVector, data, function) <- Seq( - (randomByteVectorArrayElement, randomInt.toString, reentrantInvoke), - (randomByteVectorArrayElement, randomInt.toString, reentrantInvokeArgBeforeFunc) - ) - ) { - val script = precondition.codeForDAppInvocation(byteVector, data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-91. ReentrantInvoke function throws an error for invalid values for RIDE V5 and more") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (byteVector, data, function, error) <- Seq( - (randomByteVectorArrayElement, randomAddressDataArrayElement, reentrantInvoke, nonMatchingTypes("Int")), - (randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, reentrantInvokeArgBeforeFunc, nonMatchingTypes("Int")), - (randomStringArrayElement, randomInt.toString, reentrantInvoke, nonMatchingTypes("ByteVector|Unit")), - (randomStringArrayElement, randomInt.toString, reentrantInvokeArgBeforeFunc, nonMatchingTypes("ByteVector|Unit")), - (randomByteVectorArrayElement, randomInt.toString, invalidReentrantInvokeFunction, invalidFunctionErrorResult), - (randomByteVectorArrayElement, randomInt.toString, invalidReentrantInvokeArgBeforeFunc, invalidFunctionErrorResult) - ) - ) { - val script = precondition.codeForDAppInvocation(byteVector, data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBinary.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBinary.scala deleted file mode 100644 index 19db5d5331d..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBinary.scala +++ /dev/null @@ -1,168 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dataTransaction - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.* -import utest.{Tests, test} - -object GetBinary extends JsTestBase { - // getBinaryKey - private val getBinaryKey = s"getBinary(callerTestData, \"key\")" - private val getBinaryKeyArgBeforeFunc = s"callerTestData.getBinary(\"key\")" - // getBinaryIndex - private val getBinaryIndex = s"getBinary(callerTestData, $randomInt)" - private val getBinaryIndexArgBeforeFunc = s"callerTestData.getBinary($randomInt)" - // getBinaryValueKey - private val getBinaryValueKey = s"getBinaryValue(callerTestData, \"key\")" - private val getBinaryValueKeyArgBeforeFunc = s"callerTestData.getBinaryValue(\"key\")" - // getBinaryValueIndex - private val getBinaryValueIndex = s"getBinaryValue(callerTestData, $randomInt)" - private val getBinaryValueIndexArgBeforeFunc = s"callerTestData.getBinaryValue($randomInt)" - - // invalid getBinary - private val invalidGetBinaryKey = s"getBinary()" - private val invalidGetBinaryArgBeforeFunc = s"callerTestData.getBinary()" - // invalid getBinaryValue - private val invalidGetBinaryValue = s"getBinaryValue()" - private val invalidGetBinaryValueArgBeforeFunc = s"callerTestData.getBinaryValue()" - - val tests: Tests = Tests { - test("RIDE-92. getBinary functions for dataTransaction should compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, binary) <- Seq( - (binaryEntryForTests, getBinaryKey), - (integerEntryForTests, getBinaryKey), - (stringEntryForTests, getBinaryKey), - (booleanEntryForTests, getBinaryKey), - (binaryEntryForTests, getBinaryKeyArgBeforeFunc), - (integerEntryForTests, getBinaryKeyArgBeforeFunc), - (stringEntryForTests, getBinaryKeyArgBeforeFunc), - (booleanEntryForTests, getBinaryKeyArgBeforeFunc), - (binaryEntryForTests, getBinaryIndex), - (integerEntryForTests, getBinaryIndex), - (stringEntryForTests, getBinaryIndex), - (booleanEntryForTests, getBinaryIndex), - (binaryEntryForTests, getBinaryIndexArgBeforeFunc), - (integerEntryForTests, getBinaryIndexArgBeforeFunc), - (stringEntryForTests, getBinaryIndexArgBeforeFunc), - (booleanEntryForTests, getBinaryIndexArgBeforeFunc), - (binaryEntryForTests, getBinaryValueKey), - (integerEntryForTests, getBinaryValueKey), - (stringEntryForTests, getBinaryValueKey), - (booleanEntryForTests, getBinaryValueKey), - (binaryEntryForTests, getBinaryValueKeyArgBeforeFunc), - (integerEntryForTests, getBinaryValueKeyArgBeforeFunc), - (stringEntryForTests, getBinaryValueKeyArgBeforeFunc), - (booleanEntryForTests, getBinaryValueKeyArgBeforeFunc), - (binaryEntryForTests, getBinaryValueIndex), - (integerEntryForTests, getBinaryValueIndex), - (stringEntryForTests, getBinaryValueIndex), - (booleanEntryForTests, getBinaryValueIndex), - (binaryEntryForTests, getBinaryValueIndexArgBeforeFunc), - (integerEntryForTests, getBinaryValueIndexArgBeforeFunc), - (stringEntryForTests, getBinaryValueIndexArgBeforeFunc), - (booleanEntryForTests, getBinaryValueIndexArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-93. getBinary function for dataTransaction should compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), getBinaryKey), - (dataEntryForTests(randomStringArrayElement), getBinaryKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBinaryIndex), - (dataEntryForTests(randomStringArrayElement), getBinaryIndexArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBinaryValueKey), - (dataEntryForTests(randomStringArrayElement), getBinaryValueKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBinaryValueIndex), - (dataEntryForTests(randomStringArrayElement), getBinaryValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-94. getBinary function should throw an error for invalid data type for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, binary) <- Seq( - (randomInt.toString, getBinaryKey), - (randomBoolean.toString, getBinaryKeyArgBeforeFunc), - (randomInt.toString, getBinaryIndex), - (randomBoolean.toString, getBinaryIndexArgBeforeFunc), - (randomInt.toString, getBinaryValueKey), - (randomBoolean.toString, getBinaryValueKeyArgBeforeFunc), - (randomInt.toString, getBinaryValueIndex), - (randomBoolean.toString, getBinaryValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-95. getBinary function should throw an error for invalid data type for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - for ( - (data, binary) <- Seq( - (randomInt.toString, getBinaryKey), - (randomBoolean.toString, getBinaryKeyArgBeforeFunc), - (randomInt.toString, getBinaryIndex), - (randomBoolean.toString, getBinaryIndexArgBeforeFunc), - (randomInt.toString, getBinaryValueKey), - (randomBoolean.toString, getBinaryValueKeyArgBeforeFunc), - (randomInt.toString, getBinaryValueIndex), - (randomBoolean.toString, getBinaryValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - - test("RIDE-96. Invalid getBinary functions should not compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, binary) <- Seq( - (integerEntryForTests, invalidGetBinaryKey), - (binaryEntryForTests, invalidGetBinaryArgBeforeFunc), - (integerEntryForTests, invalidGetBinaryValue), - (binaryEntryForTests, invalidGetBinaryValueArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-97. Invalid getBinary functions should not compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), invalidGetBinaryKey), - (dataEntryForTests(randomStringArrayElement), invalidGetBinaryArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), invalidGetBinaryValue), - (dataEntryForTests(randomStringArrayElement), invalidGetBinaryValueArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBoolean.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBoolean.scala deleted file mode 100644 index 22c6fd07fb7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetBoolean.scala +++ /dev/null @@ -1,168 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dataTransaction - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBooleanEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests} -import utest.{Tests, test} - -object GetBoolean extends JsTestBase { - // getBooleanKey - private val getBooleanKey = s"getBoolean(callerTestData, \"key\")" - private val getBooleanKeyArgBeforeFunc = s"callerTestData.getBoolean(\"key\")" - // getBooleanIndex - private val getBooleanIndex = s"getBoolean(callerTestData, $randomInt)" - private val getBooleanIndexArgBeforeFunc = s"callerTestData.getBoolean($randomInt)" - // getBooleanValueKey - private val getBooleanValueKey = s"getBooleanValue(callerTestData, \"key\")" - private val getBooleanValueKeyArgBeforeFunc = s"callerTestData.getBooleanValue(\"key\")" - // getBooleanValueIndex - private val getBooleanValueIndex = s"getBooleanValue(callerTestData, $randomInt)" - private val getBooleanValueIndexArgBeforeFunc = s"callerTestData.getBooleanValue($randomInt)" - - // invalid getBoolean - private val invalidGetBooleanKey = s"getBoolean()" - private val invalidGetBooleanArgBeforeFunc = s"callerTestData.getBoolean()" - // invalid getBooleanValue - private val invalidGetBooleanValue = s"getBooleanValue()" - private val invalidGetBooleanValueArgBeforeFunc = s"callerTestData.getBooleanValue()" - - val tests: Tests = Tests { - test("RIDE-98. getBoolean functions for dataTransaction should compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, binary) <- Seq( - (binaryEntryForTests, getBooleanKey), - (integerEntryForTests, getBooleanKey), - (stringEntryForTests, getBooleanKey), - (booleanEntryForTests, getBooleanKey), - (binaryEntryForTests, getBooleanKeyArgBeforeFunc), - (integerEntryForTests, getBooleanKeyArgBeforeFunc), - (stringEntryForTests, getBooleanKeyArgBeforeFunc), - (booleanEntryForTests, getBooleanKeyArgBeforeFunc), - (binaryEntryForTests, getBooleanIndex), - (integerEntryForTests, getBooleanIndex), - (stringEntryForTests, getBooleanIndex), - (booleanEntryForTests, getBooleanIndex), - (binaryEntryForTests, getBooleanIndexArgBeforeFunc), - (integerEntryForTests, getBooleanIndexArgBeforeFunc), - (stringEntryForTests, getBooleanIndexArgBeforeFunc), - (booleanEntryForTests, getBooleanIndexArgBeforeFunc), - (binaryEntryForTests, getBooleanValueKey), - (integerEntryForTests, getBooleanValueKey), - (stringEntryForTests, getBooleanValueKey), - (booleanEntryForTests, getBooleanValueKey), - (binaryEntryForTests, getBooleanValueKeyArgBeforeFunc), - (integerEntryForTests, getBooleanValueKeyArgBeforeFunc), - (stringEntryForTests, getBooleanValueKeyArgBeforeFunc), - (booleanEntryForTests, getBooleanValueKeyArgBeforeFunc), - (binaryEntryForTests, getBooleanValueIndex), - (integerEntryForTests, getBooleanValueIndex), - (stringEntryForTests, getBooleanValueIndex), - (booleanEntryForTests, getBooleanValueIndex), - (binaryEntryForTests, getBooleanValueIndexArgBeforeFunc), - (integerEntryForTests, getBooleanValueIndexArgBeforeFunc), - (stringEntryForTests, getBooleanValueIndexArgBeforeFunc), - (booleanEntryForTests, getBooleanValueIndexArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-99. getBoolean function for dataTransaction should compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), getBooleanKey), - (dataEntryForTests(randomStringArrayElement), getBooleanKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBooleanIndex), - (dataEntryForTests(randomStringArrayElement), getBooleanIndexArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBooleanValueKey), - (dataEntryForTests(randomStringArrayElement), getBooleanValueKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getBooleanValueIndex), - (dataEntryForTests(randomStringArrayElement), getBooleanValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-100. getBoolean function should throw an error for invalid data type for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, binary) <- Seq( - (randomInt.toString, getBooleanKey), - (randomBoolean.toString, getBooleanKeyArgBeforeFunc), - (randomInt.toString, getBooleanIndex), - (randomBoolean.toString, getBooleanIndexArgBeforeFunc), - (randomInt.toString, getBooleanValueKey), - (randomBoolean.toString, getBooleanValueKeyArgBeforeFunc), - (randomInt.toString, getBooleanValueIndex), - (randomBoolean.toString, getBooleanValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-101. getBoolean function should throw an error for invalid data type for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - for ( - (data, binary) <- Seq( - (randomInt.toString, getBooleanKey), - (randomBoolean.toString, getBooleanKeyArgBeforeFunc), - (randomInt.toString, getBooleanIndex), - (randomBoolean.toString, getBooleanIndexArgBeforeFunc), - (randomInt.toString, getBooleanValueKey), - (randomBoolean.toString, getBooleanValueKeyArgBeforeFunc), - (randomInt.toString, getBooleanValueIndex), - (randomBoolean.toString, getBooleanValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - - test("RIDE-102. Invalid getBoolean functions should not compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, binary) <- Seq( - (integerEntryForTests, invalidGetBooleanKey), - (binaryEntryForTests, invalidGetBooleanArgBeforeFunc), - (integerEntryForTests, invalidGetBooleanValue), - (binaryEntryForTests, invalidGetBooleanValueArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-103. Invalid getBoolean functions should not compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), invalidGetBooleanKey), - (dataEntryForTests(randomStringArrayElement), invalidGetBooleanArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), invalidGetBooleanValue), - (dataEntryForTests(randomStringArrayElement), invalidGetBooleanValueArgBeforeFunc), - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetInteger.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetInteger.scala deleted file mode 100644 index d919d93d4c7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetInteger.scala +++ /dev/null @@ -1,177 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dataTransaction - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{ - CANT_FIND_A_FUNCTION_OVERLOAD, - GreaterV3ResultIntegerEntry, - actualVersionsWithoutV3, - binaryEntryForTests, - booleanEntryForTests, - integerEntryForTests, - rideV3Result, - stringEntryForTests -} -import utest.{Tests, test} - -object GetInteger extends JsTestBase { - // getIntegerKey - private val getIntegerKey = s"getInteger(callerTestData, \"key\")" - private val getIntegerKeyArgBeforeFunc = s"callerTestData.getInteger(\"key\")" - // getIntegerIndex - private val getIntegerIndex = s"getInteger(callerTestData, $randomInt)" - private val getIntegerIndexArgBeforeFunc = s"callerTestData.getInteger($randomInt)" - // getIntegerValueKey - private val getIntegerValueKey = s"getIntegerValue(callerTestData, \"key\")" - private val getIntegerValueKeyArgBeforeFunc = s"callerTestData.getIntegerValue(\"key\")" - // getIntegerValueIndex - private val getIntegerValueIndex = s"getIntegerValue(callerTestData, $randomInt)" - private val getIntegerValueIndexArgBeforeFunc = s"callerTestData.getIntegerValue($randomInt)" - - // invalid getInteger - private val invalidGetIntegerKey = s"getInteger()" - private val invalidGetIntegerArgBeforeFunc = s"callerTestData.getInteger()" - // invalid getIntegerValue - private val invalidGetIntegerValue = s"getIntegerValue()" - private val invalidGetIntegerValueArgBeforeFunc = s"callerTestData.getIntegerValue()" - - val tests: Tests = Tests { - test("RIDE-104. getInteger functions for dataTransaction should compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, binary) <- Seq( - (binaryEntryForTests, getIntegerKey), - (integerEntryForTests, getIntegerKey), - (stringEntryForTests, getIntegerKey), - (booleanEntryForTests, getIntegerKey), - (binaryEntryForTests, getIntegerKeyArgBeforeFunc), - (integerEntryForTests, getIntegerKeyArgBeforeFunc), - (stringEntryForTests, getIntegerKeyArgBeforeFunc), - (booleanEntryForTests, getIntegerKeyArgBeforeFunc), - (binaryEntryForTests, getIntegerIndex), - (integerEntryForTests, getIntegerIndex), - (stringEntryForTests, getIntegerIndex), - (booleanEntryForTests, getIntegerIndex), - (binaryEntryForTests, getIntegerIndexArgBeforeFunc), - (integerEntryForTests, getIntegerIndexArgBeforeFunc), - (stringEntryForTests, getIntegerIndexArgBeforeFunc), - (booleanEntryForTests, getIntegerIndexArgBeforeFunc), - (binaryEntryForTests, getIntegerValueKey), - (integerEntryForTests, getIntegerValueKey), - (stringEntryForTests, getIntegerValueKey), - (booleanEntryForTests, getIntegerValueKey), - (binaryEntryForTests, getIntegerValueKeyArgBeforeFunc), - (integerEntryForTests, getIntegerValueKeyArgBeforeFunc), - (stringEntryForTests, getIntegerValueKeyArgBeforeFunc), - (booleanEntryForTests, getIntegerValueKeyArgBeforeFunc), - (binaryEntryForTests, getIntegerValueIndex), - (integerEntryForTests, getIntegerValueIndex), - (stringEntryForTests, getIntegerValueIndex), - (booleanEntryForTests, getIntegerValueIndex), - (binaryEntryForTests, getIntegerValueIndexArgBeforeFunc), - (integerEntryForTests, getIntegerValueIndexArgBeforeFunc), - (stringEntryForTests, getIntegerValueIndexArgBeforeFunc), - (booleanEntryForTests, getIntegerValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-105. getInteger function for dataTransaction should compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), getIntegerKey), - (dataEntryForTests(randomStringArrayElement), getIntegerKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getIntegerIndex), - (dataEntryForTests(randomStringArrayElement), getIntegerIndexArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getIntegerValueKey), - (dataEntryForTests(randomStringArrayElement), getIntegerValueKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getIntegerValueIndex), - (dataEntryForTests(randomStringArrayElement), getIntegerValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-106. getInteger function should throw an error for invalid data type for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, binary) <- Seq( - (randomInt.toString, getIntegerKey), - (randomBoolean.toString, getIntegerKeyArgBeforeFunc), - (randomInt.toString, getIntegerIndex), - (randomBoolean.toString, getIntegerIndexArgBeforeFunc), - (randomInt.toString, getIntegerValueKey), - (randomBoolean.toString, getIntegerValueKeyArgBeforeFunc), - (randomInt.toString, getIntegerValueIndex), - (randomBoolean.toString, getIntegerValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-107. getInteger function should throw an error for invalid data type for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, binary) <- Seq( - (randomInt.toString, getIntegerKey), - (randomBoolean.toString, getIntegerKeyArgBeforeFunc), - (randomInt.toString, getIntegerIndex), - (randomBoolean.toString, getIntegerIndexArgBeforeFunc), - (randomInt.toString, getIntegerValueKey), - (randomBoolean.toString, getIntegerValueKeyArgBeforeFunc), - (randomInt.toString, getIntegerValueIndex), - (randomBoolean.toString, getIntegerValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - - test("RIDE-108. Invalid getInteger functions should not compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, binary) <- Seq( - (integerEntryForTests, invalidGetIntegerKey), - (binaryEntryForTests, invalidGetIntegerArgBeforeFunc), - (integerEntryForTests, invalidGetIntegerValue), - (binaryEntryForTests, invalidGetIntegerValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-109. Invalid getInteger functions should not compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), invalidGetIntegerKey), - (dataEntryForTests(randomStringArrayElement), invalidGetIntegerArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), invalidGetIntegerValue), - (dataEntryForTests(randomStringArrayElement), invalidGetIntegerValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetString.scala deleted file mode 100644 index f1167868ac5..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/dataTransaction/GetString.scala +++ /dev/null @@ -1,168 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.dataTransaction - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests} -import utest.{Tests, test} - -object GetString extends JsTestBase { - // getStringKey - private val getStringKey = s"getString(callerTestData, \"key\")" - private val getStringKeyArgBeforeFunc = s"callerTestData.getString(\"key\")" - // getStringIndex - private val getStringIndex = s"getString(callerTestData, $randomInt)" - private val getStringIndexArgBeforeFunc = s"callerTestData.getString($randomInt)" - // getStringValueKey - private val getStringValueKey = s"getStringValue(callerTestData, \"key\")" - private val getStringValueKeyArgBeforeFunc = s"callerTestData.getStringValue(\"key\")" - // getStringValueIndex - private val getStringValueIndex = s"getStringValue(callerTestData, $randomInt)" - private val getStringValueIndexArgBeforeFunc = s"callerTestData.getStringValue($randomInt)" - - // invalid getString - private val invalidGetStringKey = s"getString()" - private val invalidGetStringArgBeforeFunc = s"callerTestData.getString()" - // invalid getStringValue - private val invalidGetStringValue = s"getStringValue()" - private val invalidGetStringValueArgBeforeFunc = s"callerTestData.getStringValue()" - - val tests: Tests = Tests { - test("RIDE-110. getString functions for dataTransaction should compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, binary) <- Seq( - (binaryEntryForTests, getStringKey), - (integerEntryForTests, getStringKey), - (stringEntryForTests, getStringKey), - (booleanEntryForTests, getStringKey), - (binaryEntryForTests, getStringKeyArgBeforeFunc), - (integerEntryForTests, getStringKeyArgBeforeFunc), - (stringEntryForTests, getStringKeyArgBeforeFunc), - (booleanEntryForTests, getStringKeyArgBeforeFunc), - (binaryEntryForTests, getStringIndex), - (integerEntryForTests, getStringIndex), - (stringEntryForTests, getStringIndex), - (booleanEntryForTests, getStringIndex), - (binaryEntryForTests, getStringIndexArgBeforeFunc), - (integerEntryForTests, getStringIndexArgBeforeFunc), - (stringEntryForTests, getStringIndexArgBeforeFunc), - (booleanEntryForTests, getStringIndexArgBeforeFunc), - (binaryEntryForTests, getStringValueKey), - (integerEntryForTests, getStringValueKey), - (stringEntryForTests, getStringValueKey), - (booleanEntryForTests, getStringValueKey), - (binaryEntryForTests, getStringValueKeyArgBeforeFunc), - (integerEntryForTests, getStringValueKeyArgBeforeFunc), - (stringEntryForTests, getStringValueKeyArgBeforeFunc), - (booleanEntryForTests, getStringValueKeyArgBeforeFunc), - (binaryEntryForTests, getStringValueIndex), - (integerEntryForTests, getStringValueIndex), - (stringEntryForTests, getStringValueIndex), - (booleanEntryForTests, getStringValueIndex), - (binaryEntryForTests, getStringValueIndexArgBeforeFunc), - (integerEntryForTests, getStringValueIndexArgBeforeFunc), - (stringEntryForTests, getStringValueIndexArgBeforeFunc), - (booleanEntryForTests, getStringValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-111. getString function for dataTransaction should compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), getStringKey), - (dataEntryForTests(randomStringArrayElement), getStringKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getStringIndex), - (dataEntryForTests(randomStringArrayElement), getStringIndexArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getStringValueKey), - (dataEntryForTests(randomStringArrayElement), getStringValueKeyArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), getStringValueIndex), - (dataEntryForTests(randomStringArrayElement), getStringValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-112. getString function should throw an error for invalid data type for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, binary) <- Seq( - (randomInt.toString, getStringKey), - (randomBoolean.toString, getStringKeyArgBeforeFunc), - (randomInt.toString, getStringIndex), - (randomBoolean.toString, getStringIndexArgBeforeFunc), - (randomInt.toString, getStringValueKey), - (randomBoolean.toString, getStringValueKeyArgBeforeFunc), - (randomInt.toString, getStringValueIndex), - (randomBoolean.toString, getStringValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-113. getString function should throw an error for invalid data type for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V3) - for ( - (data, binary) <- Seq( - (randomInt.toString, getStringKey), - (randomBoolean.toString, getStringKeyArgBeforeFunc), - (randomInt.toString, getStringIndex), - (randomBoolean.toString, getStringIndexArgBeforeFunc), - (randomInt.toString, getStringValueKey), - (randomBoolean.toString, getStringValueKeyArgBeforeFunc), - (randomInt.toString, getStringValueIndex), - (randomBoolean.toString, getStringValueIndexArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - - test("RIDE-114. Invalid getString functions should not compile for versions V4 and above") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, binary) <- Seq( - (integerEntryForTests, invalidGetStringKey), - (binaryEntryForTests, invalidGetStringArgBeforeFunc), - (integerEntryForTests, invalidGetStringValue), - (binaryEntryForTests, invalidGetStringValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - - test("RIDE-115. Invalid getString functions should not compile for V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V3) - for ( - (data, binary) <- Seq( - (dataEntryForTests(randomStringArrayElement), invalidGetStringKey), - (dataEntryForTests(randomStringArrayElement), invalidGetStringArgBeforeFunc), - (dataEntryForTests(randomStringArrayElement), invalidGetStringValue), - (dataEntryForTests(randomStringArrayElement), invalidGetStringValueArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/AddressFromString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/AddressFromString.scala deleted file mode 100644 index 0eb37fc3d9b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/AddressFromString.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.decoding - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomBoolean, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object AddressFromString extends JsTestBase { - private val addressFromString = "addressFromString(callerTestData)" - private val addressFromStringArgBeforeFunc = "callerTestData.addressFromString()" - private val addressFromStringValue = "addressFromStringValue(callerTestData)" - private val addressFromStringValueArgBeforeFunc = "callerTestData.addressFromStringValue()" - private val invalidAddressFromString = "addressFromString()" - private val invalidAddressFromStringValue = "addressFromStringValue()" - private val invalidFunctionErrorForAddressFromString = invalidFunctionError("addressFromString", 1) - private val invalidFunctionErrorForAddressFromStringValue = invalidFunctionError("addressFromStringValue", 1) - - val tests: Tests = Tests { - test("RIDE-116. Function addressFromString should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Address", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, addressFromString), - (randomStringArrayElement, addressFromStringArgBeforeFunc), - (randomStringArrayElement, addressFromStringValue), - (randomStringArrayElement, addressFromStringValueArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-117. Function addressFromString should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Address", version) - for ( - (data, function, error) <- Seq( - (randomAliasDataArrayElement, addressFromString, nonMatchingTypes("String")), - (randomAliasDataArrayElement, addressFromStringArgBeforeFunc, nonMatchingTypes("String")), - (randomBoolean.toString, addressFromStringValue, nonMatchingTypes("String")), - (randomUnionArrayElement, addressFromStringValueArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidAddressFromString, invalidFunctionErrorForAddressFromString), - (randomStringArrayElement, invalidAddressFromStringValue, invalidFunctionErrorForAddressFromStringValue) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/FromBaseString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/FromBaseString.scala deleted file mode 100644 index 58e5a59db4c..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/decoding/FromBaseString.scala +++ /dev/null @@ -1,79 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.decoding - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAliasDataArrayElement, - randomBoolean, - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object FromBaseString extends JsTestBase { - private val fromBase16String = "fromBase16String(callerTestData)" - private val fromBase16StringArgBeforeFunc = "callerTestData.fromBase16String()" - private val fromBase58String = "fromBase58String(callerTestData)" - private val fromBase58StringArgBeforeFunc = "callerTestData.fromBase58String()" - private val fromBase64String = "fromBase64String(callerTestData)" - private val fromBase64StringArgBeforeFunc = "callerTestData.fromBase64String()" - private val invalidFromBase16String = "fromBase16String()" - private val invalidFromBase58String = "fromBase58String()" - private val invalidFromBase64String = "fromBase64String()" - private val invalidFromBase16StringArgBeforeFunction = "callerTestData.fromBase16String(callerTestData)" - private val invalidFromBase58StringArgBeforeFunction = "callerTestData.fromBase58String(callerTestData)" - private val invalidFromBase64StringArgBeforeFunction = "callerTestData.fromBase64String(callerTestData)" - private val invalidErrorForFromBase16String = invalidFunctionError("fromBase16String", 1) - private val invalidErrorForFromBase58String = invalidFunctionError("fromBase58String", 1) - private val invalidErrorForFromBase64String = invalidFunctionError("fromBase64String", 1) - - val tests: Tests = Tests { - test("RIDE-118. Function fromBaseString should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, fromBase16String), - (randomStringArrayElement, fromBase16StringArgBeforeFunc), - (randomStringArrayElement, fromBase58String), - (randomStringArrayElement, fromBase58StringArgBeforeFunc), - (randomStringArrayElement, fromBase64String), - (randomStringArrayElement, fromBase64StringArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - // invalid data - test("RIDE-119. Function fromBaseString should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomBoolean.toString, fromBase16String, nonMatchingTypes("String")), - (randomAliasDataArrayElement, fromBase16StringArgBeforeFunc, nonMatchingTypes("String")), - (randomByteVectorArrayElement, fromBase58String, nonMatchingTypes("String")), - (randomDigestAlgorithmTypeArrayElement, fromBase58StringArgBeforeFunc, nonMatchingTypes("String")), - (randomByteVectorArrayElement, fromBase64String, nonMatchingTypes("String")), - (randomUnionArrayElement, fromBase64StringArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, invalidFromBase16String, invalidErrorForFromBase16String), - (randomStringArrayElement, invalidFromBase58String, invalidErrorForFromBase58String), - (randomStringArrayElement, invalidFromBase64String, invalidErrorForFromBase64String), - (randomStringArrayElement, invalidFromBase16StringArgBeforeFunction, invalidErrorForFromBase16String), - (randomStringArrayElement, invalidFromBase58StringArgBeforeFunction, invalidErrorForFromBase58String), - (randomStringArrayElement, invalidFromBase64StringArgBeforeFunction, invalidErrorForFromBase64String) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/encoding/ToBaseString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/encoding/ToBaseString.scala deleted file mode 100644 index 1ca2701e767..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/encoding/ToBaseString.scala +++ /dev/null @@ -1,79 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.encoding - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAliasDataArrayElement, - randomBoolean, - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomInt, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, nonMatchingTypes} -import utest.{Tests, test} - -object ToBaseString extends JsTestBase { - private val toBase16String = "toBase16String(callerTestData)" - private val toBase16StringArgBeforeFunc = "callerTestData.toBase16String()" - private val toBase58String = "toBase58String(callerTestData)" - private val toBase58StringArgBeforeFunc = "callerTestData.toBase58String()" - private val toBase64String = "toBase64String(callerTestData)" - private val toBase64StringArgBeforeFunc = "callerTestData.toBase64String()" - private val invalidToBase16String = "toBase16String()" - private val invalidToBase58String = "toBase58String()" - private val invalidToBase64String = "toBase64String()" - private val invalidToBase16StringArgBeforeFunction = "callerTestData.toBase16String(callerTestData)" - private val invalidToBase58StringArgBeforeFunction = "callerTestData.toBase58String(callerTestData)" - private val invalidToBase64StringArgBeforeFunction = "callerTestData.toBase64String(callerTestData)" - private val invalidErrorForToBase16String = testData.invalidFunctionError("toBase16String", 1) - private val invalidErrorForToBase58String = testData.invalidFunctionError("toBase58String", 1) - private val invalidErrorForToBase64String = testData.invalidFunctionError("toBase64String", 1) - - val tests: Tests = Tests { - test("RIDE-120. Function toBaseString should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, toBase16String), - (randomByteVectorArrayElement, toBase16StringArgBeforeFunc), - (randomByteVectorArrayElement, toBase58String), - (randomByteVectorArrayElement, toBase58StringArgBeforeFunc), - (randomByteVectorArrayElement, toBase64String), - (randomByteVectorArrayElement, toBase64StringArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-121. Function toBaseString should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, function, error) <- Seq( - (randomBoolean.toString, toBase16String, nonMatchingTypes("ByteVector")), - (randomAliasDataArrayElement, toBase16StringArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomStringArrayElement, toBase58String, nonMatchingTypes("ByteVector")), - (randomDigestAlgorithmTypeArrayElement, toBase58StringArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomInt.toString, toBase64String, nonMatchingTypes("ByteVector")), - (randomUnionArrayElement, toBase64StringArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidToBase16String, invalidErrorForToBase16String), - (randomByteVectorArrayElement, invalidToBase58String, invalidErrorForToBase58String), - (randomByteVectorArrayElement, invalidToBase64String, invalidErrorForToBase64String), - (randomByteVectorArrayElement, invalidToBase16StringArgBeforeFunction, invalidErrorForToBase16String), - (randomByteVectorArrayElement, invalidToBase58StringArgBeforeFunction, invalidErrorForToBase58String), - (randomByteVectorArrayElement, invalidToBase64StringArgBeforeFunction, invalidErrorForToBase64String) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256.scala deleted file mode 100644 index 6fe2bcdc91d..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.blake2b256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Blake2b256 extends JsTestBase { - private val blake2b256 = "blake2b256(callerTestData)" - private val blake2b256ArgBeforeFunc = "callerTestData.blake2b256()" - private val invalidBlake2b256 = "blake2b256()" - private val invalidBlake2b256ArgBeforeFunc = "callerTestData.blake2b256(callerTestData)" - private val invalidErrorBlake2b256 = invalidFunctionError("blake2b256", 1) - - val tests: Tests = Tests { - test("RIDE-122. Function blake2b256 should compile for valid ByteVector") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, blake2b256), - (randomByteVectorArrayElement, blake2b256ArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-123. Function blake2b256 should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, blake2b256, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, blake2b256ArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBlake2b256, invalidErrorBlake2b256), - (randomByteVectorArrayElement, invalidBlake2b256ArgBeforeFunc, invalidErrorBlake2b256) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_128Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_128Kb.scala deleted file mode 100644 index ab053a282d8..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_128Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.blake2b256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Blake2b256_128Kb extends JsTestBase { - private val blake2b256_128Kb = "blake2b256_128Kb(callerTestData)" - private val blake2b256_128KbArgBeforeFunc = "callerTestData.blake2b256_128Kb()" - private val invalidBlake2b256_128Kb = "blake2b256_128Kb()" - private val invalidBlake2b256_128KbArgBeforeFunc = "callerTestData.blake2b256_128Kb(callerTestData)" - private val invalidErrorBlake2b256_128Kb = testData.invalidFunctionError("blake2b256_128Kb", 1) - - val tests: Tests = Tests { - test("RIDE-130. Function blake2b256_128Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, blake2b256_128Kb), - (randomByteVectorArrayElement, blake2b256_128KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-131. Function blake2b256_128Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, blake2b256_128Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, blake2b256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBlake2b256_128Kb, invalidErrorBlake2b256_128Kb), - (randomByteVectorArrayElement, invalidBlake2b256_128KbArgBeforeFunc, invalidErrorBlake2b256_128Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_16Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_16Kb.scala deleted file mode 100644 index 5b71434273f..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_16Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.blake2b256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Blake2b256_16Kb extends JsTestBase { - private val blake2b256_16Kb = "blake2b256_16Kb(callerTestData)" - private val blake2b256_16KbArgBeforeFunc = "callerTestData.blake2b256_16Kb()" - private val invalidBlake2b256_16Kb = "blake2b256_16Kb()" - private val invalidBlake2b256_16KbArgBeforeFunc = "callerTestData.blake2b256_16Kb(callerTestData)" - private val invalidErrorBlake2b256_16Kb = testData.invalidFunctionError("blake2b256_16Kb", 1) - - val tests: Tests = Tests { - test("RIDE-124. Function blake2b256_16Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, blake2b256_16Kb), - (randomByteVectorArrayElement, blake2b256_16KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-125. Function blake2b256 should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, blake2b256_16Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, blake2b256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBlake2b256_16Kb, invalidErrorBlake2b256_16Kb), - (randomByteVectorArrayElement, invalidBlake2b256_16KbArgBeforeFunc, invalidErrorBlake2b256_16Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_32Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_32Kb.scala deleted file mode 100644 index 5460efe85a7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_32Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.blake2b256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Blake2b256_32Kb extends JsTestBase { - private val blake2b256_32Kb = "blake2b256_32Kb(callerTestData)" - private val blake2b256_32KbArgBeforeFunc = "callerTestData.blake2b256_32Kb()" - private val invalidBlake2b256_32Kb = "blake2b256_32Kb()" - private val invalidBlake2b256_32KbArgBeforeFunc = "callerTestData.blake2b256_32Kb(callerTestData)" - private val invalidErrorBlake2b256_32Kb = testData.invalidFunctionError("blake2b256_32Kb", 1) - - val tests: Tests = Tests { - test("RIDE-126. Function blake2b256 should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, blake2b256_32Kb), - (randomByteVectorArrayElement, blake2b256_32KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-127. Function blake2b256_32Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, blake2b256_32Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, blake2b256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBlake2b256_32Kb, invalidErrorBlake2b256_32Kb), - (randomByteVectorArrayElement, invalidBlake2b256_32KbArgBeforeFunc, invalidErrorBlake2b256_32Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_64Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_64Kb.scala deleted file mode 100644 index 7bff43f92b7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/blake2b256/Blake2b256_64Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.blake2b256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Blake2b256_64Kb extends JsTestBase { - private val blake2b256_64Kb = "blake2b256_64Kb(callerTestData)" - private val blake2b256_64KbArgBeforeFunc = "callerTestData.blake2b256_64Kb()" - private val invalidBlake2b256_64Kb = "blake2b256_64Kb()" - private val invalidBlake2b256_64KbArgBeforeFunc = "callerTestData.blake2b256_64Kb(callerTestData)" - private val invalidErrorBlake2b256_64Kb = testData.invalidFunctionError("blake2b256_64Kb", 1) - - val tests: Tests = Tests { - test("RIDE-128. Function blake2b256_64Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, blake2b256_64Kb), - (randomByteVectorArrayElement, blake2b256_64KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-128. Function blake2b256_64Kb должна выдавать ошибку при невалидных данных") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, blake2b256_64Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, blake2b256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBlake2b256_64Kb, invalidErrorBlake2b256_64Kb), - (randomByteVectorArrayElement, invalidBlake2b256_64KbArgBeforeFunc, invalidErrorBlake2b256_64Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256.scala deleted file mode 100644 index 18d8efdf7b3..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.keccak256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersions, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Keccak256 extends JsTestBase { - private val keccak256 = "keccak256(callerTestData)" - private val keccak256ArgBeforeFunc = "callerTestData.keccak256()" - private val invalidKeccak256 = "keccak256()" - private val invalidKeccak256ArgBeforeFunc = "callerTestData.keccak256(callerTestData)" - private val invalidErrorKeccak256 = testData.invalidFunctionError("keccak256", 1) - - val tests: Tests = Tests { - test("RIDE-132. Function Keccak256 should compile for valid ByteVector") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, keccak256), - (randomByteVectorArrayElement, keccak256ArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-133. Function blake2b256 should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, keccak256, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, keccak256ArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidKeccak256, invalidErrorKeccak256), - (randomByteVectorArrayElement, invalidKeccak256ArgBeforeFunc, invalidErrorKeccak256) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_128Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_128Kb.scala deleted file mode 100644 index 5973ed09331..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_128Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.keccak256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Keccak256_128Kb extends JsTestBase { - private val keccak256_128Kb = "keccak256_128Kb(callerTestData)" - private val keccak256_128KbArgBeforeFunc = "callerTestData.keccak256_128Kb()" - private val invalidKeccak256_128Kb = "keccak256_128Kb()" - private val invalidKeccak256_128KbArgBeforeFunc = "callerTestData.keccak256_128Kb(callerTestData)" - private val invalidErrorKeccak256_128Kb = testData.invalidFunctionError("keccak256_128Kb", 1) - - val tests: Tests = Tests { - test("RIDE-140. Function keccak256_128Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, keccak256_128Kb), - (randomByteVectorArrayElement, keccak256_128KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-141. Function keccak256_128Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, keccak256_128Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, keccak256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidKeccak256_128Kb, invalidErrorKeccak256_128Kb), - (randomByteVectorArrayElement, invalidKeccak256_128KbArgBeforeFunc, invalidErrorKeccak256_128Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_16Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_16Kb.scala deleted file mode 100644 index 4a48caa8275..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_16Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.keccak256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Keccak256_16Kb extends JsTestBase { - private val keccak256_16Kb = "keccak256_16Kb(callerTestData)" - private val keccak256_16KbArgBeforeFunc = "callerTestData.keccak256_16Kb()" - private val invalidKeccak256_16Kb = "keccak256_16Kb()" - private val invalidKeccak256_16KbArgBeforeFunc = "callerTestData.keccak256_16Kb(callerTestData)" - private val invalidErrorKeccak256_16Kb = testData.invalidFunctionError("keccak256_16Kb", 1) - - val tests: Tests = Tests { - test("RIDE-134. Function keccak256_16Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, keccak256_16Kb), - (randomByteVectorArrayElement, keccak256_16KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-135. Function keccak256_16Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, keccak256_16Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, keccak256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidKeccak256_16Kb, invalidErrorKeccak256_16Kb), - (randomByteVectorArrayElement, invalidKeccak256_16KbArgBeforeFunc, invalidErrorKeccak256_16Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_32Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_32Kb.scala deleted file mode 100644 index d99d9a288e8..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_32Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.keccak256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Keccak256_32Kb extends JsTestBase { - private val keccak256_32Kb = "keccak256_32Kb(callerTestData)" - private val keccak256_32KbArgBeforeFunc = "callerTestData.keccak256_32Kb()" - private val invalidKeccak256_32Kb = "keccak256_32Kb()" - private val invalidKeccak256_32KbArgBeforeFunc = "callerTestData.keccak256_32Kb(callerTestData)" - private val invalidErrorKeccak256_32Kb = testData.invalidFunctionError("keccak256_32Kb", 1) - - val tests: Tests = Tests { - test("RIDE-136. Function keccak256_32Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, keccak256_32Kb), - (randomByteVectorArrayElement, keccak256_32KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-137. Function keccak256_32Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, keccak256_32Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, keccak256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidKeccak256_32Kb, invalidErrorKeccak256_32Kb), - (randomByteVectorArrayElement, invalidKeccak256_32KbArgBeforeFunc, invalidErrorKeccak256_32Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_64Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_64Kb.scala deleted file mode 100644 index 312dd572b79..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/keccak256/Keccak256_64Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.keccak256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Keccak256_64Kb extends JsTestBase { - private val keccak256_64Kb = "keccak256_64Kb(callerTestData)" - private val keccak256_64KbArgBeforeFunc = "callerTestData.keccak256_64Kb()" - private val invalidKeccak256_64Kb = "keccak256_64Kb()" - private val invalidKeccak256_64KbArgBeforeFunc = "callerTestData.keccak256_64Kb(callerTestData)" - private val invalidErrorKeccak256_64Kb = testData.invalidFunctionError("keccak256_64Kb", 1) - - val tests: Tests = Tests { - test("RIDE-138. Function keccak256_64Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, keccak256_64Kb), - (randomByteVectorArrayElement, keccak256_64KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-139. Function keccak256_64Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, keccak256_64Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, keccak256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidKeccak256_64Kb, invalidErrorKeccak256_64Kb), - (randomByteVectorArrayElement, invalidKeccak256_64KbArgBeforeFunc, invalidErrorKeccak256_64Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256.scala deleted file mode 100644 index 03f5de3c385..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.sha256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersions, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Sha256 extends JsTestBase { - private val sha256 = "sha256(callerTestData)" - private val sha256ArgBeforeFunc = "callerTestData.sha256()" - private val invalidSha256 = "sha256()" - private val invalidSha256ArgBeforeFunc = "callerTestData.sha256(callerTestData)" - private val invalidErrorSha256 = testData.invalidFunctionError("sha256", 1) - - val tests: Tests = Tests { - test("RIDE-142. Function sha256 should compile for valid ByteVector") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sha256), - (randomByteVectorArrayElement, sha256ArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-143. Function sha256 should throw an error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sha256, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sha256ArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSha256, invalidErrorSha256), - (randomByteVectorArrayElement, invalidSha256ArgBeforeFunc, invalidErrorSha256) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_128Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_128Kb.scala deleted file mode 100644 index 7b3c79d2006..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_128Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.sha256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Sha256_128Kb extends JsTestBase { - private val sha256_128Kb = "sha256_128Kb(callerTestData)" - private val sha256_128KbArgBeforeFunc = "callerTestData.sha256_128Kb()" - private val invalidSha256_128Kb = "sha256_128Kb()" - private val invalidSha256_128KbArgBeforeFunc = "callerTestData.sha256_128Kb(callerTestData)" - private val invalidErrorSha256_128Kb = testData.invalidFunctionError("sha256_128Kb", 1) - - val tests: Tests = Tests { - test("RIDE-150. Function sha256_128Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sha256_128Kb), - (randomByteVectorArrayElement, sha256_128KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-151. Function sha256_128Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sha256_128Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sha256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSha256_128Kb, invalidErrorSha256_128Kb), - (randomByteVectorArrayElement, invalidSha256_128KbArgBeforeFunc, invalidErrorSha256_128Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_16Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_16Kb.scala deleted file mode 100644 index 79de0d87770..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_16Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.sha256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Sha256_16Kb extends JsTestBase { - private val sha256_16Kb = "sha256_16Kb(callerTestData)" - private val sha256_16KbArgBeforeFunc = "callerTestData.sha256_16Kb()" - private val invalidSha256_16Kb = "sha256_16Kb()" - private val invalidSha256_16KbArgBeforeFunc = "callerTestData.sha256_16Kb(callerTestData)" - private val invalidErrorSha256_16Kb = testData.invalidFunctionError("sha256_16Kb", 1) - - val tests: Tests = Tests { - test("RIDE-144. Function sha256_16Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sha256_16Kb), - (randomByteVectorArrayElement, sha256_16KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-145. Function sha256_16Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sha256_16Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sha256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSha256_16Kb, invalidErrorSha256_16Kb), - (randomByteVectorArrayElement, invalidSha256_16KbArgBeforeFunc, invalidErrorSha256_16Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_32Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_32Kb.scala deleted file mode 100644 index 279007f292a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_32Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.sha256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Sha256_32Kb extends JsTestBase { - private val sha256_32Kb = "sha256_32Kb(callerTestData)" - private val sha256_32KbArgBeforeFunc = "callerTestData.sha256_32Kb()" - private val invalidSha256_32Kb = "sha256_32Kb()" - private val invalidSha256_32KbArgBeforeFunc = "callerTestData.sha256_32Kb(callerTestData)" - private val invalidErrorSha256_32Kb = testData.invalidFunctionError("sha256_32Kb", 1) - - val tests: Tests = Tests { - test("RIDE-146. Function sha256_32Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sha256_32Kb), - (randomByteVectorArrayElement, sha256_32KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-147. Function sha256_32Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sha256_32Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sha256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSha256_32Kb, invalidErrorSha256_32Kb), - (randomByteVectorArrayElement, invalidSha256_32KbArgBeforeFunc, invalidErrorSha256_32Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_64Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_64Kb.scala deleted file mode 100644 index d27ec125666..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/hashing/sha256/Sha256_64Kb.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.hashing.sha256 - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, nonMatchingTypes, rideV3Result} -import utest.{Tests, test} - -object Sha256_64Kb extends JsTestBase { - private val sha256_64Kb = "sha256_64Kb(callerTestData)" - private val sha256_64KbArgBeforeFunc = "callerTestData.sha256_64Kb()" - private val invalidSha256_64Kb = "sha256_64Kb()" - private val invalidSha256_64KbArgBeforeFunc = "callerTestData.sha256_64Kb(callerTestData)" - private val invalidErrorSha256_64Kb = testData.invalidFunctionError("sha256_64Kb", 1) - - val tests: Tests = Tests { - test("RIDE-148. Function sha256_64Kb should compile for valid ByteVector") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sha256_64Kb), - (randomByteVectorArrayElement, sha256_64KbArgBeforeFunc) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-149. Function sha256_64Kb should throw an error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sha256_64Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sha256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSha256_64Kb, invalidErrorSha256_64Kb), - (randomByteVectorArrayElement, invalidSha256_64KbArgBeforeFunc, invalidErrorSha256_64Kb) - ) - ) { - val script = precondition.codeFromMatchingAndCase(data, function, rideV3Result, GreaterV3ResultBinaryEntry) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Cons.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Cons.scala deleted file mode 100644 index 4876b912127..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Cons.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomBoolean, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, intList, invalidFunctionError, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object Cons extends JsTestBase { - private val cons = "cons(foo, bar)" - private val consArgBeforeFunc = "foo.cons(bar)" - private val invalidCons = "cons(foo)" - private val invalidConsArgBeforeFunc = "foo.cons(foo, bar)" - private val invalidErrorCons = invalidFunctionError("cons", 2) - - val tests: Tests = Tests { - test("RIDE-152. Function Cons should compile for valid list") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, cons), - (randomInt.toString, intList, cons), - (randomStringArrayElement, stringList, consArgBeforeFunc), - (randomInt.toString, intList, consArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-153. Function Cons should throw an error for invalid data or type") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, cons, nonMatchingTypes("")), - (randomStringArrayElement, randomBoolean.toString, consArgBeforeFunc, nonMatchingTypes("")), - (randomInt.toString, intList, invalidCons, invalidErrorCons), - (randomStringArrayElement, stringList, invalidConsArgBeforeFunc, invalidErrorCons) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ContainsElement.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ContainsElement.scala deleted file mode 100644 index 71179420236..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ContainsElement.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, intList, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object ContainsElement extends JsTestBase { - private val containsElement = "containsElement(bar, foo)" - private val containsElementArgBeforeFunc = "bar.containsElement(foo)" - private val invalidContainsElement = "containsElement(foo)" - private val invalidContainsElementArgBeforeFunc = "foo.containsElement(foo, bar)" - private val invalidErrorContainsElement = testData.invalidFunctionError("containsElement", 2) - - val tests: Tests = Tests { - test("RIDE-154. Function ContainsElement should compile for valid list") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, containsElement), - (randomInt.toString, intList, containsElement), - (randomStringArrayElement, stringList, containsElementArgBeforeFunc), - (randomInt.toString, intList, containsElementArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-155. Function ContainsElement should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, containsElement, nonMatchingTypes("")), - (randomStringArrayElement, randomIssuesArrayElement, containsElementArgBeforeFunc, nonMatchingTypes("")), - (randomInt.toString, intList, invalidContainsElement, invalidErrorContainsElement), - (randomStringArrayElement, stringList, invalidContainsElementArgBeforeFunc, invalidErrorContainsElement) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/GetElement.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/GetElement.scala deleted file mode 100644 index 05443e10b0c..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/GetElement.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, intList, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object GetElement extends JsTestBase { - private val getElement = "getElement(bar, foo)" - private val getElementArgBeforeFunc = "bar.getElement(foo)" - private val invalidGetElement = "getElement(foo)" - private val invalidGetElementArgBeforeFunc = "foo.getElement(bar, foo)" - private val invalidErrorGetElement = testData.invalidFunctionError("getElement", 2) - - val tests: Tests = Tests { - test("RIDE-156. Function GetElement should compile for valid list") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomInt.toString, stringList, getElement), - (randomInt.toString, intList, getElement), - (randomInt.toString, stringList, getElementArgBeforeFunc), - (randomInt.toString, intList, getElementArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-157. Function GetElement should throw an error for invalid data or type") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, getElement, nonMatchingTypes("")), - (randomStringArrayElement, randomIssuesArrayElement, getElementArgBeforeFunc, nonMatchingTypes("")), - (randomInt.toString, intList, invalidGetElement, invalidErrorGetElement), - (randomStringArrayElement, stringList, invalidGetElementArgBeforeFunc, invalidErrorGetElement) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/IndexOf.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/IndexOf.scala deleted file mode 100644 index 4029a039de3..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/IndexOf.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomByteVectorArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, stringList} -import utest.{Tests, test} - -object IndexOf extends JsTestBase { - private val indexOf = "indexOf(bar, foo)" - private val indexOfArgBeforeFunc = "bar.indexOf(foo)" - private val invalidIndexOf = "indexOf()" - private val invalidIndexOfArgBeforeFunc = "bar.indexOf(bar, foo)" - - val tests: Tests = Tests { - test("RIDE-158. Function IndexOf should compile for valid list") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, indexOf), - (randomInt.toString, intList, indexOf), - (randomStringArrayElement, stringList, indexOfArgBeforeFunc), - (randomInt.toString, intList, indexOfArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-159. Function IndexOf should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (stringList, stringList, indexOf), - (randomByteVectorArrayElement, intList, indexOfArgBeforeFunc), - (randomInt.toString, intList, invalidIndexOf), - (randomStringArrayElement, stringList, invalidIndexOfArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/LastIndexOf.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/LastIndexOf.scala deleted file mode 100644 index ed0a6bc1296..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/LastIndexOf.scala +++ /dev/null @@ -1,50 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomByteVectorArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, stringList} -import utest.{Tests, test} - -object LastIndexOf extends JsTestBase { - private val lastIndexOf = "lastIndexOf(bar, foo)" - private val lastIndexOfArgBeforeFunc = "bar.lastIndexOf(foo)" - private val invalidLastIndexOf = "lastIndexOf()" - private val invalidLastIndexOfArgBeforeFunc = "bar.indexOf(bar, foo)" - - val tests: Tests = Tests { - test("RIDE-160. Function LastIndexOf should compile for valid list") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, lastIndexOf), - (randomInt.toString, intList, lastIndexOf), - (randomStringArrayElement, stringList, lastIndexOfArgBeforeFunc), - (randomInt.toString, intList, lastIndexOfArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-161. Function IndexOf should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (stringList, stringList, lastIndexOf), - (randomByteVectorArrayElement, intList, lastIndexOfArgBeforeFunc), - (randomInt.toString, intList, invalidLastIndexOf), - (randomStringArrayElement, stringList, invalidLastIndexOfArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Max.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Max.scala deleted file mode 100644 index 8aafca83452..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Max.scala +++ /dev/null @@ -1,72 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V4 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object Max extends JsTestBase { - private val max = "max(callerTestData)" - private val maxArgBeforeFunc = "callerTestData.max()" - private val invalidMax = "max()" - private val invalidMaxArgBeforeFunc = "callerTestData.max(callerTestData)" - private val maxForBigInt = "max([callerTestData])" - private val maxForBigIntArgBeforeFunc = "[callerTestData].max()" - private val invalidMaxForBigInt = "[callerTestData].max([callerTestData], [callerTestData])" - - val tests: Tests = Tests { - test("RIDE-162. Function Max should compile with a list") { - for (version <- actualVersionsWithoutV3) { - for ( - (data, function, dataType) <- Seq( - (intList, max, "Int"), - (intList, maxArgBeforeFunc, "Int") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-163. Function Max should compile with a BigInt") { - for (version <- versionsSupportingTheNewFeatures) { - for ( - (data, function, dataType) <- Seq( - (s"toBigInt($randomInt)", maxForBigInt, "BigInt"), - (s"toBigInt($randomInt)", maxForBigIntArgBeforeFunc, "BigInt") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-164. Function Max should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - for ( - (data, function, dataType, error) <- Seq( - (randomUnionArrayElement, max, "Int", nonMatchingTypes("List[Int]")), - (randomDigestAlgorithmTypeArrayElement, maxArgBeforeFunc, "Int", nonMatchingTypes("List[Int]")), - (intList, invalidMax, "Int", invalidFunctionError("max", 1)), - (intList, invalidMaxArgBeforeFunc, "Int", invalidFunctionError("max", 1)), - (intList, invalidMaxForBigInt, "Int", invalidFunctionError("max", 1)), - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - if (version == V4) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Min.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Min.scala deleted file mode 100644 index 8ee68499812..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Min.scala +++ /dev/null @@ -1,79 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V4 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{ - CANT_FIND_A_FUNCTION_OVERLOAD, - actualVersionsWithoutV3, - intList, - invalidFunctionError, - nonMatchingTypes, - versionsSupportingTheNewFeatures -} -import utest.{Tests, test} - -object Min extends JsTestBase { - private val min = "min(callerTestData)" - private val minArgBeforeFunc = "callerTestData.min()" - private val invalidMin = "min()" - private val invalidMinArgBeforeFunc = "callerTestData.min(callerTestData)" - private val minForBigInt = "min([callerTestData])" - private val minForBigIntArgBeforeFunc = "[callerTestData].min()" - private val invalidMinForBigInt = "[callerTestData].min([callerTestData], [callerTestData])" - - val tests: Tests = Tests { - test("RIDE-165. Function Min should compile with a list") { - for (version <- actualVersionsWithoutV3) { - for ( - (data, function, dataType) <- Seq( - (intList, min, "Int"), - (intList, minArgBeforeFunc, "Int") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-166. Function Min should compile with a BigInt") { - for (version <- versionsSupportingTheNewFeatures) { - for ( - (data, function, dataType) <- Seq( - (s"toBigInt($randomInt)", minForBigInt, "BigInt"), - (s"toBigInt($randomInt)", minForBigIntArgBeforeFunc, "BigInt") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-167. Function Min should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - for ( - (data, function, dataType, error) <- Seq( - (randomUnionArrayElement, min, "Int", nonMatchingTypes("List[Int]")), - (randomDigestAlgorithmTypeArrayElement, minArgBeforeFunc, "Int", nonMatchingTypes("List[Int]")), - (intList, invalidMin, "Int", invalidFunctionError("min", 1)), - (intList, invalidMinArgBeforeFunc, "Int", invalidFunctionError("min", 1)), - (intList, invalidMinForBigInt, "Int", invalidFunctionError("min", 1)) - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - if (version == V4) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/RemoveByIndex.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/RemoveByIndex.scala deleted file mode 100644 index f6239f74a5a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/RemoveByIndex.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object RemoveByIndex extends JsTestBase { - private val removeByIndex = "removeByIndex(bar, foo)" - private val removeByIndexArgBeforeFunc = "bar.removeByIndex(foo)" - private val invalidRemoveByIndex = "removeByIndex(foo)" - private val invalidRemoveByIndexArgBeforeFunc = "foo.removeByIndex(bar, foo)" - private val invalidErrorRemoveByIndex = testData.invalidFunctionError("removeByIndex", 2) - - val tests: Tests = Tests { - test("RIDE-168. Function RemoveByIndex should compile for valid list") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomInt.toString, stringList, removeByIndex), - (randomInt.toString, stringList, removeByIndexArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-169. Function RemoveByIndex should throw an error for invalid data or type") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, removeByIndex, nonMatchingTypes("List[T]")), - (randomInt.toString, randomIssuesArrayElement, removeByIndexArgBeforeFunc, nonMatchingTypes("List[T]")), - (randomInt.toString, stringList, invalidRemoveByIndex, invalidErrorRemoveByIndex), - (randomInt.toString, stringList, invalidRemoveByIndexArgBeforeFunc, invalidErrorRemoveByIndex) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ReplaceByIndex.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ReplaceByIndex.scala deleted file mode 100644 index 6eb499dac6b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/ReplaceByIndex.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.DirectiveDictionary -import com.wavesplatform.lang.directives.values.{StdLibVersion, V8} -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{nonMatchingTypes, stringList} -import utest.{Tests, test} - -object ReplaceByIndex extends JsTestBase { - private val replaceByIndex = "replaceByIndex(bar, 1, foo)" - private val replaceByIndexArgBeforeFunc = "bar.replaceByIndex(1, foo)" - private val invalidReplaceByIndex = "replaceByIndex(1, foo)" - private val invalidReplaceByIndexArgBeforeFunc = "foo.replaceByIndex(bar, 1, foo)" - private val invalidErrorReplaceByIndex = testData.invalidFunctionError("replaceByIndex", numberOfArguments = 3) - - val tests: Tests = Tests { - test("replaceByIndex functions compiles with a list") { - for (version <- DirectiveDictionary[StdLibVersion].all.filter(_ >= V8)) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, replaceByIndex), - (randomStringArrayElement, stringList, replaceByIndexArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("Compilation errors ReplaceByIndex functions") { - for (version <- DirectiveDictionary[StdLibVersion].all.filter(_ >= V8)) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, replaceByIndex, nonMatchingTypes("List[T]")), - (randomInt.toString, randomIssuesArrayElement, replaceByIndexArgBeforeFunc, nonMatchingTypes("List[T]")), - (randomInt.toString, stringList, invalidReplaceByIndex, invalidErrorReplaceByIndex), - (randomInt.toString, stringList, invalidReplaceByIndexArgBeforeFunc, invalidErrorReplaceByIndex) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Size.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Size.scala deleted file mode 100644 index a2b3d0952f7..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/list/Size.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.list - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList} -import utest.{Tests, test} - -object Size extends JsTestBase { - private val size = "size(callerTestData)" - private val sizeArgBeforeFunc = "callerTestData.size()" - private val invalidSize = "size()" - private val invalidSizeArgBeforeFunc = "callerTestData.size(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-170. Function Size should compile for valid list") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (intList, size), - (intList, sizeArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-171. Function Size should throw an error for invalid data or type") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomUnionArrayElement, size), - (randomAddressDataArrayElement, sizeArgBeforeFunc), - (intList, invalidSize), - (intList, invalidSizeArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Fraction.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Fraction.scala deleted file mode 100644 index 41ef536076d..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Fraction.scala +++ /dev/null @@ -1,117 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.math - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V5 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomInt, - randomIssuesArrayElement, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, nonMatchingTypes, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object Fraction extends JsTestBase { - private var union: String = randomUnionArrayElement - private val fractionInt = s"fraction(callerTestData, $randomInt, $randomInt)" - private val fractionIntArgBeforeFunc = s"callerTestData.fraction($randomInt, $randomInt)" - private val fractionIntAndUnion = s"fraction(callerTestData, $randomInt, $randomInt, $union)" - private val fractionIntAndUnionArgBeforeFunc = s"callerTestData.fraction($randomInt, $randomInt, $union)" - - union = randomUnionArrayElement - private val fractionBigInt = s"fraction(callerTestData, callerTestData, callerTestData)" - private val fractionBigIntArgBeforeFunc = s"callerTestData.fraction(callerTestData, callerTestData)" - private val fractionBigIntAndUnion = s"fraction(callerTestData, callerTestData, callerTestData, $union)" - private val fractionBigIntAndUnionArgBeforeFunc = s"callerTestData.fraction(callerTestData, callerTestData, $union)" - - private val invalidFractionFunction = s"fraction(callerTestData)" - private val invalidFractionFunctionArgBeforeFunc = s"callerTestData.fraction()" - private val fractionError: String = testData.invalidFunctionError("fraction", 3) - - val tests: Tests = Tests { - test("RIDE-172. Fraction should compile with the Int type") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, fractionInt), - (randomInt.toString, fractionIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-173. Fraction should compile with the Int and Union types - Ride V5, V6") { - for (version <- versionsSupportingTheNewFeatures) { - for ( - (data, function, dataType) <- Seq( - (randomInt.toString, fractionIntAndUnion, "Int"), - (randomInt.toString, fractionIntAndUnionArgBeforeFunc, "Int"), - (s"toBigInt(${randomInt.toString})", fractionBigInt, "BigInt"), - (s"toBigInt(${randomInt.toString})", fractionBigIntArgBeforeFunc, "BigInt"), - (s"toBigInt(${randomInt.toString})", fractionBigIntAndUnion, "BigInt"), - (s"toBigInt(${randomInt.toString})", fractionBigIntAndUnionArgBeforeFunc, "BigInt") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-174. Fraction should throw an error for invalid data") { - for (version <- actualVersions) { - for ( - (data, function, dataType, error) <- Seq( - (randomInt.toString, invalidFractionFunction, "Int", fractionError), - (randomInt.toString, invalidFractionFunctionArgBeforeFunc, "Int", fractionError), - (randomStringArrayElement, fractionInt, "Int", nonMatchingTypes("Int")), - (randomAddressDataArrayElement, fractionIntArgBeforeFunc, "Int", nonMatchingTypes("Int")) - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - if (version < V5) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - - test("RIDE-175. Fraction should raise a compilation error for BigInt - Ride V5, V6") { - for (version <- versionsSupportingTheNewFeatures) { - for ( - (data, function, dataType, error) <- Seq( - (randomStringArrayElement, fractionBigInt, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD), - (randomAliasDataArrayElement, fractionBigIntArgBeforeFunc, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD), - (randomStringArrayElement, fractionBigIntAndUnion, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD), - (randomAliasDataArrayElement, fractionBigIntAndUnionArgBeforeFunc, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD), - (randomIssuesArrayElement, fractionIntAndUnion, "Int", CANT_FIND_A_FUNCTION_OVERLOAD), - (randomIssuesArrayElement, fractionIntAndUnionArgBeforeFunc, "Int", CANT_FIND_A_FUNCTION_OVERLOAD) - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-176. Fraction should raise an error for versions V3 and V4 with incorrect argument count") { - for (version <- testData.oldVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - val script = precondition.onlyMatcherContract(randomInt.toString, fractionIntAndUnion) - assertCompileErrorDApp(script, version, fractionError) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Log.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Log.scala deleted file mode 100644 index 5f7e94d8b19..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Log.scala +++ /dev/null @@ -1,93 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.math - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V5 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomInt, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, nonMatchingTypes} -import utest.{Tests, test} - -object Log extends JsTestBase { - private val union: String = randomUnionArrayElement - private val logInt = s"log(callerTestData, $randomInt, $randomInt, 4, 2, $union)" - private val logIntArgBeforeFunc = s"callerTestData.log($randomInt, $randomInt, 4, 2, $union)" - private val logBigInt = s"log(callerTestData, 6, callerTestData, $randomInt, 2, $union)" - private val logBigIntArgBeforeFunc = s"callerTestData.log(6, callerTestData, $randomInt, 2, $union)" - private val invalidLogInt = s"log(callerTestData, 10, $union)" - private val invalidLogIntArgBeforeFunc = s"callerTestData.log(10, $union)" - private val logError: String = testData.invalidFunctionError("log", 6) - - val tests: Tests = Tests { - test("RIDE-177. Log function should compile with Int") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, logInt), - (randomInt.toString, logIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-178. Log function should compile with BigInt for Ride V5, V6") { - for (version <- testData.versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (s"toBigInt(${randomInt.toString})", logBigInt), - (s"toBigInt(${randomInt.toString})", logBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-179. Log function should throw an error for invalid data") { - for (version <- testData.actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomStringArrayElement, logInt, nonMatchingTypes("Int")), - (randomAddressDataArrayElement, logIntArgBeforeFunc, nonMatchingTypes("Int")), - (randomInt.toString, invalidLogInt, logError), - (randomInt.toString, invalidLogIntArgBeforeFunc, logError) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - if (version < V5) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - - test("RIDE-180. Log function should throw an error for invalid data BigInt - Ride V5, V6") { - for (version <- testData.versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, logBigInt), - (randomAliasDataArrayElement, logBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Median.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Median.scala deleted file mode 100644 index 0b5b96b637b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Median.scala +++ /dev/null @@ -1,84 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.math - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V5 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, nonMatchingTypes, versionsSupportingTheNewFeatures} -import utest.{Tests, test} - -object Median extends JsTestBase { - private val medianInt = s"median([callerTestData, $randomInt, $randomInt])" - private val medianIntArgBeforeFunc = s"[callerTestData, $randomInt, $randomInt].median()" - private val medianBigInt = s"median(callerTestData)" - private val medianBigIntArgBeforeFunc = s"callerTestData.median()" - private val invalidMedianInt = s"median()" - private val medianError: String = testData.invalidFunctionError("median", 1) - - val tests: Tests = Tests { - test("RIDE-181. Median functions should compile with Int") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, medianInt), - (randomInt.toString, medianIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-182. Median functions should compile with BigInt for Ride V5, V6") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (s"[toBigInt(${randomInt.toString})]", medianBigInt), - (s"[toBigInt(${randomInt.toString})]", medianBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-183. Median functions should throw an error for invalid Int data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, invalidMedianInt, medianError), - (randomStringArrayElement, medianInt, nonMatchingTypes("List[Int]")), - (randomAddressDataArrayElement, medianIntArgBeforeFunc, nonMatchingTypes("List[Int]")) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - if (version < V5) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - - test("RIDE-184. Median function should throw an error for invalid BigInt data - Ride V5, V6") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, medianBigInt), - (randomAliasDataArrayElement, medianBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, testData.CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Pow.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Pow.scala deleted file mode 100644 index 1077d111eea..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Pow.scala +++ /dev/null @@ -1,96 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.math - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V5 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomInt, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{ - CANT_FIND_A_FUNCTION_OVERLOAD, - actualVersionsWithoutV3, - nonMatchingTypes, - versionsSupportingTheNewFeatures -} -import utest.{Tests, test} - -object Pow extends JsTestBase { - private val union = randomUnionArrayElement - private val powInt = s"pow(callerTestData, 6, $randomInt, 4, $randomInt, $union)" - private val powIntArgBeforeFunc = s"callerTestData.pow(6, $randomInt, $randomInt, 2, $union)" - private val powBigInt = s"pow(callerTestData, 6, callerTestData, 4, 2, $union)" - private val powBigIntArgBeforeFunc = s"callerTestData.pow($randomInt, callerTestData, 4, 2, $union)" - private val invalidPowInt = s"pow()" - private val powError: String = testData.invalidFunctionError("pow", 6) - - val tests: Tests = Tests { - test("RIDE-185. Pow functions should compile with Int") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, powInt), - (randomInt.toString, powIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-186. Pow functions should compile with BigInt for Ride V5, V6") { - for (version <- versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (s"toBigInt(${randomInt.toString})", powBigInt), - (s"toBigInt(${randomInt.toString})", powBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-187. Median functions should throw an error for invalid Int data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function, error) <- Seq( - (randomInt.toString, invalidPowInt, powError), - (randomStringArrayElement, powInt, nonMatchingTypes("Int")), - (randomAddressDataArrayElement, powIntArgBeforeFunc, nonMatchingTypes("Int")) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - if (version < V5) { - assertCompileErrorDApp(script, version, error) - } else { - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } - - test("RIDE-188. Median function should throw an error for invalid BigInt data - Ride V5, V6") { - for (version <- testData.versionsSupportingTheNewFeatures) { - val precondition = new GeneratorContractsForBuiltInFunctions("BigInt", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, powBigInt), - (randomAliasDataArrayElement, powBigIntArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Sqrt.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Sqrt.scala deleted file mode 100644 index 2859884f800..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/math/Sqrt.scala +++ /dev/null @@ -1,62 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.math - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V6 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomByteVectorArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, CANT_FIND_FUNCTION} -import utest.{Tests, test} - -object Sqrt extends JsTestBase { - private val union = randomUnionArrayElement - private val sqrtIntAndUnion = s"sqrt(callerTestData, $randomInt, $randomInt, $union)" - private val sqrtIntAndUnionArgBeforeFunc = s"callerTestData.sqrt($randomInt, 3, $union)" - private val invalidSqrtFunction = s"sqrt(callerTestData)" - - val tests: Tests = Tests { - test("RIDE-189. Sqrt functions compile with Int and BigInt") { - for ( - (data, function, dataType) <- Seq( - (randomInt.toString, sqrtIntAndUnion, "Int"), - (randomInt.toString, sqrtIntAndUnionArgBeforeFunc, "Int"), - (s"toBigInt(${randomInt.toString})", sqrtIntAndUnion, "BigInt"), - (s"toBigInt(${randomInt.toString})", sqrtIntAndUnionArgBeforeFunc, "BigInt") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, V6) - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, V6) - } - } - - test("RIDE-190. Sqrt functions should throw an error for invalid Int data") { - for ( - (data, function, dataType) <- Seq( - (randomStringArrayElement, sqrtIntAndUnion, "Int"), - (randomInt.toString, invalidSqrtFunction, "Int"), - (randomByteVectorArrayElement, sqrtIntAndUnion, "BigInt"), - (s"toBigInt(${randomInt.toString})", invalidSqrtFunction, "BigInt") - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, V6) - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, V6, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - - test("RIDE-191. Can't find a function Sqrt for V3 - V5") { - for (version <- testData.versionsWithoutV6) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, sqrtIntAndUnion), - (randomInt.toString, sqrtIntAndUnionArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Contains.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Contains.scala deleted file mode 100644 index 809a7d05597..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Contains.scala +++ /dev/null @@ -1,57 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object Contains extends JsTestBase { - private val contains = "contains(bar, foo)" - private val containsArgBeforeFunc = "bar.contains(foo)" - private val invalidContains = "contains(foo)" - private val invalidContainsArgBeforeFunc = "foo.contains(bar, foo)" - private val invalidErrorContains = testData.invalidFunctionError("contains", 2) - - val tests: Tests = Tests { - test("RIDE-208. function contains should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, contains), - (randomStringArrayElement, randomStringArrayElement, containsArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-209. function contains throw a compilation error for invalid data") { - for (version <- testData.actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, containsArgBeforeFunc, nonMatchingTypes("String")), - (randomInt.toString, randomIssuesArrayElement, containsArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, randomStringArrayElement, invalidContains, invalidErrorContains), - (randomStringArrayElement, randomStringArrayElement, invalidContainsArgBeforeFunc, invalidErrorContains) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - - } - } - - test("RIDE-210. Can't find a function contains for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V3) - val script = precondition.simpleRideCode(randomStringArrayElement, randomStringArrayElement, contains) - assertCompileErrorDApp(script, V3, testData.CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Drop.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Drop.scala deleted file mode 100644 index f40e5c6671b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Drop.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Drop extends JsTestBase { - private val drop = s"drop(callerTestData, $randomInt)" - private val dropArgBeforeFunction = s"callerTestData.drop($randomInt)" - private val invalidDrop = s"drop(callerTestData)" - private val invalidDropArgBeforeFunc = s"callerTestData.drop(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-211. function drop should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, drop), - (randomStringArrayElement, dropArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-212. function drop throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, drop), - (randomUnionArrayElement, dropArgBeforeFunction), - (randomStringArrayElement, invalidDrop), - (randomStringArrayElement, invalidDropArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/DropRight.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/DropRight.scala deleted file mode 100644 index 7e47ad779ea..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/DropRight.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object DropRight extends JsTestBase { - private val dropRight = s"dropRight(callerTestData, $randomInt)" - private val dropRightArgBeforeFunction = s"callerTestData.dropRight($randomInt)" - private val invalidDropRight = s"dropRight(callerTestData)" - private val invalidDropRightArgBeforeFunc = s"callerTestData.dropRight(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-213. function dropRight should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, dropRight), - (randomStringArrayElement, dropRightArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-214. function dropRight throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, dropRight), - (randomUnionArrayElement, dropRightArgBeforeFunction), - (randomStringArrayElement, invalidDropRight), - (randomStringArrayElement, invalidDropRightArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/IndexOf.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/IndexOf.scala deleted file mode 100644 index c445e104be8..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/IndexOf.scala +++ /dev/null @@ -1,52 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList, stringList} -import utest.{Tests, test} - -object IndexOf extends JsTestBase { - private val indexOf = "indexOf(bar, foo)" - private val indexOfWithOffset = s"indexOf(bar, foo, $randomInt)" - private val indexOfArgBeforeFunc = "bar.indexOf(foo)" - private val indexOfWithOffsetArgBeforeFunc = s"bar.indexOf(foo, $randomInt)" - private val invalidIndexOf = "indexOf()" - - val tests: Tests = Tests { - test("RIDE-215. function indexOf should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, indexOf), - (randomStringArrayElement, randomStringArrayElement, indexOfWithOffset), - (randomStringArrayElement, randomStringArrayElement, indexOfArgBeforeFunc), - (randomStringArrayElement, randomStringArrayElement, indexOfWithOffsetArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-216. function indexOf - Non-matching types - Can't find a function overload") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function) <- Seq( - (stringList, randomStringArrayElement, indexOf), - (randomInt.toString, randomStringArrayElement, indexOfArgBeforeFunc), - (stringList, randomStringArrayElement, indexOfWithOffset), - (randomInt.toString, randomStringArrayElement, indexOfWithOffsetArgBeforeFunc), - (randomInt.toString, intList, invalidIndexOf) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/LastIndexOf.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/LastIndexOf.scala deleted file mode 100644 index 122b061d3c4..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/LastIndexOf.scala +++ /dev/null @@ -1,52 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList, stringList} -import utest.{Tests, test} - -object LastIndexOf extends JsTestBase { - private val lastIndexOf = "lastIndexOf(bar, foo)" - private val lastIndexOfWithOffset = s"lastIndexOf(bar, foo, $randomInt)" - private val lastIndexOfArgBeforeFunc = "bar.lastIndexOf(foo)" - private val lastIndexOfWithOffsetArgBeforeFunc = s"bar.lastIndexOf(foo, $randomInt)" - private val invalidLastIndexOf = "lastIndexOf()" - - val tests: Tests = Tests { - test("RIDE-217. function lastIndexOf should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, lastIndexOf), - (randomStringArrayElement, randomStringArrayElement, lastIndexOfWithOffset), - (randomStringArrayElement, randomStringArrayElement, lastIndexOfArgBeforeFunc), - (randomStringArrayElement, randomStringArrayElement, lastIndexOfWithOffsetArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-218. function lastIndexOf - Non-matching types - Can't find a function overload") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function) <- Seq( - (stringList, randomStringArrayElement, lastIndexOf), - (randomInt.toString, randomStringArrayElement, lastIndexOfArgBeforeFunc), - (stringList, randomStringArrayElement, lastIndexOfWithOffset), - (randomInt.toString, randomStringArrayElement, lastIndexOfWithOffsetArgBeforeFunc), - (randomInt.toString, intList, invalidLastIndexOf) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Size.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Size.scala deleted file mode 100644 index c1fbb6a4546..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Size.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Size extends JsTestBase { - private val size = s"size(callerTestData)" - private val sizeArgBeforeFunction = s"callerTestData.size()" - private val invalidSize = s"size()" - private val invalidSizeArgBeforeFunc = s"callerTestData.size(callerTestData, callerTestData)" - - val tests: Tests = Tests { - test("RIDE-219. function size should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, size), - (randomStringArrayElement, sizeArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileSuccessDApp(script, version) - - } - } - } - - test("RIDE-220. function size throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, size), - (randomUnionArrayElement, sizeArgBeforeFunction), - (randomStringArrayElement, invalidSize), - (randomStringArrayElement, invalidSizeArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultIntegerEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Take.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Take.scala deleted file mode 100644 index cadc4a0eaf3..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/Take.scala +++ /dev/null @@ -1,48 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object Take extends JsTestBase { - private val take = s"take(callerTestData, $randomInt)" - private val takeArgBeforeFunction = s"callerTestData.take($randomInt)" - private val invalidTake = s"take(callerTestData)" - private val invalidTakeArgBeforeFunc = s"callerTestData.take(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-221. function take should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, take), - (randomStringArrayElement, takeArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-222. function take throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, take), - (randomUnionArrayElement, takeArgBeforeFunction), - (randomStringArrayElement, invalidTake), - (randomStringArrayElement, invalidTakeArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/TakeRight.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/TakeRight.scala deleted file mode 100644 index 775f4379efa..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/TakeRight.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result} -import utest.{Tests, test} - -object TakeRight extends JsTestBase { - private val takeRight = s"takeRight(callerTestData, $randomInt)" - private val takeRightArgBeforeFunction = s"callerTestData.takeRight($randomInt)" - private val invalidTakeRight = s"takeRight(callerTestData)" - private val invalidTakeRightArgBeforeFunc = s"callerTestData.takeRight(callerTestData, $randomInt)" - - val tests: Tests = Tests { - test("RIDE-223. function takeRight should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomStringArrayElement, takeRight), - (randomStringArrayElement, takeRightArgBeforeFunction) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileSuccessDApp(script, version) - - } - } - } - - test("RIDE-224. function takeRight throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, takeRight), - (randomUnionArrayElement, takeRightArgBeforeFunction), - (randomStringArrayElement, invalidTakeRight), - (randomStringArrayElement, invalidTakeRightArgBeforeFunc) - ) - ) { - val script = precondition.codeWithoutMatcher(data, function, rideV3Result, GreaterV3ResultStringEntry) - assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString.scala deleted file mode 100644 index 92839d0043b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.makeStringFunctions - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object MakeString extends JsTestBase { - private val makeString = "makeString(bar, foo)" - private val makeStringArgBeforeFunc = "bar.makeString(foo)" - private val invalidMakeString = "makeString(foo)" - private val invalidMakeStringArgBeforeFunc = "foo.makeString(bar, foo)" - private val invalidErrorMakeString = invalidFunctionError("makeString", 2) - - val tests: Tests = Tests { - test("RIDE-192. makeString function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, makeString), - (randomStringArrayElement, stringList, makeStringArgBeforeFunc), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-193. makeString function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, makeStringArgBeforeFunc, nonMatchingTypes("List[String]")), - (randomInt.toString, randomIssuesArrayElement, makeStringArgBeforeFunc, nonMatchingTypes("List[String]")), - (randomStringArrayElement, stringList, invalidMakeString, invalidErrorMakeString), - (randomStringArrayElement, stringList, invalidMakeStringArgBeforeFunc, invalidErrorMakeString), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_11C.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_11C.scala deleted file mode 100644 index 83bf262c2f6..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_11C.scala +++ /dev/null @@ -1,59 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.makeStringFunctions - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V6 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object MakeString_11C extends JsTestBase { - private val makeString_11C = s"makeString_11C(bar, foo)" - private val makeString_11CArgBeforeFunc = s"bar.makeString_11C(foo)" - private val invalidMakeString_11CFunction = s"makeString_11C(foo)" - private val invalidErrorMakeString_11C = testData.invalidFunctionError("makeString_11C", 2) - - val tests: Tests = Tests { - test("RIDE-197. makeString_11C function should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, makeString_11C), - (randomStringArrayElement, stringList, makeString_11CArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, V6) - } - } - - test("RIDE-198. makeString_11C function should throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function, error) <- Seq( - (randomStringArrayElement, stringList, invalidMakeString_11CFunction, invalidErrorMakeString_11C), - (randomIssuesArrayElement, stringList, makeString_11C, nonMatchingTypes("String")), - (randomInt.toString, stringList, makeString_11CArgBeforeFunc, nonMatchingTypes("String")), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, V6, error) - } - } - - test("RIDE-199. Can't find a function makeString_11C for RIDE versions V3 - V5") { - for (version <- testData.versionsWithoutV6) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, makeString_11C), - (randomStringArrayElement, stringList, makeString_11CArgBeforeFunc), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_2C.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_2C.scala deleted file mode 100644 index bdd9bd5f923..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/makeStringFunctions/MakeString_2C.scala +++ /dev/null @@ -1,59 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.makeStringFunctions - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V6 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, nonMatchingTypes, stringList} -import utest.{Tests, test} - -object MakeString_2C extends JsTestBase { - private val makeString_2C = s"makeString_2C(bar, foo)" - private val makeString_2CArgBeforeFunc = s"bar.makeString_2C(foo)" - private val invalidMakeString_2CFunction = s"makeString_2C(foo)" - private val invalidErrorMakeString_2C = testData.invalidFunctionError("makeString_2C", 2) - - val tests: Tests = Tests { - test("RIDE-194. makeString_2C function should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, makeString_2C), - (randomStringArrayElement, stringList, makeString_2CArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, V6) - } - } - - test("RIDE-195. makeString_2C function should throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function, error) <- Seq( - (randomStringArrayElement, stringList, invalidMakeString_2CFunction, invalidErrorMakeString_2C), - (randomIssuesArrayElement, stringList, makeString_2C, nonMatchingTypes("String")), - (randomInt.toString, stringList, makeString_2CArgBeforeFunc, nonMatchingTypes("String")), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, V6, error) - } - } - - test("RIDE-196. Can't find a function makeString_2C for RIDE versions V3 - V5") { - for (version <- testData.versionsWithoutV6) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, stringList, makeString_2C), - (randomStringArrayElement, stringList, makeString_2CArgBeforeFunc), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split.scala deleted file mode 100644 index ea89141ea13..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.splitFunctions - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, nonMatchingTypes} -import utest.{Tests, test} - -object Split extends JsTestBase { - private val split = "split(bar, foo)" - private val splitArgBeforeFunc = "bar.split(foo)" - private val invalidSplit = "split(foo)" - private val invalidSplitArgBeforeFunc = "foo.split(bar, foo)" - private val invalidErrorSplit = testData.invalidFunctionError("split", 2) - - val tests: Tests = Tests { - test("RIDE-200. split function should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, split), - (randomStringArrayElement, randomStringArrayElement, splitArgBeforeFunc), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-201. split function should throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (data, list, function, error) <- Seq( - (randomInt.toString, randomAliasDataArrayElement, splitArgBeforeFunc, nonMatchingTypes("String")), - (randomInt.toString, randomIssuesArrayElement, splitArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, randomStringArrayElement, invalidSplit, invalidErrorSplit), - (randomStringArrayElement, randomStringArrayElement, invalidSplitArgBeforeFunc, invalidErrorSplit), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_4C.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_4C.scala deleted file mode 100644 index 18d46e5fedb..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_4C.scala +++ /dev/null @@ -1,59 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.splitFunctions - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V6 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, nonMatchingTypes} -import utest.{Tests, test} - -object Split_4C extends JsTestBase { - private val split_4C = s"split_4C(bar, foo)" - private val split_4CArgBeforeFunc = s"bar.split_4C(foo)" - private val invalidSplit_4C = s"split_4C(foo)" - private val invalidErrorSplit_4C = testData.invalidFunctionError("split_4C", 2) - - val tests: Tests = Tests { - test("RIDE-202. split_4C function should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, split_4C), - (randomStringArrayElement, randomStringArrayElement, split_4CArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, V6) - } - } - - test("RIDE-203. split_4C function should throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function, error) <- Seq( - (randomIssuesArrayElement, randomStringArrayElement, split_4C, nonMatchingTypes("String")), - (randomInt.toString, randomStringArrayElement, split_4CArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, randomStringArrayElement, invalidSplit_4C, invalidErrorSplit_4C), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, V6, error) - } - } - - test("RIDE-204. Can't find a function split_4C for RIDE versions V3 - V5") { - for (version <- testData.versionsWithoutV6) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, split_4C), - (randomStringArrayElement, randomStringArrayElement, split_4CArgBeforeFunc), - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_51C.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_51C.scala deleted file mode 100644 index bf98dd1123a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/string/splitFunctions/Split_51C.scala +++ /dev/null @@ -1,59 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.string.splitFunctions - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V6 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomIssuesArrayElement, randomStringArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, nonMatchingTypes} -import utest.{Tests, test} - -object Split_51C extends JsTestBase { - private val split_51C = s"split_51C(bar, foo)" - private val split_51CArgBeforeFunc = s"bar.split_51C(foo)" - private val invalidSplit_51C = s"split_51C(foo)" - private val invalidErrorSplit_51C = testData.invalidFunctionError("split_51C", 2) - - val tests: Tests = Tests { - test("RIDE-205. split_51C function should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, split_51C), - (randomStringArrayElement, randomStringArrayElement, split_51CArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileSuccessDApp(script, V6) - } - } - - test("RIDE-206. split_51C function should throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("String", V6) - for ( - (data, list, function, error) <- Seq( - (randomIssuesArrayElement, randomStringArrayElement, split_51C, nonMatchingTypes("String")), - (randomInt.toString, randomStringArrayElement, split_51CArgBeforeFunc, nonMatchingTypes("String")), - (randomStringArrayElement, randomStringArrayElement, invalidSplit_51C, invalidErrorSplit_51C) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, V6, error) - } - } - - test("RIDE-207. Can't find a function split_4C for RIDE versions V3 - V5") { - for (version <- testData.versionsWithoutV6) { - val precondition = new GeneratorContractsForBuiltInFunctions("String", version) - for ( - (data, list, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, split_51C), - (randomStringArrayElement, randomStringArrayElement, split_51CArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(data, list, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Extract.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Extract.scala deleted file mode 100644 index 1b93d0a8602..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Extract.scala +++ /dev/null @@ -1,62 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.union - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, MATCHING_NOT_EXHAUSTIVE, actualVersionsWithoutV3, invalidFunctionError} -import utest.{Tests, test} - -object Extract extends JsTestBase { - private val extract = "extract(callerTestData)" - private val extractArgBeforeFunc = "callerTestData.extract()" - private val invalidExtract = "extract()" - private val invalidExtractArgBeforeFunc = "callerTestData.extract(callerTestData)" - - private val invalidErrorExtract = invalidFunctionError("extract", 1) - - val tests: Tests = Tests { - test("RIDE-225. function extract should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, function) <- Seq( - (randomInt.toString, extract), - (randomInt.toString, extractArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-226. function extract throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", V3) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, extract, MATCHING_NOT_EXHAUSTIVE), - (randomUnionArrayElement, extractArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE), - (randomInt.toString, invalidExtract, invalidErrorExtract), - (randomInt.toString, invalidExtractArgBeforeFunc, invalidErrorExtract), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, V3, error) - } - } - - test("RIDE-227. invalid extract functions for RIDE V4 - V6") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, extract), - (randomInt.toString, extractArgBeforeFunc), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/IsDefined.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/IsDefined.scala deleted file mode 100644 index ffe830d471b..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/IsDefined.scala +++ /dev/null @@ -1,55 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.union - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{MATCHING_NOT_EXHAUSTIVE, actualVersions, invalidFunctionError} -import utest.{Tests, test} - -object IsDefined extends JsTestBase { - private val isDefined = "isDefined(callerTestData)" - private val isDefinedArgBeforeFunc = "callerTestData.isDefined()" - private val invalidIsDefined = "isDefined()" - private val invalidIsDefinedArgBeforeFunc = "callerTestData.isDefined(callerTestData)" - private val invalidErrorIsDefined = invalidFunctionError("isDefined", 1) - - val tests: Tests = Tests { - test("RIDE-228. function isDefined should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomAddressDataArrayElement, isDefined), - (randomAliasDataArrayElement, isDefinedArgBeforeFunc), - (randomByteVectorArrayElement, isDefined), - (randomStringArrayElement, isDefinedArgBeforeFunc), - (randomUnionArrayElement, isDefined), - (randomDigestAlgorithmTypeArrayElement, isDefinedArgBeforeFunc), - (randomInt.toString, isDefined), - (randomBoolean.toString, isDefinedArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-229. function isDefined throw a compilation error for can't find overload") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, invalidIsDefined, MATCHING_NOT_EXHAUSTIVE), - (randomAddressDataArrayElement, invalidIsDefinedArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE), - (randomInt.toString, invalidIsDefined, invalidErrorIsDefined), - (randomInt.toString, invalidIsDefinedArgBeforeFunc, invalidErrorIsDefined) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Value.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Value.scala deleted file mode 100644 index 32188359a71..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/Value.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.union - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{MATCHING_NOT_EXHAUSTIVE, actualVersions, invalidFunctionError} -import utest.{Tests, test} - -object Value extends JsTestBase { - private val value = "value(callerTestData)" - private val valueArgBeforeFunc = "callerTestData.value()" - private val invalidValue = "value()" - private val invalidValueArgBeforeFunc = "callerTestData.value(callerTestData)" - private val invalidErrorValue = invalidFunctionError("value", 1) - - val tests: Tests = Tests { - test("RIDE-230. function value should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Int", version) - for ( - (data, function) <- Seq( - (randomInt.toString, value), - (randomInt.toString, valueArgBeforeFunc), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-231. function value throw a compilation error for can't find overload") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, value, MATCHING_NOT_EXHAUSTIVE), - (randomAddressDataArrayElement, valueArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE), - (randomInt.toString, invalidValue, invalidErrorValue), - (randomInt.toString, invalidValueArgBeforeFunc, invalidErrorValue), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrElse.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrElse.scala deleted file mode 100644 index c2ee0a090f3..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrElse.scala +++ /dev/null @@ -1,74 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.union - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomBoolean, - randomByteVectorArrayElement, - randomInt, - randomStringArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, CANT_MATCH_INFERRED_TYPE, actualVersionsWithoutV3, invalidFunctionError} -import utest.{Tests, test} - -object ValueOrElse extends JsTestBase { - private val valueOrElse = "valueOrElse(bar, foo)" - private val valueOrElseArgBeforeFunc = "bar.valueOrElse(foo)" - private val invalidValueOrElse = "valueOrElse(foo)" - private val invalidValueOrElseArgBeforeFunc = "foo.valueOrElse(foo, bar)" - private val invalidErrorValueOrElse = invalidFunctionError("valueOrElse", 2) - - val tests: Tests = Tests { - test("RIDE-232. function valueOrElse should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function) <- Seq( - (randomStringArrayElement, randomStringArrayElement, valueOrElse), - (randomInt.toString, randomInt.toString, valueOrElse), - (randomAliasDataArrayElement, randomAliasDataArrayElement, valueOrElse), - (randomAddressDataArrayElement, randomAddressDataArrayElement, valueOrElseArgBeforeFunc), - (randomByteVectorArrayElement, randomByteVectorArrayElement, valueOrElseArgBeforeFunc), - (randomBoolean.toString, randomBoolean.toString, valueOrElseArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-233. function valueOrElse throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("", version) - for ( - (firstData, secondData, function, error) <- Seq( - (randomInt.toString, randomByteVectorArrayElement, valueOrElse, CANT_MATCH_INFERRED_TYPE), - (randomInt.toString, randomStringArrayElement, valueOrElseArgBeforeFunc, CANT_MATCH_INFERRED_TYPE), - (randomStringArrayElement, randomStringArrayElement, invalidValueOrElse, invalidErrorValueOrElse), - (randomByteVectorArrayElement, randomByteVectorArrayElement, invalidValueOrElseArgBeforeFunc, invalidErrorValueOrElse) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-234. Can't find a function valueOrElse for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("", V3) - for ( - (firstData, secondData, function) <- Seq( - (randomAliasDataArrayElement, randomAliasDataArrayElement, valueOrElse), - (randomAddressDataArrayElement, randomAddressDataArrayElement, valueOrElseArgBeforeFunc) - ) - ) { - val script = precondition.simpleRideCode(firstData, secondData, function) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrErrorMessage.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrErrorMessage.scala deleted file mode 100644 index b5abfb1088c..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/union/ValueOrErrorMessage.scala +++ /dev/null @@ -1,61 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.union - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomAliasDataArrayElement, - randomBoolean, - randomByteVectorArrayElement, - randomInt, - randomStringArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{MATCHING_NOT_EXHAUSTIVE, actualVersions} -import utest.{Tests, test} - -object ValueOrErrorMessage extends JsTestBase { - private val valueOrErrorMessage = s"valueOrErrorMessage(callerTestData, \"error message\")" - private val valueOrErrorMessageArgBeforeFunction = s"callerTestData.valueOrErrorMessage(\"error message\")" - private val invalidValueOrErrorMessage = s"valueOrErrorMessage(callerTestData)" - private val invalidValueOrErrorMessageArgBeforeFunc = s"callerTestData.valueOrErrorMessage(callerTestData, \"error message\")" - private val valueOrErrorInvalidFunctionMessage = testData.invalidFunctionError("valueOrErrorMessage", 2) - - val tests: Tests = Tests { - test("RIDE-235. valueOrErrorMessage functions are compiled with valid data types.") { - for (version <- actualVersions) { - for ( - (dataType, firstData, function) <- Seq( - ("Int", randomInt.toString, valueOrErrorMessage), - ("Boolean", randomBoolean.toString, valueOrErrorMessage), - ("String", randomStringArrayElement, valueOrErrorMessage), - ("ByteVector", randomByteVectorArrayElement, valueOrErrorMessageArgBeforeFunction), - ("Address", randomAddressDataArrayElement, valueOrErrorMessageArgBeforeFunction), - ("Alias", randomAliasDataArrayElement, valueOrErrorMessageArgBeforeFunction) - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(firstData, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-236. valueOrErrorMessage function should throw a compilation error for invalid data.") { - for (version <- actualVersions) { - for ( - (dataType, firstData, function, error) <- Seq( - ("Alias", randomAddressDataArrayElement, valueOrErrorMessage, MATCHING_NOT_EXHAUSTIVE), - ("String", randomUnionArrayElement, valueOrErrorMessageArgBeforeFunction, MATCHING_NOT_EXHAUSTIVE), - ("String", randomStringArrayElement, invalidValueOrErrorMessage, valueOrErrorInvalidFunctionMessage), - ("ByteVector", randomByteVectorArrayElement, invalidValueOrErrorMessageArgBeforeFunc, valueOrErrorInvalidFunctionMessage) - ) - ) { - val precondition = new GeneratorContractsForBuiltInFunctions(dataType, version) - val script = precondition.onlyMatcherContract(firstData, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Bn256Groth16Verify.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Bn256Groth16Verify.scala deleted file mode 100644 index c0be40ec392..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Bn256Groth16Verify.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object Bn256Groth16Verify extends JsTestBase { - private val bn256Groth16Verify = s"bn256Groth16Verify(callerTestData, callerTestData, callerTestData)" - private val bn256Groth16VerifyArgBeforeFunc = s"callerTestData.bn256Groth16Verify(callerTestData, callerTestData)" - private val invalidBn256Groth16Verify = "bn256Groth16Verify()" - private val invalidBn256Groth16VerifyArgBeforeFunc = "callerTestData.bn256Groth16Verify(callerTestData)" - private val invalidErrorBn256Groth16Verify = testData.invalidFunctionError("bn256Groth16Verify", 3) - - val tests: Tests = Tests { - test("RIDE-265. bn256Groth16Verify function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, bn256Groth16Verify), - (randomByteVectorArrayElement, bn256Groth16VerifyArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-266. bn256Groth16Verify function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, bn256Groth16Verify, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, bn256Groth16VerifyArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidBn256Groth16Verify, invalidErrorBn256Groth16Verify), - (randomByteVectorArrayElement, invalidBn256Groth16VerifyArgBeforeFunc, invalidErrorBn256Groth16Verify) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-267. Can't find a function bn256Groth16Verify") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, bn256Groth16Verify) - assertCompileErrorDApp(script, V3, testData.CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CheckMerkleProof.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CheckMerkleProof.scala deleted file mode 100644 index 979ca4f5b1c..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CheckMerkleProof.scala +++ /dev/null @@ -1,62 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, MATCHING_NOT_EXHAUSTIVE} -import utest.{Tests, test} - -object CheckMerkleProof extends JsTestBase { - private val checkMerkleProof = "checkMerkleProof(callerTestData, callerTestData, callerTestData)" - private val checkMerkleProofArgBeforeFunc = "callerTestData.checkMerkleProof(callerTestData, callerTestData)" - private val invalidCheckMerkleProof = "checkMerkleProof()" - private val invalidCheckMerkleProofArgBeforeFunc = "callerTestData.checkMerkleProof(callerTestData)" - - private val invalidErrorCheckMerkleProof = testData.invalidFunctionError("checkMerkleProof", 3) - - val tests: Tests = Tests { - test("RIDE-268. checkMerkleProof function should compile for valid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, checkMerkleProof), - (randomByteVectorArrayElement, checkMerkleProofArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, V3) - } - } - - test("RIDE-269. checkMerkleProof function should throw a compilation error for invalid data") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, checkMerkleProof, MATCHING_NOT_EXHAUSTIVE), - (randomAddressDataArrayElement, checkMerkleProofArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE), - (randomByteVectorArrayElement, invalidCheckMerkleProof, invalidErrorCheckMerkleProof), - (randomByteVectorArrayElement, invalidCheckMerkleProofArgBeforeFunc, invalidErrorCheckMerkleProof) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, V3, error) - } - } - - test("RIDE-270. Can't find a function checkMerkleProof") { - for (version <- testData.actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, checkMerkleProof), - (randomByteVectorArrayElement, checkMerkleProofArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CreateMerkleRoot.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CreateMerkleRoot.scala deleted file mode 100644 index 028eaefd6a6..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/CreateMerkleRoot.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object CreateMerkleRoot extends JsTestBase { - private val createMerkleRoot = s"createMerkleRoot([callerTestData], callerTestData, $randomInt)" - private val createMerkleRootArgBeforeFunc = s"[callerTestData].createMerkleRoot(callerTestData, $randomInt)" - private val invalidCreateMerkleRoot = "createMerkleRoot()" - private val invalidCreateMerkleRootArgBeforeFunc = "[callerTestData].createMerkleRoot(callerTestData)" - private val invalidErrorCreateMerkleRoot = invalidFunctionError("createMerkleRoot", 3) - - val tests: Tests = Tests { - test("RIDE-271. createMerkleRoot function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, createMerkleRoot), - (randomByteVectorArrayElement, createMerkleRootArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-272. createMerkleRoot function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, createMerkleRoot, nonMatchingTypes("List[ByteVector]")), - (randomAddressDataArrayElement, createMerkleRootArgBeforeFunc, nonMatchingTypes("List[ByteVector]")), - (randomByteVectorArrayElement, invalidCreateMerkleRoot, invalidErrorCreateMerkleRoot), - (randomByteVectorArrayElement, invalidCreateMerkleRootArgBeforeFunc, invalidErrorCreateMerkleRoot), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-273. Can't find a function createMerkleRoot") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, createMerkleRoot) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Ecrecover.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Ecrecover.scala deleted file mode 100644 index 6a1fefd7c79..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Ecrecover.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object Ecrecover extends JsTestBase { - private val ecrecover = "ecrecover(callerTestData, callerTestData)" - private val ecrecoverArgBeforeFunc = "callerTestData.ecrecover(callerTestData)" - private val invalidEcrecover = "ecrecover()" - private val invalidEcrecoverArgBeforeFunc = "callerTestData.ecrecover()" - private val invalidErrorEcrecover = invalidFunctionError("ecrecover", 2) - - val tests: Tests = Tests { - test("RIDE-274. ecrecover function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, ecrecover), - (randomByteVectorArrayElement, ecrecoverArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-275. ecrecover function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, ecrecover, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, ecrecoverArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidEcrecover, invalidErrorEcrecover), - (randomByteVectorArrayElement, invalidEcrecoverArgBeforeFunc, invalidErrorEcrecover), - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-276. Can't find a function ecrecover") { - val precondition = new GeneratorContractsForBuiltInFunctions("ByteVector", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, ecrecover) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Groth16Verify.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Groth16Verify.scala deleted file mode 100644 index 91236b8e4bd..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/Groth16Verify.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object Groth16Verify extends JsTestBase { - private val groth16Verify = "groth16Verify(callerTestData, callerTestData, callerTestData)" - private val groth16VerifyArgBeforeFunc = "callerTestData.groth16Verify(callerTestData, callerTestData)" - private val invalidGroth16Verify = "groth16Verify()" - private val invalidGroth16VerifyArgBeforeFunc = "callerTestData.groth16Verify()" - private val invalidErrorGroth16Verify = invalidFunctionError("groth16Verify", 3) - - val tests: Tests = Tests { - test("RIDE-277. groth16Verify function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, groth16Verify), - (randomByteVectorArrayElement, groth16VerifyArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-278. groth16Verify function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, groth16Verify, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, groth16VerifyArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidGroth16Verify, invalidErrorGroth16Verify), - (randomByteVectorArrayElement, invalidGroth16VerifyArgBeforeFunc, invalidErrorGroth16Verify) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-279. Can't find a function groth16Verify") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, groth16Verify) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify.scala deleted file mode 100644 index 0f3bf398b2a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify.scala +++ /dev/null @@ -1,54 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.rsaVerify - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, invalidFunctionError, nonMatchingTypes} -import utest.{Tests, test} - -object RsaVerify extends JsTestBase { - private val rsaVerify = s"rsaVerify($randomDigestAlgorithmTypeArrayElement, callerTestData, callerTestData, callerTestData)" - private val rsaVerifyArgBeforeFunc = s"$randomDigestAlgorithmTypeArrayElement.rsaVerify(callerTestData, callerTestData, callerTestData)" - private val invalidRsaVerify = s"rsaVerify()" - private val invalidRsaVerifyArgBeforeFunc = s"callerTestData.rsaVerify(callerTestData)" - private val invalidErrorRsaVerify = invalidFunctionError("rsaVerify", 4) - - val tests: Tests = Tests { - test("RIDE-237. function rsaVerify should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, rsaVerify), - (randomByteVectorArrayElement, rsaVerifyArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-238. function rsaVerify throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, rsaVerify, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, rsaVerifyArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidRsaVerify, invalidErrorRsaVerify), - (randomByteVectorArrayElement, invalidRsaVerifyArgBeforeFunc, invalidErrorRsaVerify) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_128Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_128Kb.scala deleted file mode 100644 index 7e570891524..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_128Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.rsaVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object RsaVerify_128Kb extends JsTestBase { - private val rsaVerify_128Kb = s"rsaVerify_128Kb($randomDigestAlgorithmTypeArrayElement, callerTestData, callerTestData, callerTestData)" - private val rsaVerify_128KbArgBeforeFunc = s"$randomDigestAlgorithmTypeArrayElement.rsaVerify_128Kb(callerTestData, callerTestData, callerTestData)" - private val invalidRsaVerify_128Kb = "rsaVerify_128Kb()" - private val invalidRsaVerify_128KbArgBeforeFunc = "callerTestData.rsaVerify_128Kb(callerTestData)" - private val invalidErrorRsaVerify_128Kb = testData.invalidFunctionError("rsaVerify_128Kb", 4) - - val tests: Tests = Tests { - test("RIDE-248. rsaVerify_128Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, rsaVerify_128Kb), - (randomByteVectorArrayElement, rsaVerify_128KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-249. rsaVerify_128Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, rsaVerify_128Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, rsaVerify_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidRsaVerify_128Kb, invalidErrorRsaVerify_128Kb), - (randomByteVectorArrayElement, invalidRsaVerify_128KbArgBeforeFunc, invalidErrorRsaVerify_128Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-250. Can't find a function rsaVerify_128Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, rsaVerify_128Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_16Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_16Kb.scala deleted file mode 100644 index 4fa1ae3db02..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_16Kb.scala +++ /dev/null @@ -1,61 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.rsaVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object RsaVerify_16Kb extends JsTestBase { - private val rsaVerify_16Kb = s"rsaVerify_16Kb($randomDigestAlgorithmTypeArrayElement, callerTestData, callerTestData, callerTestData)" - private val rsaVerify_16KbArgBeforeFunc = s"$randomDigestAlgorithmTypeArrayElement.rsaVerify_16Kb(callerTestData, callerTestData, callerTestData)" - private val invalidRsaVerify_16Kb = "rsaVerify_16Kb()" - private val invalidRsaVerify_16KbArgBeforeFunc = "callerTestData.rsaVerify_16Kb(callerTestData)" - private val invalidErrorRsaVerify_16Kb = testData.invalidFunctionError("rsaVerify_16Kb", 4) - - val tests: Tests = Tests { - test("RIDE-239. rsaVerify_16Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, rsaVerify_16Kb), - (randomByteVectorArrayElement, rsaVerify_16KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-240. rsaVerify_16Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, rsaVerify_16Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, rsaVerify_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidRsaVerify_16Kb, invalidErrorRsaVerify_16Kb), - (randomByteVectorArrayElement, invalidRsaVerify_16KbArgBeforeFunc, invalidErrorRsaVerify_16Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-241. Can't find a function makeString_2C for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, rsaVerify_16Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_32Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_32Kb.scala deleted file mode 100644 index bead03df1c1..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_32Kb.scala +++ /dev/null @@ -1,61 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.rsaVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{ - randomAddressDataArrayElement, - randomByteVectorArrayElement, - randomDigestAlgorithmTypeArrayElement, - randomUnionArrayElement -} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object RsaVerify_32Kb extends JsTestBase { - private val rsaVerify_32Kb = s"rsaVerify_32Kb($randomDigestAlgorithmTypeArrayElement, callerTestData, callerTestData, callerTestData)" - private val rsaVerify_32KbArgBeforeFunc = s"$randomDigestAlgorithmTypeArrayElement.rsaVerify_32Kb(callerTestData, callerTestData, callerTestData)" - private val invalidRsaVerify_32Kb = "rsaVerify_32Kb()" - private val invalidRsaVerify_32KbArgBeforeFunc = "callerTestData.rsaVerify_32Kb(callerTestData)" - private val invalidErrorRsaVerify_32Kb = testData.invalidFunctionError("rsaVerify_32Kb", 4) - - val tests: Tests = Tests { - test("RIDE-242. rsaVerify_32Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, rsaVerify_32Kb), - (randomByteVectorArrayElement, rsaVerify_32KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-243. rsaVerify_32Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, rsaVerify_32Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, rsaVerify_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidRsaVerify_32Kb, invalidErrorRsaVerify_32Kb), - (randomByteVectorArrayElement, invalidRsaVerify_32KbArgBeforeFunc, invalidErrorRsaVerify_32Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-244. Can't find a function rsaVerify_32Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, rsaVerify_32Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_64Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_64Kb.scala deleted file mode 100644 index 38cb333e73a..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/rsaVerify/RsaVerify_64Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.rsaVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object RsaVerify_64Kb extends JsTestBase { - private val rsaVerify_64Kb = s"rsaVerify_64Kb($randomDigestAlgorithmTypeArrayElement, callerTestData, callerTestData, callerTestData)" - private val rsaVerify_64KbArgBeforeFunc = s"$randomDigestAlgorithmTypeArrayElement.rsaVerify_64Kb(callerTestData, callerTestData, callerTestData)" - private val invalidRsaVerify_64Kb = "rsaVerify_64Kb()" - private val invalidRsaVerify_64KbArgBeforeFunc = "callerTestData.rsaVerify_64Kb(callerTestData)" - private val invalidErrorRsaVerify_64Kb = testData.invalidFunctionError("rsaVerify_64Kb", 4) - - val tests: Tests = Tests { - test("RIDE-245. rsaVerify_64Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, rsaVerify_64Kb), - (randomByteVectorArrayElement, rsaVerify_64KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-246. rsaVerify_64Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, rsaVerify_64Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, rsaVerify_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidRsaVerify_64Kb, invalidErrorRsaVerify_64Kb), - (randomByteVectorArrayElement, invalidRsaVerify_64KbArgBeforeFunc, invalidErrorRsaVerify_64Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-247. Can't find a function rsaVerify_64Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, rsaVerify_64Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify.scala deleted file mode 100644 index e9bb733dd09..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.sigVerify - -import com.wavesplatform.JsTestBase -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{actualVersions, nonMatchingTypes} -import utest.{Tests, test} - -object SigVerify extends JsTestBase { - private val sigVerify = s"sigVerify(callerTestData, callerTestData, callerTestData)" - private val sigVerifyArgBeforeFunc = s"callerTestData.sigVerify(callerTestData, callerTestData)" - private val invalidSigVerify = s"sigVerify()" - private val invalidSigVerifyArgBeforeFunc = s"callerTestData.sigVerify(callerTestData)" - private val invalidErrorSigVerify = testData.invalidFunctionError("sigVerify", 3) - - val tests: Tests = Tests { - test("RIDE-251. function sigVerify should compile for valid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sigVerify), - (randomByteVectorArrayElement, sigVerifyArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-252. function rsaVerify throw a compilation error for invalid data") { - for (version <- actualVersions) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sigVerify, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sigVerifyArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSigVerify, invalidErrorSigVerify), - (randomByteVectorArrayElement, invalidSigVerifyArgBeforeFunc, invalidErrorSigVerify) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_128Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_128Kb.scala deleted file mode 100644 index f4630cdc82e..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_128Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.sigVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object SigVerify_128Kb extends JsTestBase { - private val sigVerify_128Kb = s"sigVerify_128Kb(callerTestData, callerTestData, callerTestData)" - private val sigVerify_128KbArgBeforeFunc = s"callerTestData.sigVerify_128Kb(callerTestData, callerTestData)" - private val invalidSigVerify_128Kb = "sigVerify_128Kb()" - private val invalidSigVerify_128KbArgBeforeFunc = "callerTestData.sigVerify_128Kb(callerTestData)" - private val invalidErrorSigVerify_128Kb = testData.invalidFunctionError("sigVerify_128Kb", 3) - - val tests: Tests = Tests { - test("RIDE-262. sigVerify_128Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sigVerify_128Kb), - (randomByteVectorArrayElement, sigVerify_128KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-263. sigVerify_128Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sigVerify_128Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sigVerify_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSigVerify_128Kb, invalidErrorSigVerify_128Kb), - (randomByteVectorArrayElement, invalidSigVerify_128KbArgBeforeFunc, invalidErrorSigVerify_128Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-264. Can't find a function sigVerify_128Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, sigVerify_128Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_16Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_16Kb.scala deleted file mode 100644 index 324e0b1fb27..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_16Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.sigVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object SigVerify_16Kb extends JsTestBase { - private val sigVerify_16Kb = s"sigVerify_16Kb(callerTestData, callerTestData, callerTestData)" - private val sigVerify_16KbArgBeforeFunc = s"callerTestData.sigVerify_16Kb(callerTestData, callerTestData)" - private val invalidSigVerify_16Kb = "sigVerify_16Kb()" - private val invalidSigVerify_16KbArgBeforeFunc = "callerTestData.sigVerify_16Kb(callerTestData)" - private val invalidErrorSigVerify_16Kb = testData.invalidFunctionError("sigVerify_16Kb", 3) - - val tests: Tests = Tests { - test("RIDE-253. sigVerify_16Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sigVerify_16Kb), - (randomByteVectorArrayElement, sigVerify_16KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-254. sigVerify_16Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sigVerify_16Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sigVerify_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSigVerify_16Kb, invalidErrorSigVerify_16Kb), - (randomByteVectorArrayElement, invalidSigVerify_16KbArgBeforeFunc, invalidErrorSigVerify_16Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-255. Can't find a function sigVerify_16Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, sigVerify_16Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_32Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_32Kb.scala deleted file mode 100644 index 8faf82e8041..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_32Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.sigVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object SigVerify_32Kb extends JsTestBase { - private val sigVerify_32Kb = s"sigVerify_32Kb(callerTestData, callerTestData, callerTestData)" - private val sigVerify_32KbArgBeforeFunc = s"callerTestData.sigVerify_32Kb(callerTestData, callerTestData)" - private val invalidSigVerify_32Kb = "sigVerify_32Kb()" - private val invalidSigVerify_32KbArgBeforeFunc = "callerTestData.sigVerify_32Kb(callerTestData)" - private val invalidErrorSigVerify_32Kb = testData.invalidFunctionError("sigVerify_32Kb", 3) - - val tests: Tests = Tests { - test("RIDE-256. sigVerify_32Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sigVerify_32Kb), - (randomByteVectorArrayElement, sigVerify_32KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-257. sigVerify_32Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sigVerify_32Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sigVerify_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSigVerify_32Kb, invalidErrorSigVerify_32Kb), - (randomByteVectorArrayElement, invalidSigVerify_32KbArgBeforeFunc, invalidErrorSigVerify_32Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-258. Can't find a function sigVerify_32Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, sigVerify_32Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_64Kb.scala b/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_64Kb.scala deleted file mode 100644 index df1629ec375..00000000000 --- a/lang/tests-js/src/test/scala/com/wavesplatform/test/builtInFunctions/verification/sigVerify/SigVerify_64Kb.scala +++ /dev/null @@ -1,56 +0,0 @@ -package com.wavesplatform.test.builtInFunctions.verification.sigVerify - -import com.wavesplatform.JsTestBase -import com.wavesplatform.lang.directives.values.V3 -import testHelpers.GeneratorContractsForBuiltInFunctions -import testHelpers.RandomDataGenerator.{randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement} -import testHelpers.TestDataConstantsAndMethods.{CANT_FIND_FUNCTION, actualVersionsWithoutV3, nonMatchingTypes} -import utest.{Tests, test} - -object SigVerify_64Kb extends JsTestBase { - private val sigVerify_64Kb = s"sigVerify_64Kb(callerTestData, callerTestData, callerTestData)" - private val sigVerify_64KbArgBeforeFunc = s"callerTestData.sigVerify_64Kb(callerTestData, callerTestData)" - private val invalidSigVerify_64Kb = "sigVerify_64Kb()" - private val invalidSigVerify_64KbArgBeforeFunc = "callerTestData.sigVerify_64Kb(callerTestData)" - private val invalidErrorSigVerify_64Kb = testData.invalidFunctionError("sigVerify_64Kb", 3) - - val tests: Tests = Tests { - test("RIDE-259. sigVerify_64Kb function should compile for valid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function) <- Seq( - (randomByteVectorArrayElement, sigVerify_64Kb), - (randomByteVectorArrayElement, sigVerify_64KbArgBeforeFunc) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileSuccessDApp(script, version) - } - } - } - - test("RIDE-260. sigVerify_64Kb function should throw a compilation error for invalid data") { - for (version <- actualVersionsWithoutV3) { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", version) - for ( - (data, function, error) <- Seq( - (randomUnionArrayElement, sigVerify_64Kb, nonMatchingTypes("ByteVector")), - (randomAddressDataArrayElement, sigVerify_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")), - (randomByteVectorArrayElement, invalidSigVerify_64Kb, invalidErrorSigVerify_64Kb), - (randomByteVectorArrayElement, invalidSigVerify_64KbArgBeforeFunc, invalidErrorSigVerify_64Kb) - ) - ) { - val script = precondition.onlyMatcherContract(data, function) - assertCompileErrorDApp(script, version, error) - } - } - } - - test("RIDE-261. Can't find a function sigVerify_64Kb for RIDE V3") { - val precondition = new GeneratorContractsForBuiltInFunctions("Boolean", V3) - val script = precondition.onlyMatcherContract(randomByteVectorArrayElement, sigVerify_64Kb) - assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) - } - } -} diff --git a/lang/tests-js/src/test/scala/testHelpers/GeneratorContractsForBuiltInFunctions.scala b/lang/tests-js/src/test/scala/testHelpers/GeneratorContractsForBuiltInFunctions.scala deleted file mode 100644 index 8a98a43b815..00000000000 --- a/lang/tests-js/src/test/scala/testHelpers/GeneratorContractsForBuiltInFunctions.scala +++ /dev/null @@ -1,151 +0,0 @@ -package testHelpers - -import com.wavesplatform.lang.directives.values.{StdLibVersion, V3} - -class GeneratorContractsForBuiltInFunctions(val dataType: String, libVersion: StdLibVersion) { - - def codeFromMatchingAndCase(testData: String, function: String, testDataForV3: String, testDataForGreaterV3: String): String = { - val caseForVersion = caseForVersions(testDataForV3, testDataForGreaterV3) - s"""\n - |@Callable(i) - | func expression() = { - | let callerTestData = $testData - | let valueOrUnit = $function - | let throwMessage = "not $dataType" - | let val = match(valueOrUnit) { - | case b:$dataType => b - | case _ => throwMessage.throw() - | } - | $caseForVersion - | } - |""".stripMargin - } - - def codeOwnData(ownDataFunction: String, testDataForV3: String, testDataForGreaterV3: String): String = { - val caseForVersion = caseForVersions(testDataForV3, testDataForGreaterV3) - s"""\n - |@Callable(i) - | func expression() = { - | let valueOrUnit = $ownDataFunction - | let val = match(valueOrUnit) { - | case b:$dataType => b - | case _ => throw("not $dataType") - | } - | $caseForVersion - | } - |""".stripMargin - } - - def codeWithoutMatcher(testData: String, function: String, testDataForV3: String, testDataForGreaterV3: String): String = { - val caseForVersion = caseForVersions(testDataForV3, testDataForGreaterV3) - s"""\n - |@Callable(i) - | func expression() = { - | let callerTestData = $testData - | let val = $function - | $caseForVersion - | } - |""".stripMargin - } - - def codeOwnDataWithoutMatcher(ownDataFunction: String, caseForVersions: String): String = { - s"""\n - | @Callable(i) - | func expression() = { - | let val = $ownDataFunction - | $caseForVersions - | } - |""".stripMargin - } - - def onlyMatcherContract(testData: String, function: String): String = { - s"""\n - | let callerTestData = $testData - | let x = match $function { - | case h:$dataType => h - | case _ => throw("not $dataType") - | } - |""".stripMargin - } - - def simpleRideCode(foo: String, bar: String, testFunction: String): String = { - s"""\n - |let foo = $foo - |let bar = $bar - |let callerTestData = $testFunction - |""".stripMargin - } - - def codeForDAppInvocation(byteVector: String, payment: String, func: String): String = { - s"""\n - |func foo(dapp2: String, a: Int, key1: String, key2: String) = { - | let byteVector = $byteVector - | let payment = $payment - | strict res = $func - | match res { - | case r : Int => - | ( - | [ - | IntegerEntry(key1, r), - | IntegerEntry(key2, wavesBalance(addressFromStringValue(dapp2)).regular) - | ], - | unit - | ) - | case _ => throw("Incorrect invoke result") - | } - | } - | - | @Callable(i) - | func bar(a: Int) = { - | ( - | [ - | ScriptTransfer(i.caller, 100000000, unit) - | ], - | a * 2 - | ) - | } - |""".stripMargin - } - - def codeForAddressFromRecipient(addressOrAlias: String, func: String, address: String): String = { - s""" - |let addressOrAlias = $addressOrAlias; - | match (tx) { - | case t: TransferTransaction => $func == $address - | case _ => false - | } - |""".stripMargin - } - - def codeForCalculateAssetId(testData: String, function: String): String = { - s""" - |@Callable(inv) - | func issueAndId() = { - | let issue = $testData - | let id = $function - | ([issue])} - |""".stripMargin - } - - def codeForCalculateLeaseId(testData: String, function: String): String = { - s""" - |@Callable(i) - | func foo() = { - | let lease = Lease($testData, 100000000) - | let id = $function - | ([ - | lease, - | BinaryEntry("lease", id) - | ], unit) - | } - |""".stripMargin - } - - private def caseForVersions(testDataForV3: String, testDataForGreaterV3: String): String = { - if (libVersion.id > V3.id) { - testDataForGreaterV3 - } else { - testDataForV3 - } - } -} diff --git a/lang/tests-js/src/test/scala/testHelpers/RandomDataGenerator.scala b/lang/tests-js/src/test/scala/testHelpers/RandomDataGenerator.scala deleted file mode 100644 index 753bee07264..00000000000 --- a/lang/tests-js/src/test/scala/testHelpers/RandomDataGenerator.scala +++ /dev/null @@ -1,80 +0,0 @@ -package testHelpers - -import scala.collection.immutable.HashMap - -object RandomDataGenerator { - val rnd = new scala.util.Random - - val addressDataArray: Array[String] = Array( - "Address(base58'')", - "Address(base58'3MDaMwqLtwBGcJrTA5tstJfY95GqnNnDDAS')", - "Address(base58'3PDaScqLtwBGcJrTA5tstJfY95GqnNnLxGA')", - "Address(base58'3P3aScAJsxBGcJrTA5tstJfY95GqnNnHLGA')" - ) - - val aliasDataArray: Array[String] = Array( - "Alias(\"merry_1312@pro\")", - "Alias(\"four\")", - "Alias(\"1111this_alias_30@long-symbols\")", - "Alias(\"\")" - ) - - val byteVectorArray: Array[String] = Array( - "base16'52696465'", - "base58'8t38fWQhrYJsqxXtPpiRCEk1g5RJdq9bG5Rkr2N7mDFC'", - "base64'UmlkZQ=='" - ) - - val stringArray: Array[String] = Array( - "\"3P3aScAJsxBGcJrTA5tstJfY95GqnNnHLGAlsadjbf87\"", - "\"8t38fWQhrYJsqxXtPpiRCEk1g5RJdq9bG5Rkr2N7mDFC\"", - "\"3MDaMwqLtwBGcJrTA5tstJfY95GqnNnDDASmsakmd091\"", - "\"3P3aScAJsxBGGqnNnHLGAlsadjbf87\"", - "\"8t38fWQhrYJsqxXtPpiRasdiuh32he98ddr2N7\"", - "\"091\"" - ) - - val issuesArray: Array[String] = Array( - "Issue(\"superToken\", \"token for super humans\", 1000, 2, true)", - "Issue(\"trueToken\", \"real token in real life\", 5_000_000_000, 5, false)", - "Issue(\"oneMoreToken\", \"just one more token in this crypto world\", 1_500_000_000, 5, true)", - "Issue(\"assetForAll\", \"asset for all peoples\", 1_500_000_000, 5, true)" - ) - - val unionArray: Array[String] = Array("DOWN", "CEILING", "FLOOR", "HALFUP", "HALFEVEN") - - val digestAlgorithmTypeArray: Array[String] = Array( - "NOALG", - "MD5", - "SHA1", - "SHA224", - "SHA256", - "SHA384", - "SHA512", - "SHA3224", - "SHA3256", - "SHA3384", - "SHA3512" - ) - - def entryMap(key: String): String = { - val entryArray: HashMap[String, String] = HashMap( - "BinaryEntry" -> s"[BinaryEntry(\"key\", $randomByteVectorArrayElement)]", - "IntegerEntry" -> s"[IntegerEntry(\"key\", $randomInt)]", - "StringEntry" -> s"[StringEntry(\"key\", $randomStringArrayElement)]", - "BooleanEntry" -> s"[BooleanEntry(\"key\", $randomBoolean)]" - ) - entryArray(key) - } - - def dataEntryForTests(value: String) = s"[DataEntry(\"key\", $value)]" - def randomAddressDataArrayElement: String = addressDataArray(rnd.nextInt(addressDataArray.length)) - def randomAliasDataArrayElement: String = aliasDataArray(rnd.nextInt(aliasDataArray.length)) - def randomByteVectorArrayElement: String = byteVectorArray(rnd.nextInt(byteVectorArray.length)) - def randomStringArrayElement: String = stringArray(rnd.nextInt(stringArray.length)) - def randomIssuesArrayElement: String = issuesArray(rnd.nextInt(issuesArray.length)) - def randomUnionArrayElement: String = unionArray(rnd.nextInt(unionArray.length)) - def randomDigestAlgorithmTypeArrayElement: String = digestAlgorithmTypeArray(rnd.nextInt(digestAlgorithmTypeArray.length)) - def randomInt: Integer = rnd.nextInt(90000000) - def randomBoolean: Boolean = randomInt % 2 == 0 -} diff --git a/lang/tests-js/src/test/scala/testHelpers/TestDataConstantsAndMethods.scala b/lang/tests-js/src/test/scala/testHelpers/TestDataConstantsAndMethods.scala deleted file mode 100644 index 7e78c051367..00000000000 --- a/lang/tests-js/src/test/scala/testHelpers/TestDataConstantsAndMethods.scala +++ /dev/null @@ -1,68 +0,0 @@ -package testHelpers - -import com.wavesplatform.lang.directives.values.{StdLibVersion, V3, V4, V5, V6} -import testHelpers.RandomDataGenerator.entryMap - -object TestDataConstantsAndMethods { - val oldVersions: Iterable[StdLibVersion] = Seq(V3, V4) - val versionsSupportingTheNewFeatures: Iterable[StdLibVersion] = Seq(V5, V6) - val versionsWithoutV6: Iterable[StdLibVersion] = Seq(V3, V4, V5) - val actualVersionsWithoutV3: Iterable[StdLibVersion] = Seq(V4, V5, V6) - val actualVersions: Iterable[StdLibVersion] = Seq(V3, V4, V5, V6) - val CANT_FIND_A_FUNCTION_OVERLOAD = "Can't find a function overload" - val CANT_FIND_FUNCTION = "Can't find a function" - val CANT_MATCH_INFERRED_TYPE = "Can't match inferred types of T over" - val MATCHING_NOT_EXHAUSTIVE = "Matching not exhaustive:" - val UNDEFINED_TYPE = "Undefined type: `BigInt`" - val stringList = "[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\"]" - val intList = "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" - val thisVariable = "this" - - def nonMatchingTypes(expectType: String): String = { - s"Non-matching types: expected: $expectType" - } - - def invalidFunctionError(functionName: String, numberOfArguments: Integer): String = { - s"Function '$functionName' requires $numberOfArguments arguments" - } - - val binaryEntryForTests: String = entryMap("BinaryEntry") - val integerEntryForTests: String = entryMap("IntegerEntry") - val stringEntryForTests: String = entryMap("StringEntry") - val booleanEntryForTests: String = entryMap("BooleanEntry") - - val rideV3Result: String = - """ - |WriteSet([ - | DataEntry("dataType", val) - | ]) - |""".stripMargin - - val GreaterV3ResultBinaryEntry: String = - """ - |[ - | BinaryEntry("bin", val) - |] - |""".stripMargin - - val GreaterV3ResultBooleanEntry: String = - """ - |[ - | BooleanEntry("boolean", val) - |] - |""".stripMargin - - val GreaterV3ResultIntegerEntry: String = - """ - |[ - | IntegerEntry("integer", val) - |] - |""".stripMargin - - val GreaterV3ResultStringEntry: String = - """ - |[ - | StringEntry("String", val) - |] - |""".stripMargin -} diff --git a/repl/js/build.sbt b/repl/js/build.sbt index fe46876562d..5f1ac3e544c 100644 --- a/repl/js/build.sbt +++ b/repl/js/build.sbt @@ -2,4 +2,8 @@ scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) } -Compile / fullOptJS / artifactPath := baseDirectory.value / "dist" / "repl.js" +// Link the combined RIDE compiler+repl module straight into the @waves/ride-js bundle +// (no copy step). repl-js is the superset that re-exports every @JSExportTopLevel from +// lang-js as well, so this single artifact is exactly what the npm package ships. +Compile / fastOptJS / artifactPath := (ThisBuild / baseDirectory).value / "ride-js-bundle" / "scalajs" / "ride-scalajs.js" +Compile / fullOptJS / artifactPath := (ThisBuild / baseDirectory).value / "ride-js-bundle" / "scalajs" / "ride-scalajs.js" diff --git a/repl/js/package.json b/repl/js/package.json deleted file mode 100644 index d0cf4077299..00000000000 --- a/repl/js/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@waves/ride-repl", - "version": "0.1.0-snapshot", - "description": "RIDE REPL", - "main": "dist/repl.js", - "module": "dist/repl.js", - "browser": "dist/repl.js", - "files": ["dist/"], - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/wavesplatform/Waves" - } -} diff --git a/ride-js-bundle/.gitignore b/ride-js-bundle/.gitignore new file mode 100644 index 00000000000..3fbb6993f57 --- /dev/null +++ b/ride-js-bundle/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +scalajs/ +.pnpm-store/ diff --git a/ride-js-bundle/package.json b/ride-js-bundle/package.json new file mode 100644 index 00000000000..8c89fd85007 --- /dev/null +++ b/ride-js-bundle/package.json @@ -0,0 +1,53 @@ +{ + "name": "@waves/ride-js", + "version": "2.3.0", + "description": "Js compiler for Ride - Waves smart contract language.", + "packageManager": "pnpm@11.5.2", + "main": "dist/index.js", + "typings": "src/index.d.ts", + "types": "src/index.d.ts", + "scripts": { + "build:ts": "tsc", + "build:browser": "webpack --config webpack.config.js", + "build": "npm run build:ts && npm run build:browser", + "pretest": "npm run build:ts", + "test": "vitest run", + "test:watch": "vitest", + "prepublishOnly": "npm run build" + }, + "files": [ + "/dist", + "/scalajs/ride-scalajs.js", + "/src/index.d.ts" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/wavesplatform/Waves.git" + }, + "keywords": [ + "compiler", + "waves", + "ride", + "smart", + "contracts" + ], + "author": "Waves Team", + "license": "MIT", + "bugs": { + "url": "https://github.com/wavesplatform/Waves/issues" + }, + "homepage": "https://github.com/wavesplatform/Waves#readme", + "devDependencies": { + "@types/node": "^22.10.0", + "typescript": "^5.9.3", + "vitest": "^3.0.0", + "webpack": "^5.105.4", + "webpack-cli": "^6.0.1", + "node-polyfill-webpack-plugin": "^4.1.0" + }, + "dependencies": { + "@waves/ts-lib-crypto": "^1.5.2", + "axios": "^1.13.6", + "buffer": "^6.0.3" + } +} diff --git a/ride-js-bundle/pnpm-lock.yaml b/ride-js-bundle/pnpm-lock.yaml new file mode 100644 index 00000000000..5889e36393f --- /dev/null +++ b/ride-js-bundle/pnpm-lock.yaml @@ -0,0 +1,3154 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +overrides: + serialize-javascript: ^7.0.3 + glob: ^13.0.6 + +importers: + + .: + dependencies: + '@waves/ts-lib-crypto': + specifier: ^1.5.2 + version: 1.5.2 + axios: + specifier: ^1.13.6 + version: 1.17.0 + buffer: + specifier: ^6.0.3 + version: 6.0.3 + devDependencies: + '@types/node': + specifier: ^22.10.0 + version: 22.19.19 + node-polyfill-webpack-plugin: + specifier: ^4.1.0 + version: 4.1.0(webpack@5.107.2) + typescript: + specifier: ^5.9.3 + version: 5.9.3 + vitest: + specifier: ^3.0.0 + version: 3.2.6(@types/node@22.19.19)(terser@5.48.0) + webpack: + specifier: ^5.105.4 + version: 5.107.2(webpack-cli@6.0.1) + webpack-cli: + specifier: ^6.0.1 + version: 6.0.1(webpack@5.107.2) + +packages: + + '@discoveryjs/json-ext@0.6.3': + resolution: {integrity: sha512-4B4OijXeVNOPZlYA2oEwWOTkzyltLao+xbotHQeqN++Rv27Y6s818+n2Qkp8q+Fxhn0t/5lA5X1Mxktud8eayQ==} + engines: {node: '>=14.17.0'} + + '@esbuild/aix-ppc64@0.27.7': + resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.27.7': + resolution: {integrity: sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.27.7': + resolution: {integrity: sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.27.7': + resolution: {integrity: sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.27.7': + resolution: {integrity: sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.27.7': + resolution: {integrity: sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.27.7': + resolution: {integrity: sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.27.7': + resolution: {integrity: sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.27.7': + resolution: {integrity: sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.27.7': + resolution: {integrity: sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.27.7': + resolution: {integrity: sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.27.7': + resolution: {integrity: sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.27.7': + resolution: {integrity: sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.27.7': + resolution: {integrity: sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.27.7': + resolution: {integrity: sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.27.7': + resolution: {integrity: sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.27.7': + resolution: {integrity: sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.27.7': + resolution: {integrity: sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.27.7': + resolution: {integrity: sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.27.7': + resolution: {integrity: sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.27.7': + resolution: {integrity: sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.27.7': + resolution: {integrity: sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.27.7': + resolution: {integrity: sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.27.7': + resolution: {integrity: sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.27.7': + resolution: {integrity: sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.27.7': + resolution: {integrity: sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/source-map@0.3.11': + resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==} + + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@noble/curves@2.2.0': + resolution: {integrity: sha512-T/BoHgFXirb0ENSPBquzX0rcjXeM6Lo892a2jlYJkqk83LqZx0l1Of7DzlKJ6jkpvMrkHSnAcgb5JegL8SeIkQ==} + engines: {node: '>= 20.19.0'} + + '@noble/hashes@2.2.0': + resolution: {integrity: sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==} + engines: {node: '>= 20.19.0'} + + '@rollup/rollup-android-arm-eabi@4.61.1': + resolution: {integrity: sha512-JnBB8MdXj45cajvTuO5FmPlvFVJRQgvrz1uSEl3NwqFnReAPGwb8EanbGi4z2nRaqLzjJSv5/JmycoTKlRZxHA==} + cpu: [arm] + os: [android] + + '@rollup/rollup-android-arm64@4.61.1': + resolution: {integrity: sha512-Jx2g7iSjw4AOT0HDPHM9RV3GNjRXwybWtSFZiZAYUTjUwjVrYIwq3kBf+LnhqJlzXFAqTAh2F7IGI+O568exPw==} + cpu: [arm64] + os: [android] + + '@rollup/rollup-darwin-arm64@4.61.1': + resolution: {integrity: sha512-0F1L/Z3Eqv8mT2n3dCpeO8GcTvHvVqkP5/t6DMsn0KzhYVcg+s7Ncl5DS8qjKYEeio6Az0Gt6nyBORay5qIlCA==} + cpu: [arm64] + os: [darwin] + + '@rollup/rollup-darwin-x64@4.61.1': + resolution: {integrity: sha512-qLttcH871ujY4YcVfUSShhOw+CsoTatYz8gRbHO7Bb92QH059/P0y5do1KMs41fY0BpD2x4AJH/gID0zFiqVKQ==} + cpu: [x64] + os: [darwin] + + '@rollup/rollup-freebsd-arm64@4.61.1': + resolution: {integrity: sha512-fUI4RapGE0Oh3mb8mgfvC1O2nU1RpDZUKnDQm3xB1Ipg7C2wTs5Kstz7G2uWK99a8S2yTMq8/P4uycwNa0nJyw==} + cpu: [arm64] + os: [freebsd] + + '@rollup/rollup-freebsd-x64@4.61.1': + resolution: {integrity: sha512-H5YrdvJaDtI/U9/emrD4b++xkvp3y/JvOe4rizHbxvkyMfRS/CiRYdji+Pl8D0brEaNFWUh1drQxgAGIl6Xudw==} + cpu: [x64] + os: [freebsd] + + '@rollup/rollup-linux-arm-gnueabihf@4.61.1': + resolution: {integrity: sha512-Q8CBCCQtDFrYtXoeUXSrnFXKOnyUhx6bz+SkL6A0E7V8kAiCJ5pamq1WtbfpVGhR5TSpXY6ak3avmDc5fHTyJA==} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-arm-musleabihf@4.61.1': + resolution: {integrity: sha512-nwnhk1581l0FBVellGcVCAT0Oi06onEA3WB53sf01VO3I0UPBkMH9sXONYME2K0ovXcNayJfNtHfm6mpJElatQ==} + cpu: [arm] + os: [linux] + libc: [musl] + + '@rollup/rollup-linux-arm64-gnu@4.61.1': + resolution: {integrity: sha512-x5Xr49hwt3hdW75UOZm3395YwwzPyauktslv29KpWL/T+vVAzoT3azLcTWv0eMciBNrx+DYjH4paehHoLpPvpg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-arm64-musl@4.61.1': + resolution: {integrity: sha512-unMS3H73DpaoPyyEVPjGKleM/s0mkmsauTENpw4INQY8y4+IuLNjkueQ5QCtC0D3N38Y38yhAU8OoZ20S2Tm6w==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rollup/rollup-linux-loong64-gnu@4.61.1': + resolution: {integrity: sha512-zNZzGRnAhwjFEYmvphJRV5XaQGjs62cCmeYYHUT//NbvEnHauw+I85nGG+SiVg5ld4GX8D1IbKIX+ozITQnhMQ==} + cpu: [loong64] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-loong64-musl@4.61.1': + resolution: {integrity: sha512-LdpWGL8X209B2SIvWjqlc8VZgM6PKfontSerGepuldQmHYrAOtnMCXeJkxXGbC+PPZVOuu5czJo7fNV6aeW8rQ==} + cpu: [loong64] + os: [linux] + libc: [musl] + + '@rollup/rollup-linux-ppc64-gnu@4.61.1': + resolution: {integrity: sha512-EC5kTtNaNGOmbMGqar8dvJy6y/hg99GAwjfBz++pxZhQATXGcRjd6c5en5wcbru0vkRmiMGsQKdMJOOf6sza4g==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-ppc64-musl@4.61.1': + resolution: {integrity: sha512-8hiwp6D4acEcNK78I4rP0/XtS1sknWIAMJBPdR4l6zUtyTm5KiTDr5bXmWt4foY7nAN7AThDHgkLIEZOWKbzWw==} + cpu: [ppc64] + os: [linux] + libc: [musl] + + '@rollup/rollup-linux-riscv64-gnu@4.61.1': + resolution: {integrity: sha512-10dh/h/BqA7DuMPWSxkR8uks18FRwnwOEqr5zOTEl+NOwP/OMzKX8OFR/Of9xxDA7D5qef1Nzar5WDD2kCCr1g==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-riscv64-musl@4.61.1': + resolution: {integrity: sha512-YKJ5lg35DP17gcAOggnihe+APw9HLyj1Xn7gsmGumBJAUDa6NGXNixJzmkWLhcK9TOuuyQjdamzvJefkO7qHZQ==} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@rollup/rollup-linux-s390x-gnu@4.61.1': + resolution: {integrity: sha512-Mlil5G2Jj6a7B3LWGctg+XPL9vdXYuzCtNXfxOQ0nPjc2m6ueUktocPGH9bnAM0bNRKb/bAWTujUU7IJQdQA+g==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-x64-gnu@4.61.1': + resolution: {integrity: sha512-bVWIOIk6pV01p4CdUbPP7CJ/434z+OooYjDuFcR+44N35YvKUC66G8MGnvcWx5mWKW3g61J+t74l3Kj15Kwn2Q==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rollup/rollup-linux-x64-musl@4.61.1': + resolution: {integrity: sha512-qy5pBvZbqNFheBz61R1rzsezjm0J7O2oNGoWtGoY89SZYLUfxAJTBAqDChqAIdB4rCiIbi9nF7yZ83GnNiLwSw==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rollup/rollup-openbsd-x64@4.61.1': + resolution: {integrity: sha512-E83TXjI4zm0+5f2qO+UOudaCYIhYwpJ5jq6YCZNIZ+6CbfhKrkAGezeiASBL9ElxAxFsRS9ZhESv8mfnj6TKeg==} + cpu: [x64] + os: [openbsd] + + '@rollup/rollup-openharmony-arm64@4.61.1': + resolution: {integrity: sha512-fbWnKqVkjrJN38vNe3ahkbk6iejS/3b0Nt7EEtPpE6RBacZcGXNKbzfHN3GUUlXOPghUg0j6XUGrtjX9z1sIvA==} + cpu: [arm64] + os: [openharmony] + + '@rollup/rollup-win32-arm64-msvc@4.61.1': + resolution: {integrity: sha512-ArMl38iVAbk0New1ogihQNY6iphLi4ZaRsa037gUzv5yeKPY8TD3Dmy4x2RNC1VztU/uqm+G+/RwFrSka3Oy2g==} + cpu: [arm64] + os: [win32] + + '@rollup/rollup-win32-ia32-msvc@4.61.1': + resolution: {integrity: sha512-0mYtjHS9ucAbcATycCNK9IGBk/cCe/ma7EmSLGZdsxnOA8cjRIyU04wDpVAD9NiOfLUR9KTxdiO53uOkherqjQ==} + cpu: [ia32] + os: [win32] + + '@rollup/rollup-win32-x64-gnu@4.61.1': + resolution: {integrity: sha512-gK1iCEPfpoSG9wfBihXxvBMi8ZfcWffYkEsC/Eih+iFENTaewvNcrEQ69lIOWYO5pePHKLHHO7nq5AILGO/HQQ==} + cpu: [x64] + os: [win32] + + '@rollup/rollup-win32-x64-msvc@4.61.1': + resolution: {integrity: sha512-X+zaP2x+j4RXGfbp/seSoRHWnPxzApilDszisZxbYH5C/jTxFhCtDNdPGZb9lJyYPs24wGxruPF7Y+sIXt9Gzw==} + cpu: [x64] + os: [win32] + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@types/node@22.19.19': + resolution: {integrity: sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew==} + + '@vitest/expect@3.2.6': + resolution: {integrity: sha512-1+7q9BtaKzEmO+fmNT3kYvoNn5Y71XWAx2Q5HRim4tTVRQVRv4uJFAQ5FbK0OPUeNP/WmVCpxYxoJdvuHVjzBQ==} + + '@vitest/mocker@3.2.6': + resolution: {integrity: sha512-EZOrpDbkKotFAP7wPAQV1UIyoGOk4oX7ynWhBhLB7v+meMHbQhU16oPpIYGTTe4oFlhpryGpgpcZP/sin3hYuw==} + peerDependencies: + msw: ^2.4.9 + vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/pretty-format@3.2.6': + resolution: {integrity: sha512-lb7XXXzmm2h2ASzFnRvQpDo6onT1NmMJA3tkGTWiBFtRJ9lxGY3d3mm/Apt36gej2bkkOVLL/yTOtufDaFa/jA==} + + '@vitest/runner@3.2.6': + resolution: {integrity: sha512-HYcoSj1w5tcgUnzoF0HcyaAQjpA1gj9ftUJ7iSJSuipc02jW9gKkigwZbjFldAfYHA1fa8UZVRftdMY5msWM9Q==} + + '@vitest/snapshot@3.2.6': + resolution: {integrity: sha512-H+ZjNTWGpObenh0YnlBctAPnJSI20P81PL8BPzWpx54YXLLTm8hEsWawtcYLMrwvpK48hGxLLbCS+1KRXhsKhw==} + + '@vitest/spy@3.2.6': + resolution: {integrity: sha512-oq6BbH68WzcWmwtBrU9nqLeaXTR4XwJF7FSLkKEZo4i6eoXcrxjcwSuTvWBIRUTC6VC72nXYunzqgZA+IKdtxg==} + + '@vitest/utils@3.2.6': + resolution: {integrity: sha512-lI23nIs4bnT3T8NIoh+vFaz5s2/DdP0Jgt2jxwgWljvwn82cLJtyi/If+fjFyoLMGIOz0U/fKvWE0d4jsNQEfg==} + + '@waves/ts-lib-crypto@1.5.2': + resolution: {integrity: sha512-lN7zmRdWLo3hRVnnrajb2WNJ0oZa3cDcI5w/J0/ycw9cy9NM/RhSISzXUDj18qFJe/quayQb2m9Y2Nk4JppODQ==} + + '@webassemblyjs/ast@1.14.1': + resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==} + + '@webassemblyjs/floating-point-hex-parser@1.13.2': + resolution: {integrity: sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==} + + '@webassemblyjs/helper-api-error@1.13.2': + resolution: {integrity: sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==} + + '@webassemblyjs/helper-buffer@1.14.1': + resolution: {integrity: sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==} + + '@webassemblyjs/helper-numbers@1.13.2': + resolution: {integrity: sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==} + + '@webassemblyjs/helper-wasm-bytecode@1.13.2': + resolution: {integrity: sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==} + + '@webassemblyjs/helper-wasm-section@1.14.1': + resolution: {integrity: sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==} + + '@webassemblyjs/ieee754@1.13.2': + resolution: {integrity: sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==} + + '@webassemblyjs/leb128@1.13.2': + resolution: {integrity: sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==} + + '@webassemblyjs/utf8@1.13.2': + resolution: {integrity: sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==} + + '@webassemblyjs/wasm-edit@1.14.1': + resolution: {integrity: sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==} + + '@webassemblyjs/wasm-gen@1.14.1': + resolution: {integrity: sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==} + + '@webassemblyjs/wasm-opt@1.14.1': + resolution: {integrity: sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==} + + '@webassemblyjs/wasm-parser@1.14.1': + resolution: {integrity: sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==} + + '@webassemblyjs/wast-printer@1.14.1': + resolution: {integrity: sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==} + + '@webpack-cli/configtest@3.0.1': + resolution: {integrity: sha512-u8d0pJ5YFgneF/GuvEiDA61Tf1VDomHHYMjv/wc9XzYj7nopltpG96nXN5dJRstxZhcNpV1g+nT6CydO7pHbjA==} + engines: {node: '>=18.12.0'} + peerDependencies: + webpack: ^5.82.0 + webpack-cli: 6.x.x + + '@webpack-cli/info@3.0.1': + resolution: {integrity: sha512-coEmDzc2u/ffMvuW9aCjoRzNSPDl/XLuhPdlFRpT9tZHmJ/039az33CE7uH+8s0uL1j5ZNtfdv0HkfaKRBGJsQ==} + engines: {node: '>=18.12.0'} + peerDependencies: + webpack: ^5.82.0 + webpack-cli: 6.x.x + + '@webpack-cli/serve@3.0.1': + resolution: {integrity: sha512-sbgw03xQaCLiT6gcY/6u3qBDn01CWw/nbaXl3gTdTFuJJ75Gffv3E3DBpgvY2fkkrdS1fpjaXNOmJlnbtKauKg==} + engines: {node: '>=18.12.0'} + peerDependencies: + webpack: ^5.82.0 + webpack-cli: 6.x.x + webpack-dev-server: '*' + peerDependenciesMeta: + webpack-dev-server: + optional: true + + '@xtuc/ieee754@1.2.0': + resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} + + '@xtuc/long@4.2.2': + resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==} + + acorn-import-phases@1.0.4: + resolution: {integrity: sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==} + engines: {node: '>=10.13.0'} + peerDependencies: + acorn: ^8.14.0 + + acorn@8.16.0: + resolution: {integrity: sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==} + engines: {node: '>=0.4.0'} + hasBin: true + + agent-base@6.0.2: + resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} + engines: {node: '>= 6.0.0'} + + ajv-formats@2.1.1: + resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + + ajv-keywords@5.1.0: + resolution: {integrity: sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==} + peerDependencies: + ajv: ^8.8.2 + + ajv@8.20.0: + resolution: {integrity: sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==} + + asn1.js@4.10.1: + resolution: {integrity: sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==} + + assert@2.1.0: + resolution: {integrity: sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + + available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} + engines: {node: '>= 0.4'} + + axios@1.17.0: + resolution: {integrity: sha512-J8SwNxprqqpbfenehxWYXE7CW+wM1BB4w3+N+g+/Wx40xM4rsLrfPmHHxSWIxJLYDgSY/HqlFPIYb2/S3rxafw==} + + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + baseline-browser-mapping@2.10.33: + resolution: {integrity: sha512-bA6+tcSLpz2tIEdDXZPpPTIuxBcC4+w6SieaYyfigIa4h8GlFxbA17v22Vx3JUtuZQj9SgOsnbK+aTBzyDyEuw==} + engines: {node: '>=6.0.0'} + hasBin: true + + bn.js@4.12.3: + resolution: {integrity: sha512-fGTi3gxV/23FTYdAoUtLYp6qySe2KE3teyZitipKNRuVYcBkoP/bB3guXN/XVKUe9mxCHXnc9C4ocyz8OmgN0g==} + + bn.js@5.2.3: + resolution: {integrity: sha512-EAcmnPkxpntVL+DS7bO1zhcZNvCkxqtkd0ZY53h06GNQ3DEkkGZ/gKgmDv6DdZQGj9BgfSPKtJJ7Dp1GPP8f7w==} + + brorand@1.1.0: + resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} + + browser-resolve@2.0.0: + resolution: {integrity: sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==} + + browserify-aes@1.2.0: + resolution: {integrity: sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==} + + browserify-cipher@1.0.1: + resolution: {integrity: sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==} + + browserify-des@1.0.2: + resolution: {integrity: sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==} + + browserify-rsa@4.1.1: + resolution: {integrity: sha512-YBjSAiTqM04ZVei6sXighu679a3SqWORA3qZTEqZImnlkDIFtKc6pNutpjyZ8RJTjQtuYfeetkxM11GwoYXMIQ==} + engines: {node: '>= 0.10'} + + browserify-sign@4.2.6: + resolution: {integrity: sha512-sd+Q65fjlWCYWtZKXiKfrUc8d+4jtp/8f0W2NkwzLtoW4bI6UDnWusLWIurHnmurW0XShIRxpwiOX4EoPtXUAg==} + engines: {node: '>= 0.10'} + + browserify-zlib@0.2.0: + resolution: {integrity: sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==} + + browserslist@4.28.2: + resolution: {integrity: sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + buffer-xor@1.0.3: + resolution: {integrity: sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==} + + buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + + builtin-status-codes@3.0.0: + resolution: {integrity: sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==} + + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + + call-bind-apply-helpers@1.0.2: + resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} + engines: {node: '>= 0.4'} + + call-bind@1.0.9: + resolution: {integrity: sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==} + engines: {node: '>= 0.4'} + + call-bound@1.0.4: + resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} + engines: {node: '>= 0.4'} + + caniuse-lite@1.0.30001793: + resolution: {integrity: sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA==} + + chai@5.3.3: + resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} + engines: {node: '>=18'} + + check-error@2.1.3: + resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==} + engines: {node: '>= 16'} + + chrome-trace-event@1.0.4: + resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} + engines: {node: '>=6.0'} + + cipher-base@1.0.7: + resolution: {integrity: sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA==} + engines: {node: '>= 0.10'} + + clone-deep@4.0.1: + resolution: {integrity: sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==} + engines: {node: '>=6'} + + colorette@2.0.20: + resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} + + combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + + commander@12.1.0: + resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} + engines: {node: '>=18'} + + commander@2.20.3: + resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + + console-browserify@1.2.0: + resolution: {integrity: sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==} + + constants-browserify@1.0.0: + resolution: {integrity: sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==} + + core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + + create-ecdh@4.0.4: + resolution: {integrity: sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==} + + create-hash@1.2.0: + resolution: {integrity: sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==} + + create-hmac@1.1.7: + resolution: {integrity: sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==} + + create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + crypto-browserify@3.12.1: + resolution: {integrity: sha512-r4ESw/IlusD17lgQi1O20Fa3qNnsckR126TdUuBgAu7GBYSIPvdNyONd3Zrxh0xCwA4+6w/TDArBPsMvhur+KQ==} + engines: {node: '>= 0.10'} + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + deep-eql@5.0.2: + resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} + engines: {node: '>=6'} + + define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + + define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + + delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + + des.js@1.1.0: + resolution: {integrity: sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==} + + diffie-hellman@5.0.3: + resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==} + + domain-browser@4.22.0: + resolution: {integrity: sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw==} + engines: {node: '>=10'} + + dunder-proto@1.0.1: + resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} + engines: {node: '>= 0.4'} + + electron-to-chromium@1.5.367: + resolution: {integrity: sha512-4Mk/mrynCNQ+atY40D3UpmhLWB6AHMbYMlIrPhHcMF6x0L7O0b052FCAsxw1LlaR++UFuNg3D/A6XCuGDa0guQ==} + + elliptic@6.6.1: + resolution: {integrity: sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==} + + enhanced-resolve@5.22.2: + resolution: {integrity: sha512-0rxICaFZ7NQho/sHely2bvOPRP0Eu2B0NZ9zM54YvRvWMn7jfz3DmnOZDR9LlXDdDcqntAVc6Hfy4gr/tdH/Ag==} + engines: {node: '>=10.13.0'} + + envinfo@7.21.0: + resolution: {integrity: sha512-Lw7I8Zp5YKHFCXL7+Dz95g4CcbMEpgvqZNNq3AmlT5XAV6CgAAk6gyAMqn2zjw08K9BHfcNuKrMiCPLByGafow==} + engines: {node: '>=4'} + hasBin: true + + es-define-property@1.0.1: + resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} + engines: {node: '>= 0.4'} + + es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + + es-module-lexer@1.7.0: + resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} + + es-module-lexer@2.1.0: + resolution: {integrity: sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==} + + es-object-atoms@1.1.2: + resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} + engines: {node: '>= 0.4'} + + es-set-tostringtag@2.1.0: + resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} + engines: {node: '>= 0.4'} + + esbuild@0.27.7: + resolution: {integrity: sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==} + engines: {node: '>=18'} + hasBin: true + + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + + eslint-scope@5.1.1: + resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} + engines: {node: '>=8.0.0'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@4.3.0: + resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} + + evp_bytestokey@1.0.3: + resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==} + + expect-type@1.3.0: + resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} + engines: {node: '>=12.0.0'} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-uri@3.1.2: + resolution: {integrity: sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==} + + fastest-levenshtein@1.0.16: + resolution: {integrity: sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==} + engines: {node: '>= 4.9.1'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + + flat@5.0.2: + resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} + hasBin: true + + follow-redirects@1.16.0: + resolution: {integrity: sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + + for-each@0.3.5: + resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} + engines: {node: '>= 0.4'} + + form-data@4.0.5: + resolution: {integrity: sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==} + engines: {node: '>= 6'} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + generator-function@2.0.1: + resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} + engines: {node: '>= 0.4'} + + get-intrinsic@1.3.0: + resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} + engines: {node: '>= 0.4'} + + get-proto@1.0.1: + resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} + engines: {node: '>= 0.4'} + + glob-to-regexp@0.4.1: + resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} + + gopd@1.2.0: + resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} + engines: {node: '>= 0.4'} + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} + + has-symbols@1.1.0: + resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} + engines: {node: '>= 0.4'} + + has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + + hash-base@3.0.5: + resolution: {integrity: sha512-vXm0l45VbcHEVlTCzs8M+s0VeYsB2lnlAaThoLKGXr3bE/VWDOelNUnycUPEhKEaXARL2TEFjBOyUiM6+55KBg==} + engines: {node: '>= 0.10'} + + hash-base@3.1.2: + resolution: {integrity: sha512-Bb33KbowVTIj5s7Ked1OsqHUeCpz//tPwR+E2zJgJKo9Z5XolZ9b6bdUgjmYlwnWhoOQKoTd1TYToZGn5mAYOg==} + engines: {node: '>= 0.8'} + + hash.js@1.1.7: + resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} + + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} + engines: {node: '>= 0.4'} + + hmac-drbg@1.0.1: + resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} + + https-browserify@1.0.0: + resolution: {integrity: sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==} + + https-proxy-agent@5.0.1: + resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} + engines: {node: '>= 6'} + + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + + import-local@3.2.0: + resolution: {integrity: sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==} + engines: {node: '>=8'} + hasBin: true + + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + interpret@3.1.1: + resolution: {integrity: sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==} + engines: {node: '>=10.13.0'} + + is-arguments@1.2.0: + resolution: {integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==} + engines: {node: '>= 0.4'} + + is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + + is-core-module@2.16.2: + resolution: {integrity: sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==} + engines: {node: '>= 0.4'} + + is-generator-function@1.1.2: + resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} + engines: {node: '>= 0.4'} + + is-nan@1.3.2: + resolution: {integrity: sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==} + engines: {node: '>= 0.4'} + + is-plain-object@2.0.4: + resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} + engines: {node: '>=0.10.0'} + + is-regex@1.2.1: + resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} + engines: {node: '>= 0.4'} + + is-typed-array@1.1.15: + resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} + engines: {node: '>= 0.4'} + + isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + + isarray@2.0.5: + resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + isobject@3.0.1: + resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} + engines: {node: '>=0.10.0'} + + isomorphic-timers-promises@1.0.1: + resolution: {integrity: sha512-u4sej9B1LPSxTGKB/HiuzvEQnXH0ECYkSVQU39koSwmFAxhlEAFl9RdTvLv4TOTQUgBS5O3O5fwUxk6byBZ+IQ==} + engines: {node: '>=10'} + + jest-worker@27.5.1: + resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} + engines: {node: '>= 10.13.0'} + + js-sha256@0.11.1: + resolution: {integrity: sha512-o6WSo/LUvY2uC4j7mO50a2ms7E/EAdbP0swigLV+nzHKTTaYnaLIWJ02VdXrsJX0vGedDESQnLsOekr94ryfjg==} + + js-sha3@0.9.3: + resolution: {integrity: sha512-BcJPCQeLg6WjEx3FE591wVAevlli8lxsxm9/FzV4HXkV49TmBH38Yvrpce6fjbADGMKFrBMGTqrVz3qPIZ88Gg==} + + js-tokens@9.0.1: + resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==} + + json-schema-traverse@1.0.0: + resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} + + kind-of@6.0.3: + resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} + engines: {node: '>=0.10.0'} + + loader-runner@4.3.2: + resolution: {integrity: sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==} + engines: {node: '>=6.11.5'} + + locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + loupe@3.2.1: + resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==} + + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + + math-intrinsics@1.1.0: + resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} + engines: {node: '>= 0.4'} + + md5.js@1.3.5: + resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} + + merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + + miller-rabin@4.0.1: + resolution: {integrity: sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==} + hasBin: true + + mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + mime-db@1.54.0: + resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==} + engines: {node: '>= 0.6'} + + mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + + minimalistic-assert@1.0.1: + resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} + + minimalistic-crypto-utils@1.0.1: + resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nanoid@3.3.12: + resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + neo-async@2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + + node-forge@1.4.0: + resolution: {integrity: sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==} + engines: {node: '>= 6.13.0'} + + node-polyfill-webpack-plugin@4.1.0: + resolution: {integrity: sha512-b4ei444EKkOagG/yFqojrD3QTYM5IOU1f8tn9o6uwrG4qL+brI7oVhjPVd0ZL2xy+Z6CP5bu9w8XTvlWgiXHcw==} + engines: {node: '>=14'} + peerDependencies: + webpack: '>=5' + + node-releases@2.0.47: + resolution: {integrity: sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og==} + engines: {node: '>=18'} + + node-stdlib-browser@1.3.1: + resolution: {integrity: sha512-X75ZN8DCLftGM5iKwoYLA3rjnrAEs97MkzvSd4q2746Tgpg8b8XWiBGiBG4ZpgcAqBgtgPHTiAc8ZMCvZuikDw==} + engines: {node: '>=10'} + + object-inspect@1.13.4: + resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} + engines: {node: '>= 0.4'} + + object-is@1.1.6: + resolution: {integrity: sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==} + engines: {node: '>= 0.4'} + + object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + + object.assign@4.1.7: + resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} + engines: {node: '>= 0.4'} + + os-browserify@0.3.0: + resolution: {integrity: sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==} + + p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + + pako@1.0.11: + resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} + + parse-asn1@5.1.9: + resolution: {integrity: sha512-fIYNuZ/HastSb80baGOuPRo1O9cf4baWw5WsAp7dBuUzeTD/BoaG8sVTdlPFksBE2lF21dN+A1AnrpIjSWqHHg==} + engines: {node: '>= 0.10'} + + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + pathval@2.0.1: + resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==} + engines: {node: '>= 14.16'} + + pbkdf2@3.1.6: + resolution: {integrity: sha512-BT6eelPB1EyGHo8pC0o9Bl6k6SYVhKO1jEbd3lcTrtr7XHdjP8BW1YpfCV3G9Kwkxgattk+S5q2/RvuttCsS1g==} + engines: {node: '>= 0.10'} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.4: + resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} + engines: {node: '>=12'} + + pkg-dir@4.2.0: + resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} + engines: {node: '>=8'} + + pkg-dir@5.0.0: + resolution: {integrity: sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==} + engines: {node: '>=10'} + + possible-typed-array-names@1.1.0: + resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} + engines: {node: '>= 0.4'} + + postcss@8.5.15: + resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==} + engines: {node: ^10 || ^12 || >=14} + + process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + + process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + + proxy-from-env@2.1.0: + resolution: {integrity: sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==} + engines: {node: '>=10'} + + public-encrypt@4.0.3: + resolution: {integrity: sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==} + + punycode@1.4.1: + resolution: {integrity: sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==} + + qs@6.15.2: + resolution: {integrity: sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==} + engines: {node: '>=0.6'} + + querystring-es3@0.2.1: + resolution: {integrity: sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==} + engines: {node: '>=0.4.x'} + + randombytes@2.1.0: + resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + + randomfill@1.0.4: + resolution: {integrity: sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==} + + readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + + readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + + rechoir@0.8.0: + resolution: {integrity: sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==} + engines: {node: '>= 10.13.0'} + + require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + + resolve-cwd@3.0.0: + resolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==} + engines: {node: '>=8'} + + resolve-from@5.0.0: + resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} + engines: {node: '>=8'} + + resolve@1.22.12: + resolution: {integrity: sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==} + engines: {node: '>= 0.4'} + hasBin: true + + ripemd160@2.0.3: + resolution: {integrity: sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA==} + engines: {node: '>= 0.8'} + + rollup@4.61.1: + resolution: {integrity: sha512-I4KW6iuRpuu2uHBLraZ1wNZe0DP7lnRha+VJ9tNaYVaVgKhW0aI3h4RYnoRPeql0flHm/Co55b7snEDcOfOJrA==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + + safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + safe-regex-test@1.1.0: + resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} + engines: {node: '>= 0.4'} + + schema-utils@4.3.3: + resolution: {integrity: sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA==} + engines: {node: '>= 10.13.0'} + + set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} + engines: {node: '>= 0.4'} + + setimmediate@1.0.5: + resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} + + sha.js@2.4.12: + resolution: {integrity: sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==} + engines: {node: '>= 0.10'} + hasBin: true + + shallow-clone@3.0.1: + resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} + engines: {node: '>=8'} + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + side-channel-list@1.0.1: + resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==} + engines: {node: '>= 0.4'} + + side-channel-map@1.0.1: + resolution: {integrity: sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==} + engines: {node: '>= 0.4'} + + side-channel-weakmap@1.0.2: + resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==} + engines: {node: '>= 0.4'} + + side-channel@1.1.0: + resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==} + engines: {node: '>= 0.4'} + + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + + source-map-js@1.2.1: + resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + engines: {node: '>=0.10.0'} + + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + + std-env@3.10.0: + resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + + stream-browserify@3.0.0: + resolution: {integrity: sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==} + + stream-http@3.2.0: + resolution: {integrity: sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==} + + string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + + string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + + strip-literal@3.1.0: + resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==} + + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + tapable@2.3.3: + resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} + engines: {node: '>=6'} + + terser-webpack-plugin@5.6.1: + resolution: {integrity: sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==} + engines: {node: '>= 10.13.0'} + peerDependencies: + '@minify-html/node': '*' + '@swc/core': '*' + '@swc/css': '*' + '@swc/html': '*' + clean-css: '*' + cssnano: '*' + csso: '*' + esbuild: '*' + html-minifier-terser: '*' + lightningcss: '*' + postcss: '*' + uglify-js: '*' + webpack: ^5.1.0 + peerDependenciesMeta: + '@minify-html/node': + optional: true + '@swc/core': + optional: true + '@swc/css': + optional: true + '@swc/html': + optional: true + clean-css: + optional: true + cssnano: + optional: true + csso: + optional: true + esbuild: + optional: true + html-minifier-terser: + optional: true + lightningcss: + optional: true + postcss: + optional: true + uglify-js: + optional: true + + terser@5.48.0: + resolution: {integrity: sha512-J/9An6vs9Us6wKRriSFXBWdRZapREHqFzdNUKk0pmu804EMR6dr6winwo7e5JDxN4xahxQsuysyYFwlwj4XN/Q==} + engines: {node: '>=10'} + hasBin: true + + timers-browserify@2.0.12: + resolution: {integrity: sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ==} + engines: {node: '>=0.6.0'} + + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinyexec@0.3.2: + resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tinypool@1.1.1: + resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} + engines: {node: ^18.0.0 || >=20.0.0} + + tinyrainbow@2.0.0: + resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} + engines: {node: '>=14.0.0'} + + tinyspy@4.0.4: + resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} + engines: {node: '>=14.0.0'} + + to-buffer@1.2.2: + resolution: {integrity: sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==} + engines: {node: '>= 0.4'} + + tty-browserify@0.0.1: + resolution: {integrity: sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==} + + type-fest@4.41.0: + resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} + engines: {node: '>=16'} + + typed-array-buffer@1.0.3: + resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} + engines: {node: '>= 0.4'} + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + + update-browserslist-db@1.2.3: + resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + url@0.11.4: + resolution: {integrity: sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg==} + engines: {node: '>= 0.4'} + + util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + + util@0.12.5: + resolution: {integrity: sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==} + + vite-node@3.2.4: + resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + + vite@7.3.5: + resolution: {integrity: sha512-KuOaNhcnGFN2zIPGA7wRmzF+lJA1sea7rHq17aiJ++9lzY1WWG6Jpwqwe1KNbRVPIqHmr8GLYx7jbrQcN/7/ww==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + jiti: '>=1.21.0' + less: ^4.0.0 + lightningcss: ^1.21.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + jiti: + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@3.2.6: + resolution: {integrity: sha512-xejya+bT/j/+R/AGa1XOfRxLmNUlLtlwjRsFUILF+xHfzElmGcmFydy2gqqIrd62ptIEfwVMofd19uNWD9L7Nw==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/debug': ^4.1.12 + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + '@vitest/browser': 3.2.6 + '@vitest/ui': 3.2.6 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/debug': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + vm-browserify@1.1.2: + resolution: {integrity: sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==} + + watchpack@2.5.1: + resolution: {integrity: sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==} + engines: {node: '>=10.13.0'} + + webpack-cli@6.0.1: + resolution: {integrity: sha512-MfwFQ6SfwinsUVi0rNJm7rHZ31GyTcpVE5pgVA3hwFRb7COD4TzjUUwhGWKfO50+xdc2MQPuEBBJoqIMGt3JDw==} + engines: {node: '>=18.12.0'} + hasBin: true + peerDependencies: + webpack: ^5.82.0 + webpack-bundle-analyzer: '*' + webpack-dev-server: '*' + peerDependenciesMeta: + webpack-bundle-analyzer: + optional: true + webpack-dev-server: + optional: true + + webpack-merge@6.0.1: + resolution: {integrity: sha512-hXXvrjtx2PLYx4qruKl+kyRSLc52V+cCvMxRjmKwoA+CBbbF5GfIBtR6kCvl0fYGqTUPKB+1ktVmTHqMOzgCBg==} + engines: {node: '>=18.0.0'} + + webpack-sources@3.5.0: + resolution: {integrity: sha512-HPuy+uuoTCaaoEoI1LQ3JN9+vrPBvEesnnX1jADHy728cHSMlq4wUc4afYqahq2B1mhQVZxCXOkNTnXltr+2vQ==} + engines: {node: '>=10.13.0'} + + webpack@5.107.2: + resolution: {integrity: sha512-v7RhXaJbpMlV0D7hC7lb2EbnxkoeUqf9qhKr6lozx3Q48pmFrqqNRmZFUEGmi7pSwm6fCQ2H1IjvCkHqdpVdjQ==} + engines: {node: '>=10.13.0'} + hasBin: true + peerDependencies: + webpack-cli: '*' + peerDependenciesMeta: + webpack-cli: + optional: true + + which-typed-array@1.1.21: + resolution: {integrity: sha512-zbRA8cVm6io/d5W8uIe2hblzN76/Wm3v/yiythQvr+dpBWeqhPSWIDNj4zOyHi4zKbMK6DN34Xsr9jPHJERAEw==} + engines: {node: '>= 0.4'} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + + wildcard@2.0.1: + resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==} + + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + +snapshots: + + '@discoveryjs/json-ext@0.6.3': {} + + '@esbuild/aix-ppc64@0.27.7': + optional: true + + '@esbuild/android-arm64@0.27.7': + optional: true + + '@esbuild/android-arm@0.27.7': + optional: true + + '@esbuild/android-x64@0.27.7': + optional: true + + '@esbuild/darwin-arm64@0.27.7': + optional: true + + '@esbuild/darwin-x64@0.27.7': + optional: true + + '@esbuild/freebsd-arm64@0.27.7': + optional: true + + '@esbuild/freebsd-x64@0.27.7': + optional: true + + '@esbuild/linux-arm64@0.27.7': + optional: true + + '@esbuild/linux-arm@0.27.7': + optional: true + + '@esbuild/linux-ia32@0.27.7': + optional: true + + '@esbuild/linux-loong64@0.27.7': + optional: true + + '@esbuild/linux-mips64el@0.27.7': + optional: true + + '@esbuild/linux-ppc64@0.27.7': + optional: true + + '@esbuild/linux-riscv64@0.27.7': + optional: true + + '@esbuild/linux-s390x@0.27.7': + optional: true + + '@esbuild/linux-x64@0.27.7': + optional: true + + '@esbuild/netbsd-arm64@0.27.7': + optional: true + + '@esbuild/netbsd-x64@0.27.7': + optional: true + + '@esbuild/openbsd-arm64@0.27.7': + optional: true + + '@esbuild/openbsd-x64@0.27.7': + optional: true + + '@esbuild/openharmony-arm64@0.27.7': + optional: true + + '@esbuild/sunos-x64@0.27.7': + optional: true + + '@esbuild/win32-arm64@0.27.7': + optional: true + + '@esbuild/win32-ia32@0.27.7': + optional: true + + '@esbuild/win32-x64@0.27.7': + optional: true + + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/source-map@0.3.11': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/sourcemap-codec@1.5.5': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.5 + + '@noble/curves@2.2.0': + dependencies: + '@noble/hashes': 2.2.0 + + '@noble/hashes@2.2.0': {} + + '@rollup/rollup-android-arm-eabi@4.61.1': + optional: true + + '@rollup/rollup-android-arm64@4.61.1': + optional: true + + '@rollup/rollup-darwin-arm64@4.61.1': + optional: true + + '@rollup/rollup-darwin-x64@4.61.1': + optional: true + + '@rollup/rollup-freebsd-arm64@4.61.1': + optional: true + + '@rollup/rollup-freebsd-x64@4.61.1': + optional: true + + '@rollup/rollup-linux-arm-gnueabihf@4.61.1': + optional: true + + '@rollup/rollup-linux-arm-musleabihf@4.61.1': + optional: true + + '@rollup/rollup-linux-arm64-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-arm64-musl@4.61.1': + optional: true + + '@rollup/rollup-linux-loong64-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-loong64-musl@4.61.1': + optional: true + + '@rollup/rollup-linux-ppc64-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-ppc64-musl@4.61.1': + optional: true + + '@rollup/rollup-linux-riscv64-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-riscv64-musl@4.61.1': + optional: true + + '@rollup/rollup-linux-s390x-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-x64-gnu@4.61.1': + optional: true + + '@rollup/rollup-linux-x64-musl@4.61.1': + optional: true + + '@rollup/rollup-openbsd-x64@4.61.1': + optional: true + + '@rollup/rollup-openharmony-arm64@4.61.1': + optional: true + + '@rollup/rollup-win32-arm64-msvc@4.61.1': + optional: true + + '@rollup/rollup-win32-ia32-msvc@4.61.1': + optional: true + + '@rollup/rollup-win32-x64-gnu@4.61.1': + optional: true + + '@rollup/rollup-win32-x64-msvc@4.61.1': + optional: true + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + + '@types/estree@1.0.9': {} + + '@types/json-schema@7.0.15': {} + + '@types/node@22.19.19': + dependencies: + undici-types: 6.21.0 + + '@vitest/expect@3.2.6': + dependencies: + '@types/chai': 5.2.3 + '@vitest/spy': 3.2.6 + '@vitest/utils': 3.2.6 + chai: 5.3.3 + tinyrainbow: 2.0.0 + + '@vitest/mocker@3.2.6(vite@7.3.5(@types/node@22.19.19)(terser@5.48.0))': + dependencies: + '@vitest/spy': 3.2.6 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + vite: 7.3.5(@types/node@22.19.19)(terser@5.48.0) + + '@vitest/pretty-format@3.2.6': + dependencies: + tinyrainbow: 2.0.0 + + '@vitest/runner@3.2.6': + dependencies: + '@vitest/utils': 3.2.6 + pathe: 2.0.3 + strip-literal: 3.1.0 + + '@vitest/snapshot@3.2.6': + dependencies: + '@vitest/pretty-format': 3.2.6 + magic-string: 0.30.21 + pathe: 2.0.3 + + '@vitest/spy@3.2.6': + dependencies: + tinyspy: 4.0.4 + + '@vitest/utils@3.2.6': + dependencies: + '@vitest/pretty-format': 3.2.6 + loupe: 3.2.1 + tinyrainbow: 2.0.0 + + '@waves/ts-lib-crypto@1.5.2': + dependencies: + '@noble/curves': 2.2.0 + '@noble/hashes': 2.2.0 + js-sha256: 0.11.1 + js-sha3: 0.9.3 + node-forge: 1.4.0 + + '@webassemblyjs/ast@1.14.1': + dependencies: + '@webassemblyjs/helper-numbers': 1.13.2 + '@webassemblyjs/helper-wasm-bytecode': 1.13.2 + + '@webassemblyjs/floating-point-hex-parser@1.13.2': {} + + '@webassemblyjs/helper-api-error@1.13.2': {} + + '@webassemblyjs/helper-buffer@1.14.1': {} + + '@webassemblyjs/helper-numbers@1.13.2': + dependencies: + '@webassemblyjs/floating-point-hex-parser': 1.13.2 + '@webassemblyjs/helper-api-error': 1.13.2 + '@xtuc/long': 4.2.2 + + '@webassemblyjs/helper-wasm-bytecode@1.13.2': {} + + '@webassemblyjs/helper-wasm-section@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/helper-buffer': 1.14.1 + '@webassemblyjs/helper-wasm-bytecode': 1.13.2 + '@webassemblyjs/wasm-gen': 1.14.1 + + '@webassemblyjs/ieee754@1.13.2': + dependencies: + '@xtuc/ieee754': 1.2.0 + + '@webassemblyjs/leb128@1.13.2': + dependencies: + '@xtuc/long': 4.2.2 + + '@webassemblyjs/utf8@1.13.2': {} + + '@webassemblyjs/wasm-edit@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/helper-buffer': 1.14.1 + '@webassemblyjs/helper-wasm-bytecode': 1.13.2 + '@webassemblyjs/helper-wasm-section': 1.14.1 + '@webassemblyjs/wasm-gen': 1.14.1 + '@webassemblyjs/wasm-opt': 1.14.1 + '@webassemblyjs/wasm-parser': 1.14.1 + '@webassemblyjs/wast-printer': 1.14.1 + + '@webassemblyjs/wasm-gen@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/helper-wasm-bytecode': 1.13.2 + '@webassemblyjs/ieee754': 1.13.2 + '@webassemblyjs/leb128': 1.13.2 + '@webassemblyjs/utf8': 1.13.2 + + '@webassemblyjs/wasm-opt@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/helper-buffer': 1.14.1 + '@webassemblyjs/wasm-gen': 1.14.1 + '@webassemblyjs/wasm-parser': 1.14.1 + + '@webassemblyjs/wasm-parser@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/helper-api-error': 1.13.2 + '@webassemblyjs/helper-wasm-bytecode': 1.13.2 + '@webassemblyjs/ieee754': 1.13.2 + '@webassemblyjs/leb128': 1.13.2 + '@webassemblyjs/utf8': 1.13.2 + + '@webassemblyjs/wast-printer@1.14.1': + dependencies: + '@webassemblyjs/ast': 1.14.1 + '@xtuc/long': 4.2.2 + + '@webpack-cli/configtest@3.0.1(webpack-cli@6.0.1)(webpack@5.107.2)': + dependencies: + webpack: 5.107.2(webpack-cli@6.0.1) + webpack-cli: 6.0.1(webpack@5.107.2) + + '@webpack-cli/info@3.0.1(webpack-cli@6.0.1)(webpack@5.107.2)': + dependencies: + webpack: 5.107.2(webpack-cli@6.0.1) + webpack-cli: 6.0.1(webpack@5.107.2) + + '@webpack-cli/serve@3.0.1(webpack-cli@6.0.1)(webpack@5.107.2)': + dependencies: + webpack: 5.107.2(webpack-cli@6.0.1) + webpack-cli: 6.0.1(webpack@5.107.2) + + '@xtuc/ieee754@1.2.0': {} + + '@xtuc/long@4.2.2': {} + + acorn-import-phases@1.0.4(acorn@8.16.0): + dependencies: + acorn: 8.16.0 + + acorn@8.16.0: {} + + agent-base@6.0.2: + dependencies: + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + ajv-formats@2.1.1(ajv@8.20.0): + optionalDependencies: + ajv: 8.20.0 + + ajv-keywords@5.1.0(ajv@8.20.0): + dependencies: + ajv: 8.20.0 + fast-deep-equal: 3.1.3 + + ajv@8.20.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-uri: 3.1.2 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + + asn1.js@4.10.1: + dependencies: + bn.js: 4.12.3 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + + assert@2.1.0: + dependencies: + call-bind: 1.0.9 + is-nan: 1.3.2 + object-is: 1.1.6 + object.assign: 4.1.7 + util: 0.12.5 + + assertion-error@2.0.1: {} + + asynckit@0.4.0: {} + + available-typed-arrays@1.0.7: + dependencies: + possible-typed-array-names: 1.1.0 + + axios@1.17.0: + dependencies: + follow-redirects: 1.16.0 + form-data: 4.0.5 + https-proxy-agent: 5.0.1 + proxy-from-env: 2.1.0 + transitivePeerDependencies: + - debug + - supports-color + + base64-js@1.5.1: {} + + baseline-browser-mapping@2.10.33: {} + + bn.js@4.12.3: {} + + bn.js@5.2.3: {} + + brorand@1.1.0: {} + + browser-resolve@2.0.0: + dependencies: + resolve: 1.22.12 + + browserify-aes@1.2.0: + dependencies: + buffer-xor: 1.0.3 + cipher-base: 1.0.7 + create-hash: 1.2.0 + evp_bytestokey: 1.0.3 + inherits: 2.0.4 + safe-buffer: 5.2.1 + + browserify-cipher@1.0.1: + dependencies: + browserify-aes: 1.2.0 + browserify-des: 1.0.2 + evp_bytestokey: 1.0.3 + + browserify-des@1.0.2: + dependencies: + cipher-base: 1.0.7 + des.js: 1.1.0 + inherits: 2.0.4 + safe-buffer: 5.2.1 + + browserify-rsa@4.1.1: + dependencies: + bn.js: 5.2.3 + randombytes: 2.1.0 + safe-buffer: 5.2.1 + + browserify-sign@4.2.6: + dependencies: + bn.js: 5.2.3 + browserify-rsa: 4.1.1 + create-hash: 1.2.0 + create-hmac: 1.1.7 + elliptic: 6.6.1 + inherits: 2.0.4 + parse-asn1: 5.1.9 + readable-stream: 2.3.8 + safe-buffer: 5.2.1 + + browserify-zlib@0.2.0: + dependencies: + pako: 1.0.11 + + browserslist@4.28.2: + dependencies: + baseline-browser-mapping: 2.10.33 + caniuse-lite: 1.0.30001793 + electron-to-chromium: 1.5.367 + node-releases: 2.0.47 + update-browserslist-db: 1.2.3(browserslist@4.28.2) + + buffer-from@1.1.2: {} + + buffer-xor@1.0.3: {} + + buffer@5.7.1: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + buffer@6.0.3: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + builtin-status-codes@3.0.0: {} + + cac@6.7.14: {} + + call-bind-apply-helpers@1.0.2: + dependencies: + es-errors: 1.3.0 + function-bind: 1.1.2 + + call-bind@1.0.9: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + get-intrinsic: 1.3.0 + set-function-length: 1.2.2 + + call-bound@1.0.4: + dependencies: + call-bind-apply-helpers: 1.0.2 + get-intrinsic: 1.3.0 + + caniuse-lite@1.0.30001793: {} + + chai@5.3.3: + dependencies: + assertion-error: 2.0.1 + check-error: 2.1.3 + deep-eql: 5.0.2 + loupe: 3.2.1 + pathval: 2.0.1 + + check-error@2.1.3: {} + + chrome-trace-event@1.0.4: {} + + cipher-base@1.0.7: + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + to-buffer: 1.2.2 + + clone-deep@4.0.1: + dependencies: + is-plain-object: 2.0.4 + kind-of: 6.0.3 + shallow-clone: 3.0.1 + + colorette@2.0.20: {} + + combined-stream@1.0.8: + dependencies: + delayed-stream: 1.0.0 + + commander@12.1.0: {} + + commander@2.20.3: {} + + console-browserify@1.2.0: {} + + constants-browserify@1.0.0: {} + + core-util-is@1.0.3: {} + + create-ecdh@4.0.4: + dependencies: + bn.js: 4.12.3 + elliptic: 6.6.1 + + create-hash@1.2.0: + dependencies: + cipher-base: 1.0.7 + inherits: 2.0.4 + md5.js: 1.3.5 + ripemd160: 2.0.3 + sha.js: 2.4.12 + + create-hmac@1.1.7: + dependencies: + cipher-base: 1.0.7 + create-hash: 1.2.0 + inherits: 2.0.4 + ripemd160: 2.0.3 + safe-buffer: 5.2.1 + sha.js: 2.4.12 + + create-require@1.1.1: {} + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + crypto-browserify@3.12.1: + dependencies: + browserify-cipher: 1.0.1 + browserify-sign: 4.2.6 + create-ecdh: 4.0.4 + create-hash: 1.2.0 + create-hmac: 1.1.7 + diffie-hellman: 5.0.3 + hash-base: 3.0.5 + inherits: 2.0.4 + pbkdf2: 3.1.6 + public-encrypt: 4.0.3 + randombytes: 2.1.0 + randomfill: 1.0.4 + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + deep-eql@5.0.2: {} + + define-data-property@1.1.4: + dependencies: + es-define-property: 1.0.1 + es-errors: 1.3.0 + gopd: 1.2.0 + + define-properties@1.2.1: + dependencies: + define-data-property: 1.1.4 + has-property-descriptors: 1.0.2 + object-keys: 1.1.1 + + delayed-stream@1.0.0: {} + + des.js@1.1.0: + dependencies: + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + + diffie-hellman@5.0.3: + dependencies: + bn.js: 4.12.3 + miller-rabin: 4.0.1 + randombytes: 2.1.0 + + domain-browser@4.22.0: {} + + dunder-proto@1.0.1: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-errors: 1.3.0 + gopd: 1.2.0 + + electron-to-chromium@1.5.367: {} + + elliptic@6.6.1: + dependencies: + bn.js: 4.12.3 + brorand: 1.1.0 + hash.js: 1.1.7 + hmac-drbg: 1.0.1 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + + enhanced-resolve@5.22.2: + dependencies: + graceful-fs: 4.2.11 + tapable: 2.3.3 + + envinfo@7.21.0: {} + + es-define-property@1.0.1: {} + + es-errors@1.3.0: {} + + es-module-lexer@1.7.0: {} + + es-module-lexer@2.1.0: {} + + es-object-atoms@1.1.2: + dependencies: + es-errors: 1.3.0 + + es-set-tostringtag@2.1.0: + dependencies: + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + esbuild@0.27.7: + optionalDependencies: + '@esbuild/aix-ppc64': 0.27.7 + '@esbuild/android-arm': 0.27.7 + '@esbuild/android-arm64': 0.27.7 + '@esbuild/android-x64': 0.27.7 + '@esbuild/darwin-arm64': 0.27.7 + '@esbuild/darwin-x64': 0.27.7 + '@esbuild/freebsd-arm64': 0.27.7 + '@esbuild/freebsd-x64': 0.27.7 + '@esbuild/linux-arm': 0.27.7 + '@esbuild/linux-arm64': 0.27.7 + '@esbuild/linux-ia32': 0.27.7 + '@esbuild/linux-loong64': 0.27.7 + '@esbuild/linux-mips64el': 0.27.7 + '@esbuild/linux-ppc64': 0.27.7 + '@esbuild/linux-riscv64': 0.27.7 + '@esbuild/linux-s390x': 0.27.7 + '@esbuild/linux-x64': 0.27.7 + '@esbuild/netbsd-arm64': 0.27.7 + '@esbuild/netbsd-x64': 0.27.7 + '@esbuild/openbsd-arm64': 0.27.7 + '@esbuild/openbsd-x64': 0.27.7 + '@esbuild/openharmony-arm64': 0.27.7 + '@esbuild/sunos-x64': 0.27.7 + '@esbuild/win32-arm64': 0.27.7 + '@esbuild/win32-ia32': 0.27.7 + '@esbuild/win32-x64': 0.27.7 + + escalade@3.2.0: {} + + eslint-scope@5.1.1: + dependencies: + esrecurse: 4.3.0 + estraverse: 4.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@4.3.0: {} + + estraverse@5.3.0: {} + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.9 + + events@3.3.0: {} + + evp_bytestokey@1.0.3: + dependencies: + md5.js: 1.3.5 + safe-buffer: 5.2.1 + + expect-type@1.3.0: {} + + fast-deep-equal@3.1.3: {} + + fast-uri@3.1.2: {} + + fastest-levenshtein@1.0.16: {} + + fdir@6.5.0(picomatch@4.0.4): + optionalDependencies: + picomatch: 4.0.4 + + find-up@4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + + flat@5.0.2: {} + + follow-redirects@1.16.0: {} + + for-each@0.3.5: + dependencies: + is-callable: 1.2.7 + + form-data@4.0.5: + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + es-set-tostringtag: 2.1.0 + hasown: 2.0.4 + mime-types: 2.1.35 + + fsevents@2.3.3: + optional: true + + function-bind@1.1.2: {} + + generator-function@2.0.1: {} + + get-intrinsic@1.3.0: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + function-bind: 1.1.2 + get-proto: 1.0.1 + gopd: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.4 + math-intrinsics: 1.1.0 + + get-proto@1.0.1: + dependencies: + dunder-proto: 1.0.1 + es-object-atoms: 1.1.2 + + glob-to-regexp@0.4.1: {} + + gopd@1.2.0: {} + + graceful-fs@4.2.11: {} + + has-flag@4.0.0: {} + + has-property-descriptors@1.0.2: + dependencies: + es-define-property: 1.0.1 + + has-symbols@1.1.0: {} + + has-tostringtag@1.0.2: + dependencies: + has-symbols: 1.1.0 + + hash-base@3.0.5: + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + + hash-base@3.1.2: + dependencies: + inherits: 2.0.4 + readable-stream: 2.3.8 + safe-buffer: 5.2.1 + to-buffer: 1.2.2 + + hash.js@1.1.7: + dependencies: + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + + hasown@2.0.4: + dependencies: + function-bind: 1.1.2 + + hmac-drbg@1.0.1: + dependencies: + hash.js: 1.1.7 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + + https-browserify@1.0.0: {} + + https-proxy-agent@5.0.1: + dependencies: + agent-base: 6.0.2 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + ieee754@1.2.1: {} + + import-local@3.2.0: + dependencies: + pkg-dir: 4.2.0 + resolve-cwd: 3.0.0 + + inherits@2.0.4: {} + + interpret@3.1.1: {} + + is-arguments@1.2.0: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-callable@1.2.7: {} + + is-core-module@2.16.2: + dependencies: + hasown: 2.0.4 + + is-generator-function@1.1.2: + dependencies: + call-bound: 1.0.4 + generator-function: 2.0.1 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-nan@1.3.2: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + + is-plain-object@2.0.4: + dependencies: + isobject: 3.0.1 + + is-regex@1.2.1: + dependencies: + call-bound: 1.0.4 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + is-typed-array@1.1.15: + dependencies: + which-typed-array: 1.1.21 + + isarray@1.0.0: {} + + isarray@2.0.5: {} + + isexe@2.0.0: {} + + isobject@3.0.1: {} + + isomorphic-timers-promises@1.0.1: {} + + jest-worker@27.5.1: + dependencies: + '@types/node': 22.19.19 + merge-stream: 2.0.0 + supports-color: 8.1.1 + + js-sha256@0.11.1: {} + + js-sha3@0.9.3: {} + + js-tokens@9.0.1: {} + + json-schema-traverse@1.0.0: {} + + kind-of@6.0.3: {} + + loader-runner@4.3.2: {} + + locate-path@5.0.0: + dependencies: + p-locate: 4.1.0 + + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + + loupe@3.2.1: {} + + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + + math-intrinsics@1.1.0: {} + + md5.js@1.3.5: + dependencies: + hash-base: 3.0.5 + inherits: 2.0.4 + safe-buffer: 5.2.1 + + merge-stream@2.0.0: {} + + miller-rabin@4.0.1: + dependencies: + bn.js: 4.12.3 + brorand: 1.1.0 + + mime-db@1.52.0: {} + + mime-db@1.54.0: {} + + mime-types@2.1.35: + dependencies: + mime-db: 1.52.0 + + minimalistic-assert@1.0.1: {} + + minimalistic-crypto-utils@1.0.1: {} + + ms@2.1.3: {} + + nanoid@3.3.12: {} + + neo-async@2.6.2: {} + + node-forge@1.4.0: {} + + node-polyfill-webpack-plugin@4.1.0(webpack@5.107.2): + dependencies: + node-stdlib-browser: 1.3.1 + type-fest: 4.41.0 + webpack: 5.107.2(webpack-cli@6.0.1) + + node-releases@2.0.47: {} + + node-stdlib-browser@1.3.1: + dependencies: + assert: 2.1.0 + browser-resolve: 2.0.0 + browserify-zlib: 0.2.0 + buffer: 5.7.1 + console-browserify: 1.2.0 + constants-browserify: 1.0.0 + create-require: 1.1.1 + crypto-browserify: 3.12.1 + domain-browser: 4.22.0 + events: 3.3.0 + https-browserify: 1.0.0 + isomorphic-timers-promises: 1.0.1 + os-browserify: 0.3.0 + path-browserify: 1.0.1 + pkg-dir: 5.0.0 + process: 0.11.10 + punycode: 1.4.1 + querystring-es3: 0.2.1 + readable-stream: 3.6.2 + stream-browserify: 3.0.0 + stream-http: 3.2.0 + string_decoder: 1.3.0 + timers-browserify: 2.0.12 + tty-browserify: 0.0.1 + url: 0.11.4 + util: 0.12.5 + vm-browserify: 1.1.2 + + object-inspect@1.13.4: {} + + object-is@1.1.6: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + + object-keys@1.1.1: {} + + object.assign@4.1.7: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + has-symbols: 1.1.0 + object-keys: 1.1.1 + + os-browserify@0.3.0: {} + + p-limit@2.3.0: + dependencies: + p-try: 2.2.0 + + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + + p-locate@4.1.0: + dependencies: + p-limit: 2.3.0 + + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + + p-try@2.2.0: {} + + pako@1.0.11: {} + + parse-asn1@5.1.9: + dependencies: + asn1.js: 4.10.1 + browserify-aes: 1.2.0 + evp_bytestokey: 1.0.3 + pbkdf2: 3.1.6 + safe-buffer: 5.2.1 + + path-browserify@1.0.1: {} + + path-exists@4.0.0: {} + + path-key@3.1.1: {} + + path-parse@1.0.7: {} + + pathe@2.0.3: {} + + pathval@2.0.1: {} + + pbkdf2@3.1.6: + dependencies: + create-hash: 1.2.0 + create-hmac: 1.1.7 + ripemd160: 2.0.3 + safe-buffer: 5.2.1 + sha.js: 2.4.12 + to-buffer: 1.2.2 + + picocolors@1.1.1: {} + + picomatch@4.0.4: {} + + pkg-dir@4.2.0: + dependencies: + find-up: 4.1.0 + + pkg-dir@5.0.0: + dependencies: + find-up: 5.0.0 + + possible-typed-array-names@1.1.0: {} + + postcss@8.5.15: + dependencies: + nanoid: 3.3.12 + picocolors: 1.1.1 + source-map-js: 1.2.1 + + process-nextick-args@2.0.1: {} + + process@0.11.10: {} + + proxy-from-env@2.1.0: {} + + public-encrypt@4.0.3: + dependencies: + bn.js: 4.12.3 + browserify-rsa: 4.1.1 + create-hash: 1.2.0 + parse-asn1: 5.1.9 + randombytes: 2.1.0 + safe-buffer: 5.2.1 + + punycode@1.4.1: {} + + qs@6.15.2: + dependencies: + side-channel: 1.1.0 + + querystring-es3@0.2.1: {} + + randombytes@2.1.0: + dependencies: + safe-buffer: 5.2.1 + + randomfill@1.0.4: + dependencies: + randombytes: 2.1.0 + safe-buffer: 5.2.1 + + readable-stream@2.3.8: + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + + readable-stream@3.6.2: + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + + rechoir@0.8.0: + dependencies: + resolve: 1.22.12 + + require-from-string@2.0.2: {} + + resolve-cwd@3.0.0: + dependencies: + resolve-from: 5.0.0 + + resolve-from@5.0.0: {} + + resolve@1.22.12: + dependencies: + es-errors: 1.3.0 + is-core-module: 2.16.2 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + + ripemd160@2.0.3: + dependencies: + hash-base: 3.1.2 + inherits: 2.0.4 + + rollup@4.61.1: + dependencies: + '@types/estree': 1.0.9 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.61.1 + '@rollup/rollup-android-arm64': 4.61.1 + '@rollup/rollup-darwin-arm64': 4.61.1 + '@rollup/rollup-darwin-x64': 4.61.1 + '@rollup/rollup-freebsd-arm64': 4.61.1 + '@rollup/rollup-freebsd-x64': 4.61.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.61.1 + '@rollup/rollup-linux-arm-musleabihf': 4.61.1 + '@rollup/rollup-linux-arm64-gnu': 4.61.1 + '@rollup/rollup-linux-arm64-musl': 4.61.1 + '@rollup/rollup-linux-loong64-gnu': 4.61.1 + '@rollup/rollup-linux-loong64-musl': 4.61.1 + '@rollup/rollup-linux-ppc64-gnu': 4.61.1 + '@rollup/rollup-linux-ppc64-musl': 4.61.1 + '@rollup/rollup-linux-riscv64-gnu': 4.61.1 + '@rollup/rollup-linux-riscv64-musl': 4.61.1 + '@rollup/rollup-linux-s390x-gnu': 4.61.1 + '@rollup/rollup-linux-x64-gnu': 4.61.1 + '@rollup/rollup-linux-x64-musl': 4.61.1 + '@rollup/rollup-openbsd-x64': 4.61.1 + '@rollup/rollup-openharmony-arm64': 4.61.1 + '@rollup/rollup-win32-arm64-msvc': 4.61.1 + '@rollup/rollup-win32-ia32-msvc': 4.61.1 + '@rollup/rollup-win32-x64-gnu': 4.61.1 + '@rollup/rollup-win32-x64-msvc': 4.61.1 + fsevents: 2.3.3 + + safe-buffer@5.1.2: {} + + safe-buffer@5.2.1: {} + + safe-regex-test@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-regex: 1.2.1 + + schema-utils@4.3.3: + dependencies: + '@types/json-schema': 7.0.15 + ajv: 8.20.0 + ajv-formats: 2.1.1(ajv@8.20.0) + ajv-keywords: 5.1.0(ajv@8.20.0) + + set-function-length@1.2.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + + setimmediate@1.0.5: {} + + sha.js@2.4.12: + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + to-buffer: 1.2.2 + + shallow-clone@3.0.1: + dependencies: + kind-of: 6.0.3 + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + side-channel-list@1.0.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + + side-channel-map@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + + side-channel-weakmap@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + side-channel-map: 1.0.1 + + side-channel@1.1.0: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + side-channel-list: 1.0.1 + side-channel-map: 1.0.1 + side-channel-weakmap: 1.0.2 + + siginfo@2.0.0: {} + + source-map-js@1.2.1: {} + + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + source-map@0.6.1: {} + + stackback@0.0.2: {} + + std-env@3.10.0: {} + + stream-browserify@3.0.0: + dependencies: + inherits: 2.0.4 + readable-stream: 3.6.2 + + stream-http@3.2.0: + dependencies: + builtin-status-codes: 3.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + xtend: 4.0.2 + + string_decoder@1.1.1: + dependencies: + safe-buffer: 5.1.2 + + string_decoder@1.3.0: + dependencies: + safe-buffer: 5.2.1 + + strip-literal@3.1.0: + dependencies: + js-tokens: 9.0.1 + + supports-color@8.1.1: + dependencies: + has-flag: 4.0.0 + + supports-preserve-symlinks-flag@1.0.0: {} + + tapable@2.3.3: {} + + terser-webpack-plugin@5.6.1(webpack@5.107.2): + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + jest-worker: 27.5.1 + schema-utils: 4.3.3 + terser: 5.48.0 + webpack: 5.107.2(webpack-cli@6.0.1) + + terser@5.48.0: + dependencies: + '@jridgewell/source-map': 0.3.11 + acorn: 8.16.0 + commander: 2.20.3 + source-map-support: 0.5.21 + + timers-browserify@2.0.12: + dependencies: + setimmediate: 1.0.5 + + tinybench@2.9.0: {} + + tinyexec@0.3.2: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.4) + picomatch: 4.0.4 + + tinypool@1.1.1: {} + + tinyrainbow@2.0.0: {} + + tinyspy@4.0.4: {} + + to-buffer@1.2.2: + dependencies: + isarray: 2.0.5 + safe-buffer: 5.2.1 + typed-array-buffer: 1.0.3 + + tty-browserify@0.0.1: {} + + type-fest@4.41.0: {} + + typed-array-buffer@1.0.3: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-typed-array: 1.1.15 + + typescript@5.9.3: {} + + undici-types@6.21.0: {} + + update-browserslist-db@1.2.3(browserslist@4.28.2): + dependencies: + browserslist: 4.28.2 + escalade: 3.2.0 + picocolors: 1.1.1 + + url@0.11.4: + dependencies: + punycode: 1.4.1 + qs: 6.15.2 + + util-deprecate@1.0.2: {} + + util@0.12.5: + dependencies: + inherits: 2.0.4 + is-arguments: 1.2.0 + is-generator-function: 1.1.2 + is-typed-array: 1.1.15 + which-typed-array: 1.1.21 + + vite-node@3.2.4(@types/node@22.19.19)(terser@5.48.0): + dependencies: + cac: 6.7.14 + debug: 4.4.3 + es-module-lexer: 1.7.0 + pathe: 2.0.3 + vite: 7.3.5(@types/node@22.19.19)(terser@5.48.0) + transitivePeerDependencies: + - '@types/node' + - jiti + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + + vite@7.3.5(@types/node@22.19.19)(terser@5.48.0): + dependencies: + esbuild: 0.27.7 + fdir: 6.5.0(picomatch@4.0.4) + picomatch: 4.0.4 + postcss: 8.5.15 + rollup: 4.61.1 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 22.19.19 + fsevents: 2.3.3 + terser: 5.48.0 + + vitest@3.2.6(@types/node@22.19.19)(terser@5.48.0): + dependencies: + '@types/chai': 5.2.3 + '@vitest/expect': 3.2.6 + '@vitest/mocker': 3.2.6(vite@7.3.5(@types/node@22.19.19)(terser@5.48.0)) + '@vitest/pretty-format': 3.2.6 + '@vitest/runner': 3.2.6 + '@vitest/snapshot': 3.2.6 + '@vitest/spy': 3.2.6 + '@vitest/utils': 3.2.6 + chai: 5.3.3 + debug: 4.4.3 + expect-type: 1.3.0 + magic-string: 0.30.21 + pathe: 2.0.3 + picomatch: 4.0.4 + std-env: 3.10.0 + tinybench: 2.9.0 + tinyexec: 0.3.2 + tinyglobby: 0.2.17 + tinypool: 1.1.1 + tinyrainbow: 2.0.0 + vite: 7.3.5(@types/node@22.19.19)(terser@5.48.0) + vite-node: 3.2.4(@types/node@22.19.19)(terser@5.48.0) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 22.19.19 + transitivePeerDependencies: + - jiti + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + + vm-browserify@1.1.2: {} + + watchpack@2.5.1: + dependencies: + glob-to-regexp: 0.4.1 + graceful-fs: 4.2.11 + + webpack-cli@6.0.1(webpack@5.107.2): + dependencies: + '@discoveryjs/json-ext': 0.6.3 + '@webpack-cli/configtest': 3.0.1(webpack-cli@6.0.1)(webpack@5.107.2) + '@webpack-cli/info': 3.0.1(webpack-cli@6.0.1)(webpack@5.107.2) + '@webpack-cli/serve': 3.0.1(webpack-cli@6.0.1)(webpack@5.107.2) + colorette: 2.0.20 + commander: 12.1.0 + cross-spawn: 7.0.6 + envinfo: 7.21.0 + fastest-levenshtein: 1.0.16 + import-local: 3.2.0 + interpret: 3.1.1 + rechoir: 0.8.0 + webpack: 5.107.2(webpack-cli@6.0.1) + webpack-merge: 6.0.1 + + webpack-merge@6.0.1: + dependencies: + clone-deep: 4.0.1 + flat: 5.0.2 + wildcard: 2.0.1 + + webpack-sources@3.5.0: {} + + webpack@5.107.2(webpack-cli@6.0.1): + dependencies: + '@types/estree': 1.0.9 + '@types/json-schema': 7.0.15 + '@webassemblyjs/ast': 1.14.1 + '@webassemblyjs/wasm-edit': 1.14.1 + '@webassemblyjs/wasm-parser': 1.14.1 + acorn: 8.16.0 + acorn-import-phases: 1.0.4(acorn@8.16.0) + browserslist: 4.28.2 + chrome-trace-event: 1.0.4 + enhanced-resolve: 5.22.2 + es-module-lexer: 2.1.0 + eslint-scope: 5.1.1 + events: 3.3.0 + glob-to-regexp: 0.4.1 + graceful-fs: 4.2.11 + loader-runner: 4.3.2 + mime-db: 1.54.0 + neo-async: 2.6.2 + schema-utils: 4.3.3 + tapable: 2.3.3 + terser-webpack-plugin: 5.6.1(webpack@5.107.2) + watchpack: 2.5.1 + webpack-sources: 3.5.0 + optionalDependencies: + webpack-cli: 6.0.1(webpack@5.107.2) + transitivePeerDependencies: + - '@minify-html/node' + - '@swc/core' + - '@swc/css' + - '@swc/html' + - clean-css + - cssnano + - csso + - esbuild + - html-minifier-terser + - lightningcss + - postcss + - uglify-js + + which-typed-array@1.1.21: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + for-each: 0.3.5 + get-proto: 1.0.1 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + + wildcard@2.0.1: {} + + xtend@4.0.2: {} + + yocto-queue@0.1.0: {} diff --git a/ride-js-bundle/pnpm-workspace.yaml b/ride-js-bundle/pnpm-workspace.yaml new file mode 100644 index 00000000000..0da30bb953f --- /dev/null +++ b/ride-js-bundle/pnpm-workspace.yaml @@ -0,0 +1,5 @@ +allowBuilds: + esbuild: false +overrides: + serialize-javascript: ^7.0.3 + glob: ^13.0.6 diff --git a/ride-js-bundle/readme.md b/ride-js-bundle/readme.md new file mode 100644 index 00000000000..1dab85457e2 --- /dev/null +++ b/ride-js-bundle/readme.md @@ -0,0 +1,54 @@ +# @waves/ride-js + +JavaScript/TypeScript compiler and REPL for the [Ride](https://docs.waves.tech/en/ride/) +smart-contract language. Self-contained: the RIDE compiler and REPL (ScalaJS) are bundled +**once**, with no runtime dependency on `@waves/ride-lang` or `@waves/ride-repl`. + +## Install + +``` +npm install @waves/ride-js +``` + +## Usage + +```js +const RideJS = require('@waves/ride-js'); + +const { result, error } = RideJS.compile('true'); +// result: { bytes, base64, size, ast, complexity, verifierComplexity, callableComplexities, ... } + +const limits = RideJS.contractLimits; +const repl = RideJS.repl(); +``` + +The same `RideJS` global is exposed by the browser bundle (`dist/ride.min.js`). + +## Layout + +- `src/` — TypeScript glue (`index.ts` public API, `interop.ts` crypto/http globals) plus the + hand-maintained `index.d.ts` public typings, which `package.json` references directly (no copy). +- `scalajs/ride-scalajs.js` — the single combined ScalaJS artifact (the linked `repl-js` + output, which exports both the compiler API and the repl API). The Waves `sbt replJS/fullOptJS` + task is configured to emit it **directly** here (see `repl/js/build.sbt`), so there is no copy + step. +- `dist/` — build output: `index.js` (node `main`), `interop.js`, `ride.min.js` (browser). +- `pnpm-workspace.yaml` — pnpm settings: the `allowBuilds` install-script policy + dependency + `overrides`. + +## Build & test + +This package uses **pnpm** (pinned via the `packageManager` field). pnpm does not run dependency +install scripts: the policy lives in `pnpm-workspace.yaml` under `allowBuilds`, where every +dependency that ships an install script must be explicitly allowed or denied. Ours are denied +(`esbuild: false`), so no third-party code executes on install; a *new* dependency with a build +script fails the install until a deliberate decision is recorded. + +``` +sbt replJS/fullOptJS # from the Waves repo root: emits ride-js-bundle/scalajs/ride-scalajs.js +cd ride-js-bundle +corepack enable # makes the pinned pnpm available +pnpm install --frozen-lockfile +pnpm run build # build:ts -> build:browser (consumes the emitted artifact) +pnpm test # Vitest suite (compiles RIDE through the public API) +``` diff --git a/ride-js-bundle/src/index.d.ts b/ride-js-bundle/src/index.d.ts new file mode 100644 index 00000000000..18a8157d78a --- /dev/null +++ b/ride-js-bundle/src/index.d.ts @@ -0,0 +1,336 @@ +export interface ICompilationResult { + result: { + ast: object + base64: string + bytes: Uint8Array + size: number + complexity: number + verifierComplexity?: number + callableComplexity?: Record + userFunctionsComplexity?: Record + } +} + +export interface ICompilationError { + error: string +} + +export interface IDecompilationResult { + result: string +} + +export interface IDecompilationError { + error: any +} + +export type TType = TList | TStruct | TUnion | TPrimitive + +export type TPrimitive = string; + +export type TStructField = { name: string, type: TType }; + +export type TStruct = { + typeName: string + fields: TStructField[] +}; + +export type TList = { + 'listOf': TType +}; + +export type TUnionItem = TStruct | TPrimitive | TList +export type TUnion = TUnionItem[] + +export type TFunction = { + name: string + doc: string + resultType: TType + args: TFunctionArgument[] +}; + +export type TFunctionArgument = { + name: string + type: TType + doc: string +}; + +export interface IVarDoc { + name: string + type: TType + doc: string +} + +export interface IScriptInfo { + stdLibVersion: number, + contentType: number, + scriptType: number + imports: string[] +} + +export interface IFlattenedCompilationResult { + ast?: object + base64?: string + bytes?: Uint8Array + size?: number + complexity?: number + verifierComplexity?: number + callableComplexities?: Record + userFunctionComplexities?: Record + error?: string +} + +export function compile( + code: string, + estimatorVersion?: number, + needCompaction?: boolean, + removeUnusedCode?: boolean, + libraries?: Record +): ICompilationResult | ICompilationError; + +export function flattenCompilationResult(compiled: ICompilationResult | ICompilationError): IFlattenedCompilationResult + +export function parseAndCompile( + code: string, + estimatorVersion?: number, + needCompaction?: boolean, + removeUnusedCode?: boolean, + libs?: Record +): IParseAndCompileResult | ICompilationError; + +export function scriptInfo(code: string): IScriptInfo | ICompilationError; + +export function getTypes(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): TStructField[]; + +export function getVarsDoc(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): IVarDoc[]; + +export function getFunctionsDoc(stdlibVersion?: number, isTokenContext?: boolean, isContract?: boolean): TFunction[]; + +export function decompile(compiledCode: string): IDecompilationResult | IDecompilationError; + +export interface IReplOptions { + nodeUrl: string + chainId: string + address: string +} + +export function repl(opts?: IReplOptions): { + reconfigure: (opts: IReplOptions) => ReturnType + evaluate: (expr: string) => Promise, + clear: () => void, + test: (str: string) => Promise, + info: (s: string) => string, + totalInfo: () => string, +}; + +export const version: string; +export const contractLimits: { + MaxComplexityByVersion: (v: number) => number, + MaxExprSizeInBytes: number, + MaxContractSizeInBytes: number, + MaxContractInvocationArgs: number, + MaxContractInvocationSizeInBytes: number, + MaxWriteSetSizeInBytes: number, + MaxPaymentAmount: number +}; + +export interface IPos { + posStart: number, + posEnd: number +} + +export interface IName extends IPos { + value: string, +} + +export interface IContext extends IPos { + name: string +} + + +export interface IConstByteStr extends IExprNode { + type: 'CONST_BYTESTR' +} + +export interface IConstLong extends IExprNode { + type: 'CONST_LONG' +} + +export interface IConstStr extends IExprNode { + type: 'CONST_STRING' +} + +export interface ITrue extends IExprNode { + type: 'TRUE' +} + +export interface IFalse extends IExprNode { + type: 'FALSE' +} + +export interface IRef extends IExprNode { + type: 'REF' + name: string +} + +export interface IBlock extends IExprNode { + type: 'BLOCK' + dec: TDecl + body: TExpr +} + + +export interface IIf extends IExprNode { + type: 'IF' + cond: TExpr + ifTrue: TExpr + ifFalse: TExpr +} + + +export interface IGetter extends IExprNode { + type: 'GETTER' + ref: TExpr + field: IName + name: string +} + +export interface IMatch extends IExprNode { + type: 'MATCH' + expr: TExpr + cases: IMatchCase[] +} + +//------------------------ +export interface IMatchCase extends INode { + type: 'MATCH_CASE' + expr: TExpr +} + +export interface ILet extends INode { + type: 'LET' + name: IName + expr: TExpr + dec?: TDecl +} + +export interface IScript extends Exclude { + type: 'SCRIPT' + expr: TExpr +} + +export interface IDApp extends Exclude { + type: 'DAPP' + decList: (ILet | IFunc)[] + annFuncList: IAnnotatedFunc[] +} + +export interface IAnnotatedFunc extends Exclude { + type: 'ANNOTATEDFUNC', + annList: IAnnotation[], + func: IFunc +} + +export interface IAnnotation extends Exclude { + type: 'ANNOTATION', + name: IName, + argList: IName[] +} + +export interface IFunc extends INode { + type: 'FUNC' + name: IName + expr: TExpr + argList: TArgument[] + body: IBlock | IFunctionCall +} + +export type TArgument = { argName: IName, type: TArgumentType } +export type TArgumentType = { typeName: IName, typeParam?: ITypeParam } + +export interface ITypeParam extends IPos { + value: { isUnion: boolean, typeList: TArgumentType[] } +} + +export interface IFunctionCall extends IExprNode { + type: 'FUNCTION_CALL' + name: IName + args: TExpr[] +} + +export interface INode extends IPos { + type: TNodeType + resultType: string + ctx: IContext[] +} + +export type TExprResultType = { type: string } | { unionTypes: TExprResultType[] } | { listOf: TExprResultType } + +export interface IExprNode extends Omit { + resultType: TExprResultType +} + +export interface IError extends IPos { + msg: string +} + +export interface IParseAndCompileResult { + result: ArrayBuffer + complexity: number + errorList: IError[] + exprAst?: IScript + dAppAst?: IDApp +} + +export type TPrimitiveNode = IConstStr | IConstLong | IConstByteStr | ITrue | IFalse + +export type TNode = + | IBlock + | IConstByteStr + | IIf + | IFunctionCall + | IConstLong + | IRef + | IConstStr + | ITrue + | IFalse + | IGetter + | IMatch + | ILet + | IMatchCase + | IFunc + | IScript + | IDApp + | IAnnotatedFunc + | IAnnotation +export type TNodeType = + | 'BLOCK' + | 'LET' + | 'CONST_BYTESTR' + | 'IF' + | 'FUNCTION_CALL' + | 'CONST_LONG' + | 'REF' + | 'CONST_STRING' + | 'TRUE' + | 'FALSE' + | 'GETTER' + | 'MATCH' + | 'MATCH_CASE' + | 'FUNC' + | 'SCRIPT' + | 'DAPP' + | 'ANNOTATEDFUNC' + | 'ANNOTATION' +export type TDecl = ILet | IFunc +export type TExpr = + | IBlock + | IConstByteStr + | IIf + | IFunctionCall + | IConstLong + | IConstStr + | ITrue + | IFalse + | IGetter + | IMatch + | IRef diff --git a/ride-js-bundle/src/index.ts b/ride-js-bundle/src/index.ts new file mode 100644 index 00000000000..3324854e49c --- /dev/null +++ b/ride-js-bundle/src/index.ts @@ -0,0 +1,124 @@ +// Public @waves/ride-js API. Ported from the original ride-js src/index.js. +// The single substantive change vs. the original: instead of requiring the two +// separate npm packages (@waves/ride-lang + @waves/ride-repl) — each carrying its +// own copy of the ScalaJS runtime — this requires ONE combined ScalaJS artifact +// (scalajs/ride-scalajs.js, the linked repl-js output) that exports both the +// compiler API and the repl API. So ScalaJS is bundled once. +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-var-requires */ +require("./interop"); // side effect: installs crypto/http globals before the artifact runs +const crypto: any = require("@waves/ts-lib-crypto"); +const scalajs: any = require("../scalajs/ride-scalajs.js"); + +// The combined artifact exposes both the compiler exports (from lang-js JsAPI) +// and the repl exports (from repl-js JsAPI) as one module. +const scalaJsCompiler = scalajs; +const replJs = scalajs; + +function wrappedCompile( + code: string, + estimatorVersion = 3, + needCompaction = false, + removeUnusedCode = false, + libraries: Record = {} +): any { + if (typeof code !== "string") { + return { + error: "Type error: contract should be string" + }; + } + try { + const result = scalaJsCompiler.compile(code, estimatorVersion, needCompaction, removeUnusedCode, libraries); + if (result.error) { + try { + result.size = new Uint8Array(result.result).length; + } catch (e) { + // ignore: failed compilations may not carry bytes + } + return result; + } else { + const bytes = new Uint8Array(result.result); + const { + ast, + complexity, + verifierComplexity, + callableComplexities, + userFunctionComplexities, + globalVariableComplexities + } = result; + return { + result: { + bytes, + base64: crypto.base64Encode(bytes), + size: bytes.byteLength, + ast, + complexity, + verifierComplexity, + callableComplexities, + userFunctionComplexities, + globalVariableComplexities + } + }; + } + } catch (e: any) { + console.log(e); + return typeof e === "object" ? { error: e.message } : { error: e }; + } +} + +function wrappedRepl(opts?: { nodeUrl: string; chainId: string; address: string }): any { + const repl = + opts != null + ? replJs.repl(new replJs.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address)) + : replJs.repl(); + + const wrapReconfigure = (repl: any): any => { + const reconfigureFn = repl.reconfigure.bind(repl); + return (opts: { nodeUrl: string; chainId: string; address: string }) => { + const settings = new replJs.NodeConnectionSettings(opts.nodeUrl, opts.chainId.charCodeAt(0), opts.address); + const newRepl = reconfigureFn(settings); + newRepl.reconfigure = wrapReconfigure(newRepl); + return newRepl; + }; + }; + + repl.reconfigure = wrapReconfigure(repl); + + return repl; +} + +const flattenCompilationResult = (compiled: any): any => { + let result: any = {}; + if (compiled.error) { + if (compiled.result) { + const bytes = new Uint8Array(compiled.result); + const base64 = crypto.base64Encode(bytes); + result = { ...compiled, base64 }; + result.result && delete result.result; + } + } else { + result = compiled.result; + } + return result; +}; + +const api: any = { + compile: wrappedCompile, + repl: wrappedRepl, + get contractLimits() { + return scalaJsCompiler.contractLimits(); + }, + get version() { + const version = scalaJsCompiler.nodeVersion(); + return version && version.version; + }, + scriptInfo: scalaJsCompiler.scriptInfo, + getTypes: scalaJsCompiler.getTypes, + getVarsDoc: scalaJsCompiler.getVarsDoc, + getFunctionsDoc: scalaJsCompiler.getFunctionsDoc, + decompile: scalaJsCompiler.decompile, + flattenCompilationResult, + parseAndCompile: scalaJsCompiler.parseAndCompile +}; + +(global as any).RideJS = api; +export = api; diff --git a/ride-js-bundle/src/interop.ts b/ride-js-bundle/src/interop.ts new file mode 100644 index 00000000000..776db733a3e --- /dev/null +++ b/ride-js-bundle/src/interop.ts @@ -0,0 +1,66 @@ +// Sets the crypto/http primitives the ScalaJS compiler & repl resolve from the +// global scope. Ported from the original @waves/ride-js src/interop.js. Must run +// before the ScalaJS artifact is required. +/* eslint-disable @typescript-eslint/no-explicit-any */ +const crypto: any = require("@waves/ts-lib-crypto"); +const axios: any = require("axios"); + +const g = global as any; + +g.base58Encode = function (bytes: ArrayBuffer | Uint8Array | number[]) { + return crypto.base58Encode(new Uint8Array(bytes as any)); +}; +g.base58Decode = function (data: string) { + return crypto.base58Decode(data).buffer; +}; +g.base64Encode = function (bytes: ArrayBuffer | Uint8Array | number[]) { + return crypto.base64Encode(new Uint8Array(bytes as any)); +}; +g.base64Decode = function (data: string) { + return crypto.base64Decode(data); +}; +g.keccak256 = function (bytes: ArrayBuffer | Uint8Array | number[]) { + return Uint8Array.from(crypto.keccak(new Uint8Array(bytes as any))).buffer; +}; +g.sha256 = function (bytes: ArrayBuffer | Uint8Array | number[]) { + return Buffer.from(crypto.sha256(new Uint8Array(bytes as any)), "hex"); +}; +g.blake2b256 = function (bytes: ArrayBuffer | Uint8Array | number[]) { + return crypto.blake2b(new Uint8Array(bytes as any)).buffer; +}; +g.curve25519verify = function (msg: ArrayBuffer, sig: ArrayBuffer, key: ArrayBuffer) { + return crypto.verifySignature(new Uint8Array(key), new Uint8Array(msg), new Uint8Array(sig)); +}; +g.merkleVerify = function (rootHash: ArrayBuffer, merkleProof: ArrayBuffer, leafData: ArrayBuffer) { + return crypto.merkleVerify(new Uint8Array(rootHash), new Uint8Array(merkleProof), new Uint8Array(leafData)); +}; +g.rsaVerify = function (digest: any, msg: ArrayBuffer, sig: ArrayBuffer, key: ArrayBuffer) { + let alg = digest.toString(); + switch (digest.toString()) { + case "SHA3224": + alg = "SHA3-224"; + break; + case "SHA3256": + alg = "SHA3-256"; + break; + case "SHA3384": + alg = "SHA3-384"; + break; + case "SHA3512": + alg = "SHA3-512"; + break; + case "NONE": + alg = undefined; + break; + } // fixme + return crypto.rsaVerify(new Uint8Array(key), new Uint8Array(msg), new Uint8Array(sig), alg); +}; +g.httpGet = async function (data: any) { + if (!data.url) return { ...data, status: 404, body: "url is undefined" }; + const resp = await axios.get(data.url, { validateStatus: () => true }); + const status = resp.status; + let body = await resp.data; + if (typeof body !== "string") body = JSON.stringify(body); + return { ...data, status, body }; +}; +export {}; diff --git a/ride-js-bundle/test/api.test.ts b/ride-js-bundle/test/api.test.ts new file mode 100644 index 00000000000..dbf4648fbc8 --- /dev/null +++ b/ride-js-bundle/test/api.test.ts @@ -0,0 +1,57 @@ +// Smoke tests for the wrapped @waves/ride-js public API (the glue layer), which the +// compiler-focused builtInFunctions suite does not exercise directly. Guards the +// shapes that consumers depend on for API compatibility. +import { describe, test, expect } from "vitest"; +import { createRequire } from "module"; + +const require = createRequire(import.meta.url); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const ride = require("../dist/index.js"); + +describe("ride-js public API", () => { + test("compile wraps a successful result under .result with bytes/base64/size/complexity", () => { + const r = ride.compile("true"); + expect(r.error).toBeUndefined(); + expect(r.result.bytes).toBeInstanceOf(Uint8Array); + expect(typeof r.result.base64).toBe("string"); + expect(r.result.size).toBe(r.result.bytes.byteLength); + expect(typeof r.result.complexity).toBe("number"); + }); + + test("compile returns a flat { error } on failure", () => { + const r = ride.compile("1 + 1"); + expect(r.result).toBeUndefined(); + expect(String(r.error)).toContain("Script should return boolean"); + }); + + test("compile rejects non-string input", () => { + const r = ride.compile(42 as unknown as string); + expect(r.error).toBe("Type error: contract should be string"); + }); + + test("flattenCompilationResult unwraps a success to a flat object", () => { + const flat = ride.flattenCompilationResult(ride.compile("true")); + expect(typeof flat.base64).toBe("string"); + expect(typeof flat.complexity).toBe("number"); + expect(flat.error).toBeUndefined(); + }); + + test("repl() exposes evaluate/info/totalInfo/clear/reconfigure", () => { + const repl = ride.repl(); + for (const k of ["evaluate", "info", "totalInfo", "clear", "reconfigure"]) { + expect(typeof repl[k]).toBe("function"); + } + }); + + test("version is a string and contractLimits exposes expected members", () => { + expect(typeof ride.version).toBe("string"); + expect(typeof ride.contractLimits.MaxExprSizeInBytes).toBe("number"); + expect(typeof ride.contractLimits.MaxComplexityByVersion).toBe("function"); + }); + + test("passthroughs are present", () => { + for (const k of ["scriptInfo", "getTypes", "getVarsDoc", "getFunctionsDoc", "decompile", "parseAndCompile"]) { + expect(typeof ride[k]).toBe("function"); + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBinary.test.ts b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBinary.test.ts new file mode 100644 index 00000000000..cd2f5f58541 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBinary.test.ts @@ -0,0 +1,64 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("GetBinary", () => { + // getBinary + const getBinary = `getBinary(callerTestData, ${randomStringArrayElement()})` + const getBinaryArgBeforeFunc = `callerTestData.getBinary(${randomStringArrayElement()})` + const ownDataGetBinary = `getBinary(${randomStringArrayElement()})` + const ownDataGetBinaryArgBeforeFunc = `${randomStringArrayElement()}.getBinary()` + + // getBinaryValue + const getBinaryValue = `getBinaryValue(callerTestData, ${randomStringArrayElement()})` + const getBinaryValueArgBeforeFunc = `callerTestData.getBinaryValue(${randomStringArrayElement()})` + const ownDataGetBinaryValue = `getBinaryValue(${randomStringArrayElement()})` + const ownDataGetBinaryValueArgBeforeFunc = `${randomStringArrayElement()}.getBinaryValue()` + + const invalidGetBinary = `getBinary(callerTestData)` + const invalidGetBinaryValue = `getBinaryValue(callerTestData)` + + test("RIDE-4. Compile getBinary functions for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [addressOrAlias, binary] of [[randomAddressDataArrayElement(), getBinary], [randomAddressDataArrayElement(), getBinaryArgBeforeFunc], [randomAliasDataArrayElement(), getBinary], [randomAliasDataArrayElement(), getBinaryArgBeforeFunc], [randomAddressDataArrayElement(), getBinaryValue], [randomAddressDataArrayElement(), getBinaryValueArgBeforeFunc], [randomAliasDataArrayElement(), getBinaryValue], [randomAliasDataArrayElement(), getBinaryValueArgBeforeFunc], [thisVariable, getBinary], [thisVariable, getBinaryArgBeforeFunc], [thisVariable, getBinaryValue], [thisVariable, getBinaryValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-5. Compile own data getBinary functions for address, alias, and 'this'", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("ByteVector", version) + for (const ownData of [ownDataGetBinary, ownDataGetBinaryArgBeforeFunc, ownDataGetBinaryValueArgBeforeFunc, ownDataGetBinaryValue]) { + const script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-6. Test negative scenarios for getBinary functions", () => { + const invalidFunction = `getBinaryValue(${randomInt()})` + const invalidArgBeforeFunction = `${randomInt()}.getBinaryValue()` + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [addressOrAlias, binary] of [[randomAddressDataArrayElement(), invalidGetBinary], [randomAliasDataArrayElement(), invalidGetBinaryValue], [randomInt(), getBinary], [randomInt(), getBinaryValue], [randomInt(), invalidFunction], [randomInt(), invalidArgBeforeFunction]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-7. Ensure no overload of own data Binary accountDataStorage for old versions", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [addressOrAlias, binary] of [[randomAddressDataArrayElement(), ownDataGetBinaryValue], [randomAliasDataArrayElement(), ownDataGetBinaryValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBoolean.test.ts b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBoolean.test.ts new file mode 100644 index 00000000000..85e4c5c01e2 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getBoolean.test.ts @@ -0,0 +1,64 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBooleanEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("GetBoolean", () => { + // getBoolean + const getBoolean = `getBoolean(callerTestData, ${randomStringArrayElement()})` + const getBooleanArgBeforeFunc = `callerTestData.getBoolean(${randomStringArrayElement()})` + const ownDataGetBoolean = `getBoolean(${randomStringArrayElement()})` + const ownDataGetBooleanArgBeforeFunc = `${randomStringArrayElement()}.getBoolean()` + + // getBooleanValue + const getBooleanValue = `getBooleanValue(callerTestData, ${randomStringArrayElement()})` + const getBooleanValueArgBeforeFunc = `callerTestData.getBooleanValue(${randomStringArrayElement()})` + const ownDataGetBooleanValue = `getBooleanValue(${randomStringArrayElement()})` + const ownDataGetBooleanValueArgBeforeFunc = `${randomStringArrayElement()}.getBooleanValue()` + + const invalidGetBoolean = `getBoolean(callerTestData)` + const invalidGetBooleanValue = `getBooleanValue(callerTestData)` + + test("RIDE-8. Compile getBoolean functions for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, booleanData] of [[randomAddressDataArrayElement(), getBoolean], [randomAddressDataArrayElement(), getBooleanArgBeforeFunc], [randomAliasDataArrayElement(), getBoolean], [randomAliasDataArrayElement(), getBooleanArgBeforeFunc], [randomAddressDataArrayElement(), getBooleanValue], [randomAddressDataArrayElement(), getBooleanValueArgBeforeFunc], [randomAliasDataArrayElement(), getBooleanValue], [randomAliasDataArrayElement(), getBooleanValueArgBeforeFunc], [thisVariable, getBoolean], [thisVariable, getBooleanArgBeforeFunc], [thisVariable, getBooleanValue], [thisVariable, getBooleanValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-9. Compile own data getBoolean functions for address, alias, and 'this'", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Boolean", version) + for (const ownData of [ownDataGetBoolean, ownDataGetBooleanArgBeforeFunc, ownDataGetBooleanValueArgBeforeFunc, ownDataGetBooleanValue]) { + const script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-10. Negative tests for getBoolean functions", () => { + const invalidFunction = `getBooleanValue(${randomInt()})` + const invalidArgBeforeFunction = `${randomInt()}.getBooleanValue()` + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, booleanData] of [[randomAddressDataArrayElement(), invalidGetBoolean], [randomAliasDataArrayElement(), invalidGetBooleanValue], [randomInt(), getBoolean], [randomInt(), getBooleanValue], [randomInt(), invalidFunction], [randomInt(), invalidArgBeforeFunction]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-11. Ensure no overload of own data Boolean accountDataStorage for old Versions", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, booleanData] of [[randomAddressDataArrayElement(), ownDataGetBooleanValue], [randomAliasDataArrayElement(), ownDataGetBooleanValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, booleanData, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/accountDataStorage/getInteger.test.ts b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getInteger.test.ts new file mode 100644 index 00000000000..92bf5561d3f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getInteger.test.ts @@ -0,0 +1,64 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("GetInteger", () => { + // getInteger + const getInteger = `getInteger(callerTestData, ${randomStringArrayElement()})` + const getIntegerArgBeforeFunc = `callerTestData.getInteger(${randomStringArrayElement()})` + const ownDataGetInt = `getInteger(${randomStringArrayElement()})` + const ownDataGetIntArgBeforeFunc = `${randomStringArrayElement()}.getInteger()` + + // getIntegerValue + const getIntegerValue = `getIntegerValue(callerTestData, ${randomStringArrayElement()})` + const getIntegerValueArgBeforeFunc = `callerTestData.getIntegerValue(${randomStringArrayElement()})` + const ownDataGetIntValue = `getIntegerValue(${randomStringArrayElement()})` + const ownDataGetIntValueArgBeforeFunc = `${randomStringArrayElement()}.getIntegerValue()` + + const invalidGetInt = `getInteger(callerTestData)` + const invalidGetIntValue = `getIntegerValue(callerTestData)` + + test("RIDE-12. Compile getInteger functions for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [addressOrAlias, intData] of [[randomAddressDataArrayElement(), getInteger], [randomAddressDataArrayElement(), getIntegerArgBeforeFunc], [randomAliasDataArrayElement(), getInteger], [randomAliasDataArrayElement(), getIntegerArgBeforeFunc], [randomAddressDataArrayElement(), getIntegerValue], [randomAddressDataArrayElement(), getIntegerValueArgBeforeFunc], [randomAliasDataArrayElement(), getIntegerValue], [randomAliasDataArrayElement(), getIntegerValueArgBeforeFunc], [thisVariable, getInteger], [thisVariable, getIntegerArgBeforeFunc], [thisVariable, getIntegerValue], [thisVariable, getIntegerValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-13. Compile own data getInteger functions for address, alias, and 'this'", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Int", version) + for (const ownData of [ownDataGetInt, ownDataGetIntArgBeforeFunc, ownDataGetIntValueArgBeforeFunc, ownDataGetIntValue]) { + const script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-14. Test negative scenarios for getInteger functions", () => { + const invalidFunction = `getIntegerValue(${randomInt()})` + const invalidArgBeforeFunction = `${randomInt()}.getIntegerValue()` + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [addressOrAlias, intData] of [[randomAddressDataArrayElement(), invalidGetInt], [randomAliasDataArrayElement(), invalidGetIntValue], [randomInt(), getInteger], [randomInt(), getIntegerValue], [randomInt(), invalidFunction], [randomInt(), invalidArgBeforeFunction]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-15. Ensure no overload of own data Integer accountDataStorage for old versions", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [addressOrAlias, intData] of [[randomAddressDataArrayElement(), ownDataGetIntValue], [randomAliasDataArrayElement(), ownDataGetIntValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, intData, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/accountDataStorage/getString.test.ts b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getString.test.ts new file mode 100644 index 00000000000..eec16833dc8 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/accountDataStorage/getString.test.ts @@ -0,0 +1,64 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("GetString", () => { + // getString + const getString = `getString(callerTestData, ${randomStringArrayElement()})` + const getStringArgBeforeFunc = `callerTestData.getString(${randomStringArrayElement()})` + const ownDataGetString = `getString(${randomStringArrayElement()})` + const ownDataGetStringArgBeforeFunc = `${randomStringArrayElement()}.getString()` + + // getStringValue + const getStringValue = `getStringValue(callerTestData, ${randomStringArrayElement()})` + const getStringValueArgBeforeFunc = `callerTestData.getStringValue(${randomStringArrayElement()})` + const ownDataGetStringValue = `getStringValue(${randomStringArrayElement()})` + const ownDataGetStringValueArgBeforeFunc = `${randomStringArrayElement()}.getStringValue()` + + const invalidGetString = `getString(callerTestData)` + const invalidGetStringValue = `getStringValue(callerTestData)` + + test("RIDE-16. Compile getString functions for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [addressOrAlias, stringData] of [[randomAddressDataArrayElement(), getString], [randomAddressDataArrayElement(), getStringArgBeforeFunc], [randomAliasDataArrayElement(), getString], [randomAliasDataArrayElement(), getStringArgBeforeFunc], [randomAddressDataArrayElement(), getStringValue], [randomAddressDataArrayElement(), getStringValueArgBeforeFunc], [randomAliasDataArrayElement(), getStringValue], [randomAliasDataArrayElement(), getStringValueArgBeforeFunc], [thisVariable, getString], [thisVariable, getStringArgBeforeFunc], [thisVariable, getStringValue], [thisVariable, getStringValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-17. Compile own data getString functions for address, alias, and 'this'", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("String", version) + for (const ownData of [ownDataGetString, ownDataGetStringArgBeforeFunc, ownDataGetStringValueArgBeforeFunc, ownDataGetStringValue]) { + const script = precondition.codeOwnData(ownData, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-18. Test negative scenarios for getString functions", () => { + const invalidFunction = `getStringValue(${randomInt()})` + const invalidArgBeforeFunction = `${randomInt()}.getStringValue()` + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [addressOrAlias, stringData] of [[randomAddressDataArrayElement(), invalidGetString], [randomAliasDataArrayElement(), invalidGetStringValue], [randomInt(), getString], [randomInt(), getStringValue], [randomInt(), invalidFunction], [randomInt(), invalidArgBeforeFunction]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-19. Ensure no overload of own data Integer accountDataStorage for old versions", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("String", version) + for (const [addressOrAlias, stringData] of [[randomAddressDataArrayElement(), ownDataGetStringValue], [randomAliasDataArrayElement(), ownDataGetStringValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, stringData, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/accountDataStorage/isDataStorageUntouched.test.ts b/ride-js-bundle/test/builtInFunctions/accountDataStorage/isDataStorageUntouched.test.ts new file mode 100644 index 00000000000..bfb1932da13 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/accountDataStorage/isDataStorageUntouched.test.ts @@ -0,0 +1,52 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, GreaterV3ResultBooleanEntry, invalidFunctionError, nonMatchingTypes, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("IsDataStorageUntouched", () => { + const isDataStorageUntouched = "isDataStorageUntouched(callerTestData)" + const isDataStorageUntouchedArgBeforeFunc = "callerTestData.isDataStorageUntouched()" + const invalidFunction = "isDataStorageUntouched()" + const invalidFunctionErrorResult = invalidFunctionError("isDataStorageUntouched", 1) + + test("RIDE-20. Compile isDataStorageUntouched functions for address, alias, and 'this'", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, dataStorage] of [[randomAddressDataArrayElement(), isDataStorageUntouched], [randomAddressDataArrayElement(), isDataStorageUntouchedArgBeforeFunc], [randomAliasDataArrayElement(), isDataStorageUntouched], [randomAliasDataArrayElement(), isDataStorageUntouchedArgBeforeFunc], [thisVariable, isDataStorageUntouched], [thisVariable, isDataStorageUntouchedArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-21. Non-matching types for function isDataStorageUntouched", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, dataStorage] of [[randomInt(), isDataStorageUntouched], [randomInt(), isDataStorageUntouchedArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, nonMatchingTypes("Address|Alias")) + } + } + }); + + test("RIDE-22. Invalid data for functions isDataStorageUntouched", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, dataStorage] of [[randomAddressDataArrayElement(), invalidFunction], [randomAliasDataArrayElement(), invalidFunction], [thisVariable, invalidFunction]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, invalidFunctionErrorResult) + } + } + }); + + test("RIDE-23. Can't find functions isDataStorageUntouched dataStorage accountDataStorage for old Versions", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [addressOrAlias, dataStorage] of [[randomAddressDataArrayElement(), isDataStorageUntouchedArgBeforeFunc], [thisVariable, isDataStorageUntouchedArgBeforeFunc], [randomAliasDataArrayElement(), isDataStorageUntouched]]) { + const script = precondition.codeFromMatchingAndCase(addressOrAlias, dataStorage, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/addressFromRecipient.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/addressFromRecipient.test.ts new file mode 100644 index 00000000000..4d63f757a2e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/addressFromRecipient.test.ts @@ -0,0 +1,43 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorExpression, assertCompileSuccessExpression } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes, thisVariable } from "../../helpers/testData"; + +describe("AddressFromRecipient", () => { + const addressFromRecipient = "addressFromRecipient(addressOrAlias)" + const addressFromRecipientArgBeforeFunc = "addressOrAlias.addressFromRecipient()" + const invalidFunc = "addressFromRecipient()" + + test("RIDE-24. Compile addressFromRecipient function for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [addressOrAlias, func, address] of [[randomAddressDataArrayElement(), addressFromRecipient, randomAddressDataArrayElement()], [randomAliasDataArrayElement(), addressFromRecipient, randomAddressDataArrayElement()], [thisVariable, addressFromRecipient, randomAddressDataArrayElement()], [randomAddressDataArrayElement(), addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement()], [randomAliasDataArrayElement(), addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement()], [thisVariable, addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement()]]) { + const script = precondition.codeForAddressFromRecipient(addressOrAlias, func, address) + assertCompileSuccessExpression(script, version) + } + } + }); + + test("RIDE-25. Invalid data for functions addressFromRecipient", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [addressOrAlias, func, address] of [[randomInt(), addressFromRecipient, randomAddressDataArrayElement()], [randomInt(), addressFromRecipientArgBeforeFunc, randomAddressDataArrayElement()]]) { + const script = precondition.codeForAddressFromRecipient(addressOrAlias, func, address) + assertCompileErrorExpression(script, version, nonMatchingTypes("Address|Alias")) + } + } + }); + + test("RIDE-26. Function 'addressFromRecipient' requires 1 arguments", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + const script = precondition.codeForAddressFromRecipient( + randomAddressDataArrayElement(), + invalidFunc, + randomAddressDataArrayElement() + ) + assertCompileErrorExpression(script, version, invalidFunctionError("addressFromRecipient", 1)) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/assetBalance.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/assetBalance.test.ts new file mode 100644 index 00000000000..32bd0208689 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/assetBalance.test.ts @@ -0,0 +1,35 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { GreaterV3ResultIntegerEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result, thisVariable } from "../../helpers/testData"; + +describe("AssetBalance", () => { + const address = randomAddressDataArrayElement() + const alias = randomAliasDataArrayElement() + const byteVector = randomByteVectorArrayElement() + + const assetBalance = `assetBalance(callerTestData, ${byteVector})` + const assetBalanceArgBeforeFunc = `callerTestData.assetBalance(${byteVector})` + const invalidAssetBalanceFunc = "assetBalance()" + + test("RIDE-27. Compile assetBalance function for address, alias, and 'this'", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [addressOrAlias, func] of [[address, assetBalance], [alias, assetBalance], [thisVariable, assetBalance], [address, assetBalanceArgBeforeFunc], [alias, assetBalanceArgBeforeFunc], [thisVariable, assetBalanceArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(addressOrAlias, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-28. Invalid data must be validated", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [addressOrAlias, func, error] of [[address, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)], [alias, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)], [thisVariable, invalidAssetBalanceFunc, invalidFunctionError("assetBalance", 2)], [randomUnionArrayElement(), assetBalance, nonMatchingTypes("Address|Alias")], [randomByteVectorArrayElement(), assetBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")]]) { + const script = precondition.codeWithoutMatcher(addressOrAlias, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/assetInfo.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/assetInfo.test.ts new file mode 100644 index 00000000000..dca3fd0b7e0 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/assetInfo.test.ts @@ -0,0 +1,34 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomInt } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("AssetInfo", () => { + const assetInfo = "assetInfo(callerTestData)" + const assetInfoArgBeforeFunc = "callerTestData.assetInfo()" + + const invalidAssetInfo = "assetInfo()" + const invalidAssetInfoArg = `${randomInt()}.assetInfo()` + + + test("RIDE-30. Compile assetInfo function for asset", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Asset", version) + for (const [asset, func] of [[randomByteVectorArrayElement(), assetInfo], [randomByteVectorArrayElement(), assetInfoArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(asset, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-29. Invalid data must be validated", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Asset", version) + for (const [asset, func, error] of [[randomByteVectorArrayElement(), invalidAssetInfo, invalidFunctionError("assetInfo", 1)], [randomByteVectorArrayElement(), invalidAssetInfoArg, nonMatchingTypes("ByteVector")], [randomAliasDataArrayElement(), assetInfo, nonMatchingTypes("ByteVector")], [randomBoolean(), assetInfoArgBeforeFunc, nonMatchingTypes("ByteVector")]]) { + const script = precondition.onlyMatcherContract(asset, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/blockInfoByHeight.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/blockInfoByHeight.test.ts new file mode 100644 index 00000000000..fc466bc347e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/blockInfoByHeight.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomInt } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("BlockInfoByHeight", () => { + const blockInfoByHeight = "blockInfoByHeight(callerTestData)" + const blockInfoByHeightArgBeforeFunc = "callerTestData.blockInfoByHeight()" + + const invalidBlockInfoByHeight = "blockInfoByHeight()" + + test("RIDE-31. BlockInfoByHeight function should compile", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("BlockInfo", version) + for (const [intData, func] of [[randomInt(), blockInfoByHeight], [randomInt(), blockInfoByHeightArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(intData, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-32. Negative cases for blockInfoByHeight function when invalid arguments are passed", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("BlockInfo", version) + for (const [intData, func, error] of [[randomInt(), invalidBlockInfoByHeight, invalidFunctionError("blockInfoByHeight", 1)], [randomAliasDataArrayElement(), blockInfoByHeight, nonMatchingTypes("Int")], [randomBoolean(), blockInfoByHeightArgBeforeFunc, nonMatchingTypes("Int")]]) { + const script = precondition.onlyMatcherContract(intData, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/calculateAssetId.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/calculateAssetId.test.ts new file mode 100644 index 00000000000..1df47a4badf --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/calculateAssetId.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomDigestAlgorithmTypeArrayElement, randomIssuesArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("CalculateAssetId", () => { + const calculateAssetId = "calculateAssetId(issue)" + const calculateAssetIdArgBeforeFunc = "issue.calculateAssetId()" + const invalidCalculateAssetId = "calculateAssetId()" + + test("RIDE-33. CalculateAssetId function should compile for version V4 and higher when called for Issue operatio", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomIssuesArrayElement(), calculateAssetId], [randomIssuesArrayElement(), calculateAssetIdArgBeforeFunc]]) { + const script = precondition.codeForCalculateAssetId(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-34. Negative cases for CalculateAssetId function for version V4 and higher", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), calculateAssetId, nonMatchingTypes("Issue")], [randomDigestAlgorithmTypeArrayElement(), calculateAssetIdArgBeforeFunc, nonMatchingTypes("Issue")], [randomDigestAlgorithmTypeArrayElement(), invalidCalculateAssetId, invalidFunctionError("calculateAssetId", 1)]]) { + const script = precondition.codeForCalculateAssetId(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-35. Negative cases for CalculateAssetId function for version V3", () => { + const precondition = new ContractGenerator("", V3) + for (const [data, func] of [[randomIssuesArrayElement(), calculateAssetId], [randomIssuesArrayElement(), calculateAssetIdArgBeforeFunc]]) { + const script = precondition.codeForCalculateAssetId(data, func) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/calculateLeaseId.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/calculateLeaseId.test.ts new file mode 100644 index 00000000000..791ea7315ba --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/calculateLeaseId.test.ts @@ -0,0 +1,41 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4, V5 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomDigestAlgorithmTypeArrayElement, randomIssuesArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, CANT_FIND_FUNCTION, invalidFunctionError, oldVersions, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("CalculateLeaseId", () => { + const calculateLeaseId = "calculateLeaseId(lease)" + const calculateLeaseIdArgBeforeFunc = "lease.calculateLeaseId()" + const invalidCalculateLeaseId = "calculateLeaseId()" + + test("RIDE-36. calculateLeaseId function should compile for version V5 and higher when called for an address", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), calculateLeaseId], [randomAddressDataArrayElement(), calculateLeaseIdArgBeforeFunc], [randomAliasDataArrayElement(), calculateLeaseId], [randomAliasDataArrayElement(), calculateLeaseIdArgBeforeFunc]]) { + const script = precondition.codeForCalculateLeaseId(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-37. Negative cases for calculateLeaseId function for version V5 and higher", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [data, func, error] of [[randomStringArrayElement(), calculateLeaseId, CANT_FIND_A_FUNCTION_OVERLOAD], [randomDigestAlgorithmTypeArrayElement(), calculateLeaseIdArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomAddressDataArrayElement(), invalidCalculateLeaseId, invalidFunctionError("calculateLeaseId", 1)], [randomAliasDataArrayElement(), invalidCalculateLeaseId, invalidFunctionError("calculateLeaseId", 1)]]) { + const script = precondition.codeForCalculateLeaseId(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-38. Negative cases for calculateLeaseId function for versions V3 and V4", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomIssuesArrayElement(), calculateLeaseId], [randomIssuesArrayElement(), calculateLeaseIdArgBeforeFunc]]) { + const script = precondition.codeForCalculateLeaseId(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/scriptHash.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/scriptHash.test.ts new file mode 100644 index 00000000000..9b17d8100bd --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/scriptHash.test.ts @@ -0,0 +1,42 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4, V5 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, GreaterV3ResultBinaryEntry, invalidFunctionError, nonMatchingTypes, oldVersions, rideV3Result, thisVariable, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ScriptHash", () => { + const scriptHash = "scriptHash(callerTestData)" + const scriptHashArgBeforeFunc = "callerTestData.scriptHash()" + const invalidScriptHash = "scriptHash(callerTestData, callerTestData)" + const invalidScriptHashArgBeforeFunc = `callerTestData.scriptHash(${randomStringArrayElement()})` + + test("RIDE-39. ScriptHash function should compile for version V5 and higher when called for an address", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomAddressDataArrayElement(), scriptHash], [randomAddressDataArrayElement(), scriptHashArgBeforeFunc], [randomAliasDataArrayElement(), scriptHash], [randomAliasDataArrayElement(), scriptHashArgBeforeFunc], [thisVariable, scriptHash], [thisVariable, scriptHashArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("Ride-40. Negative cases for ScriptHash function for version V5 and higher", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomStringArrayElement(), scriptHash, nonMatchingTypes("Address|Alias")], [randomDigestAlgorithmTypeArrayElement(), scriptHashArgBeforeFunc, nonMatchingTypes("Address|Alias")], [randomAddressDataArrayElement(), invalidScriptHash, invalidFunctionError("scriptHash", 1)], [randomAliasDataArrayElement(), invalidScriptHash, invalidFunctionError("scriptHash", 1)], [thisVariable, invalidScriptHashArgBeforeFunc, invalidFunctionError("scriptHash", 1)]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-41. Negative cases for ScriptHash function for versions V3 and V4", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), scriptHash], [randomAliasDataArrayElement(), scriptHashArgBeforeFunc]]) { + const script = precondition.codeForCalculateLeaseId(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/transactionHeightById.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/transactionHeightById.test.ts new file mode 100644 index 00000000000..6fdd7dbf5c8 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/transactionHeightById.test.ts @@ -0,0 +1,34 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("TransactionHeightById", () => { + const transactionHeightById = "transactionHeightById(callerTestData)" + const transactionHeightByIdArgBeforeFunc = "callerTestData.transactionHeightById()" + + const invalidTransactionHeightById = "transactionHeightById()" + const invalidTransactionHeightByIdArg = `callerTestData.transactionHeightById(callerTestData)` + + + test("RIDE-42. TransactionHeightById function should compile", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomByteVectorArrayElement(), transactionHeightById], [randomByteVectorArrayElement(), transactionHeightByIdArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-43. Negative cases for TransactionHeightById function", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), transactionHeightById, nonMatchingTypes("ByteVector")], [randomStringArrayElement(), transactionHeightByIdArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidTransactionHeightById, invalidFunctionError("transactionHeightById", 1)], [randomByteVectorArrayElement(), invalidTransactionHeightByIdArg, invalidFunctionError("transactionHeightById", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/transferTransactionById.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/transferTransactionById.test.ts new file mode 100644 index 00000000000..f92fc18685a --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/transferTransactionById.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("TransferTransactionById", () => { + const transferTransactionById = "transferTransactionById(callerTestData)" + const transferTransactionByIdArgBeforeFunc = "callerTestData.transferTransactionById()" + + const invalidTransferTransactionById = "transferTransactionById()" + const invalidTransferTransactionByIdArg = `callerTestData.transferTransactionById(callerTestData)` + + test("RIDE-44. TransactionHeightById function should compile", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Unit", version) + for (const [data, func] of [[randomByteVectorArrayElement(), transferTransactionById], [randomByteVectorArrayElement(), transferTransactionByIdArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-45. Negative cases for TransactionHeightById function", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Unit", version) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), transferTransactionById, nonMatchingTypes("ByteVector")], [randomStringArrayElement(), transferTransactionByIdArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidTransferTransactionById, invalidFunctionError("transferTransactionById", 1)], [randomByteVectorArrayElement(), invalidTransferTransactionByIdArg, invalidFunctionError("transferTransactionById", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/blockchain/wavesBalance.test.ts b/ride-js-bundle/test/builtInFunctions/blockchain/wavesBalance.test.ts new file mode 100644 index 00000000000..9a38596bd46 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/blockchain/wavesBalance.test.ts @@ -0,0 +1,48 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, thisVariable } from "../../helpers/testData"; + +describe("WavesBalance", () => { + const wavesBalance = "wavesBalance(callerTestData)" + const wavesBalanceArgBeforeFunc = "callerTestData.wavesBalance()" + const invalidWavesBalance = "wavesBalance()" + const invalidWavesBalanceArg = `callerTestData.wavesBalance(callerTestData)` + + test("RIDE-46. wavesBalance function for version V4 and more should compile for address, alias, and 'this'", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("BalanceDetails", version) + for (const [data, func] of [[randomAddressDataArrayElement(), wavesBalance], [randomAliasDataArrayElement(), wavesBalance], [thisVariable, wavesBalance], [randomAddressDataArrayElement(), wavesBalanceArgBeforeFunc], [randomAliasDataArrayElement(), wavesBalanceArgBeforeFunc], [thisVariable, wavesBalanceArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-47. Negative cases for wavesBalance function for version V4 and more", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("BalanceDetails", version) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), wavesBalance, nonMatchingTypes("Address|Alias")], [randomStringArrayElement(), wavesBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")], [randomAddressDataArrayElement(), invalidWavesBalanceArg, invalidFunctionError("wavesBalance", 1)], [randomAliasDataArrayElement(), invalidWavesBalance, invalidFunctionError("wavesBalance", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-48. Functions wavesBalance for V3 compiles for address, alias and 'this'", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, func] of [[randomAddressDataArrayElement(), wavesBalance], [randomAliasDataArrayElement(), wavesBalance], [thisVariable, wavesBalance], [randomAddressDataArrayElement(), wavesBalanceArgBeforeFunc], [randomAliasDataArrayElement(), wavesBalanceArgBeforeFunc], [thisVariable, wavesBalanceArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-49. compilation error: wavesBalance for V3 Non-matching type", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), wavesBalance, nonMatchingTypes("Address|Alias")], [randomStringArrayElement(), wavesBalanceArgBeforeFunc, nonMatchingTypes("Address|Alias")], [randomAddressDataArrayElement(), invalidWavesBalanceArg, invalidFunctionError("wavesBalance", 1)], [randomAliasDataArrayElement(), invalidWavesBalance, invalidFunctionError("wavesBalance", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, V3, error) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/byteArray/drop.test.ts b/ride-js-bundle/test/builtInFunctions/byteArray/drop.test.ts new file mode 100644 index 00000000000..5437740ad4e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/byteArray/drop.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Drop", () => { + const drop = `drop(callerTestData, ${randomInt()})` + const dropArgBeforeFunction = `callerTestData.drop(${randomInt()})` + const invalidDrop = `drop(callerTestData)` + const invalidDropNotInt = `drop(callerTestData, ${randomByteVectorArrayElement()})` + const invalidDropArgBeforeFunc = `callerTestData.drop(callerTestData, ${randomInt()})` + + test("RIDE-50. Drop function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomByteVectorArrayElement(), drop], [randomByteVectorArrayElement(), dropArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-51. Drop function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), drop], [randomUnionArrayElement(), dropArgBeforeFunction], [randomByteVectorArrayElement(), invalidDrop], [randomByteVectorArrayElement(), invalidDropNotInt], [randomByteVectorArrayElement(), invalidDropArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/byteArray/dropRight.test.ts b/ride-js-bundle/test/builtInFunctions/byteArray/dropRight.test.ts new file mode 100644 index 00000000000..21db3ff0df1 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/byteArray/dropRight.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("DropRight", () => { + const dropRight = `dropRight(callerTestData, ${randomInt()})` + const dropRightArgBeforeFunction = `callerTestData.dropRight(${randomInt()})` + const invalidDropRight = `dropRight(callerTestData)` + const invalidDropRightNotInt = `dropRight(callerTestData, ${randomByteVectorArrayElement()})` + const invalidDropRightArgBeforeFunc = `callerTestData.dropRight(callerTestData, ${randomInt()})` + + test("RIDE-52. DropRight function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomByteVectorArrayElement(), dropRight], [randomByteVectorArrayElement(), dropRightArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-53. DropRight function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), dropRight], [randomUnionArrayElement(), dropRightArgBeforeFunction], [randomByteVectorArrayElement(), invalidDropRight], [randomByteVectorArrayElement(), invalidDropRightArgBeforeFunc], [randomByteVectorArrayElement(), invalidDropRightNotInt]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/byteArray/size.test.ts b/ride-js-bundle/test/builtInFunctions/byteArray/size.test.ts new file mode 100644 index 00000000000..b9e0b5d9890 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/byteArray/size.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Size", () => { + const size = `size(callerTestData)` + const sizeArgBeforeFunction = `callerTestData.size()` + const invalidSize = `size()` + const invalidSizeArgBeforeFunc = `callerTestData.size(callerTestData, callerTestData)` + + test("RIDE-54. Size function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomByteVectorArrayElement(), size], [randomByteVectorArrayElement(), sizeArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-55. Size function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), size], [randomUnionArrayElement(), sizeArgBeforeFunction], [randomByteVectorArrayElement(), invalidSize], [randomByteVectorArrayElement(), invalidSizeArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/byteArray/take.test.ts b/ride-js-bundle/test/builtInFunctions/byteArray/take.test.ts new file mode 100644 index 00000000000..0ac63dc8573 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/byteArray/take.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Take", () => { + const take = `take(callerTestData, ${randomInt()})` + const takeArgBeforeFunction = `callerTestData.take(${randomInt()})` + const invalidTake = `take(callerTestData)` + const invalidTakeArgBeforeFunc = `callerTestData.take(callerTestData, ${randomInt()})` + const invalidTakeNotInt = `take(callerTestData, ${randomByteVectorArrayElement()})` + + test("RIDE-56. Take function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomByteVectorArrayElement(), take], [randomByteVectorArrayElement(), takeArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-57. Take function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), take], [randomUnionArrayElement(), takeArgBeforeFunction], [randomByteVectorArrayElement(), invalidTake], [randomByteVectorArrayElement(), invalidTakeArgBeforeFunc], [randomByteVectorArrayElement(), invalidTakeNotInt]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/byteArray/takeRight.test.ts b/ride-js-bundle/test/builtInFunctions/byteArray/takeRight.test.ts new file mode 100644 index 00000000000..cdac5b6daf7 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/byteArray/takeRight.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("TakeRight", () => { + const takeRight = `takeRight(callerTestData, ${randomInt()})` + const takeRightArgBeforeFunction = `callerTestData.takeRight(${randomInt()})` + const invalidTakeRight = `takeRight(callerTestData)` + const invalidTakeRightArgBeforeFunc = `callerTestData.takeRight(callerTestData, ${randomInt()})` + const invalidTakeRightNotInt = `takeRight(callerTestData, ${randomByteVectorArrayElement()})` + + test("RIDE-58. TakeRight function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomByteVectorArrayElement(), takeRight], [randomByteVectorArrayElement(), takeRightArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-59. TakeRight function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), takeRight], [randomUnionArrayElement(), takeRightArgBeforeFunction], [randomByteVectorArrayElement(), invalidTakeRight], [randomByteVectorArrayElement(), invalidTakeRightArgBeforeFunc], [randomByteVectorArrayElement(), invalidTakeRightNotInt]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/addressFromPublicKey.test.ts b/ride-js-bundle/test/builtInFunctions/converting/addressFromPublicKey.test.ts new file mode 100644 index 00000000000..41b93d8c81b --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/addressFromPublicKey.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("AddressFromPublicKey", () => { + const addressFromPublicKey = `addressFromPublicKey(callerTestData)` + const addressFromPublicKeyArgBeforeFunction = `callerTestData.addressFromPublicKey()` + const invalidAddressFromPublicKey = `addressFromPublicKey()` + const invalidAddressFromPublicKeyArgBeforeFunc = `callerTestData.addressFromPublicKey(callerTestData, callerTestData)` + const invalidAddressFromPublicKeyData = `addressFromPublicKey(callerTestData, ${randomUnionArrayElement()})` + + test("RIDE-60. AddressFromPublicKey function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Address", version) + for (const [data, func] of [[randomByteVectorArrayElement(), addressFromPublicKey], [randomByteVectorArrayElement(), addressFromPublicKeyArgBeforeFunction]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-61. AddressFromPublicKey function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomAddressDataArrayElement(), addressFromPublicKey, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), addressFromPublicKeyArgBeforeFunction, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidAddressFromPublicKey, invalidFunctionError("addressFromPublicKey", 1)], [randomAddressDataArrayElement(), invalidAddressFromPublicKeyArgBeforeFunc, invalidFunctionError("addressFromPublicKey", 1)], [randomAddressDataArrayElement(), invalidAddressFromPublicKeyData, invalidFunctionError("addressFromPublicKey", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/parseBigInt.test.ts b/ride-js-bundle/test/builtInFunctions/converting/parseBigInt.test.ts new file mode 100644 index 00000000000..a7cae298c34 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/parseBigInt.test.ts @@ -0,0 +1,80 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { UNDEFINED_TYPE, invalidFunctionError, nonMatchingTypes, oldVersions, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ParseBigInt", () => { + const parseBigInt = "parseBigInt(callerTestData)" + const parseBigIntArgBeforeFunc = "callerTestData.parseBigInt()" + const invalidFunctionParseBigInt = "parseBigInt()" + const invalidValueParseBigIntArgBeforeFunc = "callerTestData.parseBigInt(callerTestData, callerTestData)" + const invalidFunctionErrorResultParseBigInt = invalidFunctionError("parseBigInt", 1) + + const parseBigIntValue = "parseBigIntValue(callerTestData)" + const parseBigIntValueArgBeforeFunc = "callerTestData.parseBigIntValue()" + const invalidFunctionParseBigIntValue = "parseBigIntValue()" + const invalidValueParseBigIntValueArgBeforeFunc = "callerTestData.parseBigIntValue(callerTestData,callerTestData)" + + const invalidFunctionErrorResultParseBigIntValue = invalidFunctionError("parseBigIntValue", 1) + + test("RIDE-62. ParseBigInt function should compile for valid values", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomStringArrayElement(), parseBigInt], [randomStringArrayElement(), parseBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-63. ParseBigInt function throws an error for invalid values", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomStringArrayElement(), parseBigInt, UNDEFINED_TYPE], [randomStringArrayElement(), parseBigIntArgBeforeFunc, UNDEFINED_TYPE]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-64. Function parseBigInt should throw an error for invalid functions", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomInt(), parseBigInt, nonMatchingTypes("String")], [randomBoolean(), parseBigIntArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidFunctionParseBigInt, invalidFunctionErrorResultParseBigInt], [randomStringArrayElement(), invalidValueParseBigIntArgBeforeFunc, invalidFunctionErrorResultParseBigInt]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-65. ParseBigIntValue function should compile for valid values", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomStringArrayElement(), parseBigIntValue], [randomStringArrayElement(), parseBigIntValueArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-66. ParseBigIntValue function throws an error for invalid values", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomStringArrayElement(), parseBigIntValue, UNDEFINED_TYPE], [randomStringArrayElement(), parseBigIntValueArgBeforeFunc, UNDEFINED_TYPE]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-67. Function parseBigIntValue should throw an error for invalid functions", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomInt(), parseBigIntValue, nonMatchingTypes("String")], [randomBoolean(), parseBigIntValueArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidFunctionParseBigIntValue, invalidFunctionErrorResultParseBigIntValue], [randomStringArrayElement(), invalidValueParseBigIntValueArgBeforeFunc, invalidFunctionErrorResultParseBigIntValue]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/parseInt.test.ts b/ride-js-bundle/test/builtInFunctions/converting/parseInt.test.ts new file mode 100644 index 00000000000..c7a85d99af3 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/parseInt.test.ts @@ -0,0 +1,59 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { GreaterV3ResultIntegerEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../helpers/testData"; + +describe("ParseInt", () => { + // parseInt + const parseInt = "parseInt(callerTestData)" + const parseIntArgBeforeFunc = "callerTestData.parseInt()" + const invalidParseInt = "parseInt()" + const invalidParseIntArgBeforeFunc = "callerTestData.parseInt(callerTestData)" + + // parseIntValue + const parseIntValue = "parseIntValue(callerTestData)" + const parseIntValueArgBeforeFunc = "callerTestData.parseIntValue()" + const invalidParseIntValue = "parseIntValue()" + const invalidParseIntValueArgBeforeFunc = "callerTestData.parseIntValue(callerTestData)" + + test("RIDE-68. ParseInt function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomStringArrayElement(), parseInt], [randomStringArrayElement(), parseIntArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-69. ParseInt function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomInt(), parseInt, nonMatchingTypes("String")], [randomAliasDataArrayElement(), parseIntArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidParseInt, invalidFunctionError("parseInt", 1)], [randomStringArrayElement(), invalidParseIntArgBeforeFunc, invalidFunctionError("parseInt", 1)]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-70. parseIntValue function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomStringArrayElement(), parseIntValue], [randomStringArrayElement(), parseIntValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-71. parseIntValue function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomInt(), parseIntValue, nonMatchingTypes("String")], [randomAliasDataArrayElement(), parseIntValueArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidParseIntValue, invalidFunctionError("parseIntValue", 1)], [randomStringArrayElement(), invalidParseIntValueArgBeforeFunc, invalidFunctionError("parseIntValue", 1)]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/toBigInt.test.ts b/ride-js-bundle/test/builtInFunctions/converting/toBigInt.test.ts new file mode 100644 index 00000000000..d447ade5a2d --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/toBigInt.test.ts @@ -0,0 +1,34 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ToBigInt", () => { + const toBigInt = "toBigInt(callerTestData)" + const toBigIntArgBeforeFunc = "callerTestData.toBigInt()" + const toBigIntOnIndex = `toBigInt(callerTestData, 1, ${randomInt()})` + const toBigIntOnIndexArgBeforeFunc = `callerTestData.toBigInt(9, ${randomInt()})` + const invalidFunctionParseBigInt = "toBigInt()" + const invalidParseBigIntArgBeforeFunc = `callerTestData.toBigInt(callerTestData, 123, ${randomInt()})` + + test("RIDE-72. ToBigInt function should compile for valid values", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomInt(), toBigInt], [randomByteVectorArrayElement(), toBigInt], [randomInt(), toBigIntArgBeforeFunc], [randomByteVectorArrayElement(), toBigIntArgBeforeFunc], [randomByteVectorArrayElement(), toBigIntOnIndex], [randomByteVectorArrayElement(), toBigIntOnIndexArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-73. ToBigInt function throws an error for invalid values", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomBoolean(), toBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomUnionArrayElement(), toBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomInt(), invalidFunctionParseBigInt, CANT_FIND_A_FUNCTION_OVERLOAD], [randomDigestAlgorithmTypeArrayElement(), toBigIntOnIndex, CANT_FIND_A_FUNCTION_OVERLOAD], [randomBoolean(), toBigIntOnIndexArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomInt(), toBigIntOnIndexArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomByteVectorArrayElement(), invalidFunctionParseBigInt, CANT_FIND_A_FUNCTION_OVERLOAD], [randomByteVectorArrayElement(), invalidParseBigIntArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/toBytes.test.ts b/ride-js-bundle/test/builtInFunctions/converting/toBytes.test.ts new file mode 100644 index 00000000000..3bda1aac932 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/toBytes.test.ts @@ -0,0 +1,43 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomBoolean, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersions, rideV3Result, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ToBytes", () => { + // toBytes + const toBytes = "toBytes(callerTestData)" + const toBytesArgBeforeFunc = "callerTestData.toBytes()" + const invalidToBytes = "toBytes()" + const invalidToBytesArgBeforeFunc = "callerTestData.toBytes(callerTestData)" + + test("RIDE-74. toBytes function should compile for valid values int, string, boolean", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomStringArrayElement(), toBytes], [randomInt(), toBytes], [randomBoolean(), toBytes], [randomStringArrayElement(), toBytesArgBeforeFunc], [randomInt(), toBytesArgBeforeFunc], [randomBoolean(), toBytesArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-75. toBytes function should compile with bigInt for V5, V6 versions", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[`toBigInt(${randomInt()})`, toBytes], [`toBigInt(${randomInt()})`, toBytesArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-76. toBytes function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomAddressDataArrayElement(), toBytes, CANT_FIND_A_FUNCTION_OVERLOAD], [randomUnionArrayElement(), toBytesArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomInt(), invalidToBytes, CANT_FIND_A_FUNCTION_OVERLOAD], [randomStringArrayElement(), invalidToBytesArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/toInt.test.ts b/ride-js-bundle/test/builtInFunctions/converting/toInt.test.ts new file mode 100644 index 00000000000..7359ebc91fc --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/toInt.test.ts @@ -0,0 +1,44 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ToInt", () => { + const toInt = "toInt(callerTestData)" + const toIntArgBeforeFunc = "callerTestData.toInt()" + const toIntOnIndex = `toInt(callerTestData, ${randomInt()})` + const toIntOnIndexArgBeforeFunc = `callerTestData.toInt(${randomInt()})` + const invalidFunctionParseInt = "toInt()" + const invalidParseIntArgBeforeFunc = `callerTestData.toInt(callerTestData, ${randomInt()})` + + test("RIDE-77. Functions toInt function should compile for valid ByteVector", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomByteVectorArrayElement(), toInt], [randomByteVectorArrayElement(), toIntOnIndex], [randomByteVectorArrayElement(), toIntArgBeforeFunc], [randomByteVectorArrayElement(), toIntOnIndexArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-78. ToInt function should compile with bigInt for V5, V6 versions", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[`toBigInt(${randomInt()})`, toInt], [`toBigInt(${randomInt()})`, toIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-79. ToInt function throws an error for invalid values", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomDigestAlgorithmTypeArrayElement(), toInt], [randomStringArrayElement(), toIntOnIndex], [randomUnionArrayElement(), toIntOnIndexArgBeforeFunc], [randomInt(), toIntArgBeforeFunc], [`toBigInt(${randomInt()})`, invalidFunctionParseInt], [randomByteVectorArrayElement(), invalidParseIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/toString.test.ts b/ride-js-bundle/test/builtInFunctions/converting/toString.test.ts new file mode 100644 index 00000000000..6cd60a580b0 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/toString.test.ts @@ -0,0 +1,42 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomBoolean, randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ToString", () => { + const toStr = "toString(callerTestData)" + const toStrArgBeforeFunc = "callerTestData.toString()" + const invalidToStr = "toString()" + const invalidToStrArgBeforeFunc = "callerTestData.toString(callerTestData)" + + test("RIDE-80. Functions toString function should compile with int, string, boolean", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func] of [[randomAddressDataArrayElement(), toStr], [randomInt(), toStr], [randomBoolean(), toStr], [randomAddressDataArrayElement(), toStrArgBeforeFunc], [randomInt(), toStrArgBeforeFunc], [randomBoolean(), toStrArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-81. Functions toString should compile with bigInt for V5, V6 versions", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("String", version) + for (const [data, func] of [[`toBigInt(${randomInt()})`, toStr], [`toBigInt(${randomInt()})`, toStrArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-82. toString function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func, error] of [[randomUnionArrayElement(), toStr, CANT_FIND_A_FUNCTION_OVERLOAD], [randomDigestAlgorithmTypeArrayElement(), toStrArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD], [randomInt(), invalidToStr, CANT_FIND_A_FUNCTION_OVERLOAD], [randomAddressDataArrayElement(), invalidToStrArgBeforeFunc, CANT_FIND_A_FUNCTION_OVERLOAD]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/toUtf8String.test.ts b/ride-js-bundle/test/builtInFunctions/converting/toUtf8String.test.ts new file mode 100644 index 00000000000..3b179121914 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/toUtf8String.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { GreaterV3ResultStringEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../helpers/testData"; + +describe("ToUtf8String", () => { + const toUtf8String = "toUtf8String(callerTestData)" + const toUtf8StringArgBeforeFunc = "callerTestData.toUtf8String()" + const invalidToUtf8String = "toUtf8String()" + const invalidToUtf8StringArgBeforeFunc = "callerTestData.toUtf8String(callerTestData)" + + test("RIDE-83. Functions toUtf8String function should compile for valid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func] of [[randomByteVectorArrayElement(), toUtf8String], [randomByteVectorArrayElement(), toUtf8StringArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-84. toUtf8String function throws an error for invalid values", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func, error] of [[randomUnionArrayElement(), toUtf8String, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), toUtf8StringArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidToUtf8String, invalidFunctionError("toUtf8String", 1)], [randomByteVectorArrayElement(), invalidToUtf8StringArgBeforeFunc, invalidFunctionError("toUtf8String", 1)]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/converting/transferTransactionFromProto.test.ts b/ride-js-bundle/test/builtInFunctions/converting/transferTransactionFromProto.test.ts new file mode 100644 index 00000000000..b2d9a819225 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/converting/transferTransactionFromProto.test.ts @@ -0,0 +1,40 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("TransferTransactionFromProto", () => { + const transferTransactionFromProto = "transferTransactionFromProto(callerTestData)" + const transferTransactionFromProtoArgBeforeFunc = "callerTestData.transferTransactionFromProto()" + const invalidTransferTransactionFromProto = "transferTransactionFromProto()" + const invalidTransferTransactionFromProtoArgBeforeFunction = "transferTransactionFromProto()" + + test("RIDE-85. transferTransactionFromProto function should compile for Issue V4 and more", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("TransferTransaction", version) + for (const [data, func] of [[randomByteVectorArrayElement(), transferTransactionFromProto], [randomByteVectorArrayElement(), transferTransactionFromProtoArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-86. transferTransactionFromProto function throws an error for invalid values for V4 and more", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("TransferTransaction", version) + for (const [data, func, error] of [[randomDigestAlgorithmTypeArrayElement(), transferTransactionFromProto, nonMatchingTypes("ByteVector")], [randomDigestAlgorithmTypeArrayElement(), transferTransactionFromProtoArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidTransferTransactionFromProto, invalidFunctionError("transferTransactionFromProto", 1)], [randomByteVectorArrayElement(), invalidTransferTransactionFromProtoArgBeforeFunction, invalidFunctionError("transferTransactionFromProto", 1)]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-87. transferTransactionFromProto function should throw a compilation error for Ride V3", () => { + const precondition = new ContractGenerator("TransferTransaction", V3) + for (const [data, func] of [[randomByteVectorArrayElement(), transferTransactionFromProto], [randomByteVectorArrayElement(), transferTransactionFromProtoArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/invoke.test.ts b/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/invoke.test.ts new file mode 100644 index 00000000000..31ab6dd680f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/invoke.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Invoke", () => { + const invoke = "invoke(addressFromStringValue(dapp2),\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const invokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const invalidInvokeFunction = "invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const invalidInvokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke([AttachedPayment(byteVector, payment)])" + const invalidFunctionErrorResult = invalidFunctionError("invoke", 4) + + test("RIDE-88. Invoke function should compile for Issue RIDE V5 and more", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [byteVector, data, func] of [[randomByteVectorArrayElement(), randomInt(), invoke], [randomByteVectorArrayElement(), randomInt(), invokeArgBeforeFunc]]) { + const script = precondition.codeForDAppInvocation(byteVector, data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-89. Invoke function throws an error for invalid values for RIDE V5 and more", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [byteVector, data, func, error] of [[randomByteVectorArrayElement(), randomAddressDataArrayElement(), invoke, nonMatchingTypes("Int")], [randomByteVectorArrayElement(), randomDigestAlgorithmTypeArrayElement(), invokeArgBeforeFunc, nonMatchingTypes("Int")], [randomStringArrayElement(), randomInt(), invoke, nonMatchingTypes("ByteVector|Unit")], [randomStringArrayElement(), randomInt(), invokeArgBeforeFunc, nonMatchingTypes("ByteVector|Unit")], [randomByteVectorArrayElement(), randomInt(), invalidInvokeFunction, invalidFunctionErrorResult], [randomByteVectorArrayElement(), randomInt(), invalidInvokeArgBeforeFunc, invalidFunctionErrorResult]]) { + const script = precondition.codeForDAppInvocation(byteVector, data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/reentrantInvoke.test.ts b/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/reentrantInvoke.test.ts new file mode 100644 index 00000000000..8a74c230cff --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dappToDappInvocation/reentrantInvoke.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("ReentrantInvoke", () => { + const reentrantInvoke = "reentrantInvoke(addressFromStringValue(dapp2),\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const reentrantInvokeArgBeforeFunc = "addressFromStringValue(dapp2).reentrantInvoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const invalidReentrantInvokeFunction = "reentrantInvoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" + const invalidReentrantInvokeArgBeforeFunc = "addressFromStringValue(dapp2).reentrantInvoke([AttachedPayment(byteVector, payment)])" + const invalidFunctionErrorResult = invalidFunctionError("reentrantInvoke", 4) + + test("RIDE-90. ReentrantInvoke function should compile for Issue RIDE V5 and more", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [byteVector, data, func] of [[randomByteVectorArrayElement(), randomInt(), reentrantInvoke], [randomByteVectorArrayElement(), randomInt(), reentrantInvokeArgBeforeFunc]]) { + const script = precondition.codeForDAppInvocation(byteVector, data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-91. ReentrantInvoke function throws an error for invalid values for RIDE V5 and more", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("", version) + for (const [byteVector, data, func, error] of [[randomByteVectorArrayElement(), randomAddressDataArrayElement(), reentrantInvoke, nonMatchingTypes("Int")], [randomByteVectorArrayElement(), randomDigestAlgorithmTypeArrayElement(), reentrantInvokeArgBeforeFunc, nonMatchingTypes("Int")], [randomStringArrayElement(), randomInt(), reentrantInvoke, nonMatchingTypes("ByteVector|Unit")], [randomStringArrayElement(), randomInt(), reentrantInvokeArgBeforeFunc, nonMatchingTypes("ByteVector|Unit")], [randomByteVectorArrayElement(), randomInt(), invalidReentrantInvokeFunction, invalidFunctionErrorResult], [randomByteVectorArrayElement(), randomInt(), invalidReentrantInvokeArgBeforeFunc, invalidFunctionErrorResult]]) { + const script = precondition.codeForDAppInvocation(byteVector, data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dataTransaction/getBinary.test.ts b/ride-js-bundle/test/builtInFunctions/dataTransaction/getBinary.test.ts new file mode 100644 index 00000000000..1035719aad0 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dataTransaction/getBinary.test.ts @@ -0,0 +1,81 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests } from "../../helpers/testData"; + +describe("GetBinary", () => { + // getBinaryKey + const getBinaryKey = `getBinary(callerTestData, \"key\")` + const getBinaryKeyArgBeforeFunc = `callerTestData.getBinary(\"key\")` + // getBinaryIndex + const getBinaryIndex = `getBinary(callerTestData, ${randomInt()})` + const getBinaryIndexArgBeforeFunc = `callerTestData.getBinary(${randomInt()})` + // getBinaryValueKey + const getBinaryValueKey = `getBinaryValue(callerTestData, \"key\")` + const getBinaryValueKeyArgBeforeFunc = `callerTestData.getBinaryValue(\"key\")` + // getBinaryValueIndex + const getBinaryValueIndex = `getBinaryValue(callerTestData, ${randomInt()})` + const getBinaryValueIndexArgBeforeFunc = `callerTestData.getBinaryValue(${randomInt()})` + + // invalid getBinary + const invalidGetBinaryKey = `getBinary()` + const invalidGetBinaryArgBeforeFunc = `callerTestData.getBinary()` + // invalid getBinaryValue + const invalidGetBinaryValue = `getBinaryValue()` + const invalidGetBinaryValueArgBeforeFunc = `callerTestData.getBinaryValue()` + + test("RIDE-92. getBinary functions for dataTransaction should compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, binary] of [[binaryEntryForTests, getBinaryKey], [integerEntryForTests, getBinaryKey], [stringEntryForTests, getBinaryKey], [booleanEntryForTests, getBinaryKey], [binaryEntryForTests, getBinaryKeyArgBeforeFunc], [integerEntryForTests, getBinaryKeyArgBeforeFunc], [stringEntryForTests, getBinaryKeyArgBeforeFunc], [booleanEntryForTests, getBinaryKeyArgBeforeFunc], [binaryEntryForTests, getBinaryIndex], [integerEntryForTests, getBinaryIndex], [stringEntryForTests, getBinaryIndex], [booleanEntryForTests, getBinaryIndex], [binaryEntryForTests, getBinaryIndexArgBeforeFunc], [integerEntryForTests, getBinaryIndexArgBeforeFunc], [stringEntryForTests, getBinaryIndexArgBeforeFunc], [booleanEntryForTests, getBinaryIndexArgBeforeFunc], [binaryEntryForTests, getBinaryValueKey], [integerEntryForTests, getBinaryValueKey], [stringEntryForTests, getBinaryValueKey], [booleanEntryForTests, getBinaryValueKey], [binaryEntryForTests, getBinaryValueKeyArgBeforeFunc], [integerEntryForTests, getBinaryValueKeyArgBeforeFunc], [stringEntryForTests, getBinaryValueKeyArgBeforeFunc], [booleanEntryForTests, getBinaryValueKeyArgBeforeFunc], [binaryEntryForTests, getBinaryValueIndex], [integerEntryForTests, getBinaryValueIndex], [stringEntryForTests, getBinaryValueIndex], [booleanEntryForTests, getBinaryValueIndex], [binaryEntryForTests, getBinaryValueIndexArgBeforeFunc], [integerEntryForTests, getBinaryValueIndexArgBeforeFunc], [stringEntryForTests, getBinaryValueIndexArgBeforeFunc], [booleanEntryForTests, getBinaryValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-93. getBinary function for dataTransaction should compile for V3", () => { + const precondition = new ContractGenerator("ByteVector", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), getBinaryKey], [dataEntryForTests(randomStringArrayElement()), getBinaryKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBinaryIndex], [dataEntryForTests(randomStringArrayElement()), getBinaryIndexArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBinaryValueKey], [dataEntryForTests(randomStringArrayElement()), getBinaryValueKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBinaryValueIndex], [dataEntryForTests(randomStringArrayElement()), getBinaryValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-94. getBinary function should throw an error for invalid data type for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, binary] of [[randomInt(), getBinaryKey], [randomBoolean(), getBinaryKeyArgBeforeFunc], [randomInt(), getBinaryIndex], [randomBoolean(), getBinaryIndexArgBeforeFunc], [randomInt(), getBinaryValueKey], [randomBoolean(), getBinaryValueKeyArgBeforeFunc], [randomInt(), getBinaryValueIndex], [randomBoolean(), getBinaryValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-95. getBinary function should throw an error for invalid data type for V3", () => { + const precondition = new ContractGenerator("ByteVector", V3) + for (const [data, binary] of [[randomInt(), getBinaryKey], [randomBoolean(), getBinaryKeyArgBeforeFunc], [randomInt(), getBinaryIndex], [randomBoolean(), getBinaryIndexArgBeforeFunc], [randomInt(), getBinaryValueKey], [randomBoolean(), getBinaryValueKeyArgBeforeFunc], [randomInt(), getBinaryValueIndex], [randomBoolean(), getBinaryValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); + + test("RIDE-96. Invalid getBinary functions should not compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, binary] of [[integerEntryForTests, invalidGetBinaryKey], [binaryEntryForTests, invalidGetBinaryArgBeforeFunc], [integerEntryForTests, invalidGetBinaryValue], [binaryEntryForTests, invalidGetBinaryValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-97. Invalid getBinary functions should not compile for V3", () => { + const precondition = new ContractGenerator("ByteVector", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), invalidGetBinaryKey], [dataEntryForTests(randomStringArrayElement()), invalidGetBinaryArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), invalidGetBinaryValue], [dataEntryForTests(randomStringArrayElement()), invalidGetBinaryValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dataTransaction/getBoolean.test.ts b/ride-js-bundle/test/builtInFunctions/dataTransaction/getBoolean.test.ts new file mode 100644 index 00000000000..b35c8a5937b --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dataTransaction/getBoolean.test.ts @@ -0,0 +1,81 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultBooleanEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests } from "../../helpers/testData"; + +describe("GetBoolean", () => { + // getBooleanKey + const getBooleanKey = `getBoolean(callerTestData, \"key\")` + const getBooleanKeyArgBeforeFunc = `callerTestData.getBoolean(\"key\")` + // getBooleanIndex + const getBooleanIndex = `getBoolean(callerTestData, ${randomInt()})` + const getBooleanIndexArgBeforeFunc = `callerTestData.getBoolean(${randomInt()})` + // getBooleanValueKey + const getBooleanValueKey = `getBooleanValue(callerTestData, \"key\")` + const getBooleanValueKeyArgBeforeFunc = `callerTestData.getBooleanValue(\"key\")` + // getBooleanValueIndex + const getBooleanValueIndex = `getBooleanValue(callerTestData, ${randomInt()})` + const getBooleanValueIndexArgBeforeFunc = `callerTestData.getBooleanValue(${randomInt()})` + + // invalid getBoolean + const invalidGetBooleanKey = `getBoolean()` + const invalidGetBooleanArgBeforeFunc = `callerTestData.getBoolean()` + // invalid getBooleanValue + const invalidGetBooleanValue = `getBooleanValue()` + const invalidGetBooleanValueArgBeforeFunc = `callerTestData.getBooleanValue()` + + test("RIDE-98. getBoolean functions for dataTransaction should compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, binary] of [[binaryEntryForTests, getBooleanKey], [integerEntryForTests, getBooleanKey], [stringEntryForTests, getBooleanKey], [booleanEntryForTests, getBooleanKey], [binaryEntryForTests, getBooleanKeyArgBeforeFunc], [integerEntryForTests, getBooleanKeyArgBeforeFunc], [stringEntryForTests, getBooleanKeyArgBeforeFunc], [booleanEntryForTests, getBooleanKeyArgBeforeFunc], [binaryEntryForTests, getBooleanIndex], [integerEntryForTests, getBooleanIndex], [stringEntryForTests, getBooleanIndex], [booleanEntryForTests, getBooleanIndex], [binaryEntryForTests, getBooleanIndexArgBeforeFunc], [integerEntryForTests, getBooleanIndexArgBeforeFunc], [stringEntryForTests, getBooleanIndexArgBeforeFunc], [booleanEntryForTests, getBooleanIndexArgBeforeFunc], [binaryEntryForTests, getBooleanValueKey], [integerEntryForTests, getBooleanValueKey], [stringEntryForTests, getBooleanValueKey], [booleanEntryForTests, getBooleanValueKey], [binaryEntryForTests, getBooleanValueKeyArgBeforeFunc], [integerEntryForTests, getBooleanValueKeyArgBeforeFunc], [stringEntryForTests, getBooleanValueKeyArgBeforeFunc], [booleanEntryForTests, getBooleanValueKeyArgBeforeFunc], [binaryEntryForTests, getBooleanValueIndex], [integerEntryForTests, getBooleanValueIndex], [stringEntryForTests, getBooleanValueIndex], [booleanEntryForTests, getBooleanValueIndex], [binaryEntryForTests, getBooleanValueIndexArgBeforeFunc], [integerEntryForTests, getBooleanValueIndexArgBeforeFunc], [stringEntryForTests, getBooleanValueIndexArgBeforeFunc], [booleanEntryForTests, getBooleanValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-99. getBoolean function for dataTransaction should compile for V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), getBooleanKey], [dataEntryForTests(randomStringArrayElement()), getBooleanKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBooleanIndex], [dataEntryForTests(randomStringArrayElement()), getBooleanIndexArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBooleanValueKey], [dataEntryForTests(randomStringArrayElement()), getBooleanValueKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getBooleanValueIndex], [dataEntryForTests(randomStringArrayElement()), getBooleanValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-100. getBoolean function should throw an error for invalid data type for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, binary] of [[randomInt(), getBooleanKey], [randomBoolean(), getBooleanKeyArgBeforeFunc], [randomInt(), getBooleanIndex], [randomBoolean(), getBooleanIndexArgBeforeFunc], [randomInt(), getBooleanValueKey], [randomBoolean(), getBooleanValueKeyArgBeforeFunc], [randomInt(), getBooleanValueIndex], [randomBoolean(), getBooleanValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-101. getBoolean function should throw an error for invalid data type for V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + for (const [data, binary] of [[randomInt(), getBooleanKey], [randomBoolean(), getBooleanKeyArgBeforeFunc], [randomInt(), getBooleanIndex], [randomBoolean(), getBooleanIndexArgBeforeFunc], [randomInt(), getBooleanValueKey], [randomBoolean(), getBooleanValueKeyArgBeforeFunc], [randomInt(), getBooleanValueIndex], [randomBoolean(), getBooleanValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); + + test("RIDE-102. Invalid getBoolean functions should not compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, binary] of [[integerEntryForTests, invalidGetBooleanKey], [binaryEntryForTests, invalidGetBooleanArgBeforeFunc], [integerEntryForTests, invalidGetBooleanValue], [binaryEntryForTests, invalidGetBooleanValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-103. Invalid getBoolean functions should not compile for V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), invalidGetBooleanKey], [dataEntryForTests(randomStringArrayElement()), invalidGetBooleanArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), invalidGetBooleanValue], [dataEntryForTests(randomStringArrayElement()), invalidGetBooleanValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultBooleanEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dataTransaction/getInteger.test.ts b/ride-js-bundle/test/builtInFunctions/dataTransaction/getInteger.test.ts new file mode 100644 index 00000000000..23555d532b4 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dataTransaction/getInteger.test.ts @@ -0,0 +1,81 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests } from "../../helpers/testData"; + +describe("GetInteger", () => { + // getIntegerKey + const getIntegerKey = `getInteger(callerTestData, \"key\")` + const getIntegerKeyArgBeforeFunc = `callerTestData.getInteger(\"key\")` + // getIntegerIndex + const getIntegerIndex = `getInteger(callerTestData, ${randomInt()})` + const getIntegerIndexArgBeforeFunc = `callerTestData.getInteger(${randomInt()})` + // getIntegerValueKey + const getIntegerValueKey = `getIntegerValue(callerTestData, \"key\")` + const getIntegerValueKeyArgBeforeFunc = `callerTestData.getIntegerValue(\"key\")` + // getIntegerValueIndex + const getIntegerValueIndex = `getIntegerValue(callerTestData, ${randomInt()})` + const getIntegerValueIndexArgBeforeFunc = `callerTestData.getIntegerValue(${randomInt()})` + + // invalid getInteger + const invalidGetIntegerKey = `getInteger()` + const invalidGetIntegerArgBeforeFunc = `callerTestData.getInteger()` + // invalid getIntegerValue + const invalidGetIntegerValue = `getIntegerValue()` + const invalidGetIntegerValueArgBeforeFunc = `callerTestData.getIntegerValue()` + + test("RIDE-104. getInteger functions for dataTransaction should compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, binary] of [[binaryEntryForTests, getIntegerKey], [integerEntryForTests, getIntegerKey], [stringEntryForTests, getIntegerKey], [booleanEntryForTests, getIntegerKey], [binaryEntryForTests, getIntegerKeyArgBeforeFunc], [integerEntryForTests, getIntegerKeyArgBeforeFunc], [stringEntryForTests, getIntegerKeyArgBeforeFunc], [booleanEntryForTests, getIntegerKeyArgBeforeFunc], [binaryEntryForTests, getIntegerIndex], [integerEntryForTests, getIntegerIndex], [stringEntryForTests, getIntegerIndex], [booleanEntryForTests, getIntegerIndex], [binaryEntryForTests, getIntegerIndexArgBeforeFunc], [integerEntryForTests, getIntegerIndexArgBeforeFunc], [stringEntryForTests, getIntegerIndexArgBeforeFunc], [booleanEntryForTests, getIntegerIndexArgBeforeFunc], [binaryEntryForTests, getIntegerValueKey], [integerEntryForTests, getIntegerValueKey], [stringEntryForTests, getIntegerValueKey], [booleanEntryForTests, getIntegerValueKey], [binaryEntryForTests, getIntegerValueKeyArgBeforeFunc], [integerEntryForTests, getIntegerValueKeyArgBeforeFunc], [stringEntryForTests, getIntegerValueKeyArgBeforeFunc], [booleanEntryForTests, getIntegerValueKeyArgBeforeFunc], [binaryEntryForTests, getIntegerValueIndex], [integerEntryForTests, getIntegerValueIndex], [stringEntryForTests, getIntegerValueIndex], [booleanEntryForTests, getIntegerValueIndex], [binaryEntryForTests, getIntegerValueIndexArgBeforeFunc], [integerEntryForTests, getIntegerValueIndexArgBeforeFunc], [stringEntryForTests, getIntegerValueIndexArgBeforeFunc], [booleanEntryForTests, getIntegerValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-105. getInteger function for dataTransaction should compile for V3", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), getIntegerKey], [dataEntryForTests(randomStringArrayElement()), getIntegerKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getIntegerIndex], [dataEntryForTests(randomStringArrayElement()), getIntegerIndexArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getIntegerValueKey], [dataEntryForTests(randomStringArrayElement()), getIntegerValueKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getIntegerValueIndex], [dataEntryForTests(randomStringArrayElement()), getIntegerValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-106. getInteger function should throw an error for invalid data type for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, binary] of [[randomInt(), getIntegerKey], [randomBoolean(), getIntegerKeyArgBeforeFunc], [randomInt(), getIntegerIndex], [randomBoolean(), getIntegerIndexArgBeforeFunc], [randomInt(), getIntegerValueKey], [randomBoolean(), getIntegerValueKeyArgBeforeFunc], [randomInt(), getIntegerValueIndex], [randomBoolean(), getIntegerValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-107. getInteger function should throw an error for invalid data type for V3", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, binary] of [[randomInt(), getIntegerKey], [randomBoolean(), getIntegerKeyArgBeforeFunc], [randomInt(), getIntegerIndex], [randomBoolean(), getIntegerIndexArgBeforeFunc], [randomInt(), getIntegerValueKey], [randomBoolean(), getIntegerValueKeyArgBeforeFunc], [randomInt(), getIntegerValueIndex], [randomBoolean(), getIntegerValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); + + test("RIDE-108. Invalid getInteger functions should not compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, binary] of [[integerEntryForTests, invalidGetIntegerKey], [binaryEntryForTests, invalidGetIntegerArgBeforeFunc], [integerEntryForTests, invalidGetIntegerValue], [binaryEntryForTests, invalidGetIntegerValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-109. Invalid getInteger functions should not compile for V3", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), invalidGetIntegerKey], [dataEntryForTests(randomStringArrayElement()), invalidGetIntegerArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), invalidGetIntegerValue], [dataEntryForTests(randomStringArrayElement()), invalidGetIntegerValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/dataTransaction/getString.test.ts b/ride-js-bundle/test/builtInFunctions/dataTransaction/getString.test.ts new file mode 100644 index 00000000000..7231c5adc1a --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/dataTransaction/getString.test.ts @@ -0,0 +1,81 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { dataEntryForTests, randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersionsWithoutV3, binaryEntryForTests, booleanEntryForTests, integerEntryForTests, rideV3Result, stringEntryForTests } from "../../helpers/testData"; + +describe("GetString", () => { + // getStringKey + const getStringKey = `getString(callerTestData, \"key\")` + const getStringKeyArgBeforeFunc = `callerTestData.getString(\"key\")` + // getStringIndex + const getStringIndex = `getString(callerTestData, ${randomInt()})` + const getStringIndexArgBeforeFunc = `callerTestData.getString(${randomInt()})` + // getStringValueKey + const getStringValueKey = `getStringValue(callerTestData, \"key\")` + const getStringValueKeyArgBeforeFunc = `callerTestData.getStringValue(\"key\")` + // getStringValueIndex + const getStringValueIndex = `getStringValue(callerTestData, ${randomInt()})` + const getStringValueIndexArgBeforeFunc = `callerTestData.getStringValue(${randomInt()})` + + // invalid getString + const invalidGetStringKey = `getString()` + const invalidGetStringArgBeforeFunc = `callerTestData.getString()` + // invalid getStringValue + const invalidGetStringValue = `getStringValue()` + const invalidGetStringValueArgBeforeFunc = `callerTestData.getStringValue()` + + test("RIDE-110. getString functions for dataTransaction should compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, binary] of [[binaryEntryForTests, getStringKey], [integerEntryForTests, getStringKey], [stringEntryForTests, getStringKey], [booleanEntryForTests, getStringKey], [binaryEntryForTests, getStringKeyArgBeforeFunc], [integerEntryForTests, getStringKeyArgBeforeFunc], [stringEntryForTests, getStringKeyArgBeforeFunc], [booleanEntryForTests, getStringKeyArgBeforeFunc], [binaryEntryForTests, getStringIndex], [integerEntryForTests, getStringIndex], [stringEntryForTests, getStringIndex], [booleanEntryForTests, getStringIndex], [binaryEntryForTests, getStringIndexArgBeforeFunc], [integerEntryForTests, getStringIndexArgBeforeFunc], [stringEntryForTests, getStringIndexArgBeforeFunc], [booleanEntryForTests, getStringIndexArgBeforeFunc], [binaryEntryForTests, getStringValueKey], [integerEntryForTests, getStringValueKey], [stringEntryForTests, getStringValueKey], [booleanEntryForTests, getStringValueKey], [binaryEntryForTests, getStringValueKeyArgBeforeFunc], [integerEntryForTests, getStringValueKeyArgBeforeFunc], [stringEntryForTests, getStringValueKeyArgBeforeFunc], [booleanEntryForTests, getStringValueKeyArgBeforeFunc], [binaryEntryForTests, getStringValueIndex], [integerEntryForTests, getStringValueIndex], [stringEntryForTests, getStringValueIndex], [booleanEntryForTests, getStringValueIndex], [binaryEntryForTests, getStringValueIndexArgBeforeFunc], [integerEntryForTests, getStringValueIndexArgBeforeFunc], [stringEntryForTests, getStringValueIndexArgBeforeFunc], [booleanEntryForTests, getStringValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-111. getString function for dataTransaction should compile for V3", () => { + const precondition = new ContractGenerator("String", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), getStringKey], [dataEntryForTests(randomStringArrayElement()), getStringKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getStringIndex], [dataEntryForTests(randomStringArrayElement()), getStringIndexArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getStringValueKey], [dataEntryForTests(randomStringArrayElement()), getStringValueKeyArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), getStringValueIndex], [dataEntryForTests(randomStringArrayElement()), getStringValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-112. getString function should throw an error for invalid data type for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, binary] of [[randomInt(), getStringKey], [randomBoolean(), getStringKeyArgBeforeFunc], [randomInt(), getStringIndex], [randomBoolean(), getStringIndexArgBeforeFunc], [randomInt(), getStringValueKey], [randomBoolean(), getStringValueKeyArgBeforeFunc], [randomInt(), getStringValueIndex], [randomBoolean(), getStringValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-113. getString function should throw an error for invalid data type for V3", () => { + const precondition = new ContractGenerator("String", V3) + for (const [data, binary] of [[randomInt(), getStringKey], [randomBoolean(), getStringKeyArgBeforeFunc], [randomInt(), getStringIndex], [randomBoolean(), getStringIndexArgBeforeFunc], [randomInt(), getStringValueKey], [randomBoolean(), getStringValueKeyArgBeforeFunc], [randomInt(), getStringValueIndex], [randomBoolean(), getStringValueIndexArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); + + test("RIDE-114. Invalid getString functions should not compile for versions V4 and above", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, binary] of [[integerEntryForTests, invalidGetStringKey], [binaryEntryForTests, invalidGetStringArgBeforeFunc], [integerEntryForTests, invalidGetStringValue], [binaryEntryForTests, invalidGetStringValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); + + test("RIDE-115. Invalid getString functions should not compile for V3", () => { + const precondition = new ContractGenerator("String", V3) + for (const [data, binary] of [[dataEntryForTests(randomStringArrayElement()), invalidGetStringKey], [dataEntryForTests(randomStringArrayElement()), invalidGetStringArgBeforeFunc], [dataEntryForTests(randomStringArrayElement()), invalidGetStringValue], [dataEntryForTests(randomStringArrayElement()), invalidGetStringValueArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, binary, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, V3, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/decoding/addressFromString.test.ts b/ride-js-bundle/test/builtInFunctions/decoding/addressFromString.test.ts new file mode 100644 index 00000000000..8426fe87163 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/decoding/addressFromString.test.ts @@ -0,0 +1,36 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("AddressFromString", () => { + const addressFromString = "addressFromString(callerTestData)" + const addressFromStringArgBeforeFunc = "callerTestData.addressFromString()" + const addressFromStringValue = "addressFromStringValue(callerTestData)" + const addressFromStringValueArgBeforeFunc = "callerTestData.addressFromStringValue()" + const invalidAddressFromString = "addressFromString()" + const invalidAddressFromStringValue = "addressFromStringValue()" + const invalidFunctionErrorForAddressFromString = invalidFunctionError("addressFromString", 1) + const invalidFunctionErrorForAddressFromStringValue = invalidFunctionError("addressFromStringValue", 1) + + test("RIDE-116. Function addressFromString should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Address", version) + for (const [data, func] of [[randomStringArrayElement(), addressFromString], [randomStringArrayElement(), addressFromStringArgBeforeFunc], [randomStringArrayElement(), addressFromStringValue], [randomStringArrayElement(), addressFromStringValueArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-117. Function addressFromString should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Address", version) + for (const [data, func, error] of [[randomAliasDataArrayElement(), addressFromString, nonMatchingTypes("String")], [randomAliasDataArrayElement(), addressFromStringArgBeforeFunc, nonMatchingTypes("String")], [randomBoolean(), addressFromStringValue, nonMatchingTypes("String")], [randomUnionArrayElement(), addressFromStringValueArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidAddressFromString, invalidFunctionErrorForAddressFromString], [randomStringArrayElement(), invalidAddressFromStringValue, invalidFunctionErrorForAddressFromStringValue]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/decoding/fromBaseString.test.ts b/ride-js-bundle/test/builtInFunctions/decoding/fromBaseString.test.ts new file mode 100644 index 00000000000..d6c4b3fd153 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/decoding/fromBaseString.test.ts @@ -0,0 +1,44 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("FromBaseString", () => { + const fromBase16String = "fromBase16String(callerTestData)" + const fromBase16StringArgBeforeFunc = "callerTestData.fromBase16String()" + const fromBase58String = "fromBase58String(callerTestData)" + const fromBase58StringArgBeforeFunc = "callerTestData.fromBase58String()" + const fromBase64String = "fromBase64String(callerTestData)" + const fromBase64StringArgBeforeFunc = "callerTestData.fromBase64String()" + const invalidFromBase16String = "fromBase16String()" + const invalidFromBase58String = "fromBase58String()" + const invalidFromBase64String = "fromBase64String()" + const invalidFromBase16StringArgBeforeFunction = "callerTestData.fromBase16String(callerTestData)" + const invalidFromBase58StringArgBeforeFunction = "callerTestData.fromBase58String(callerTestData)" + const invalidFromBase64StringArgBeforeFunction = "callerTestData.fromBase64String(callerTestData)" + const invalidErrorForFromBase16String = invalidFunctionError("fromBase16String", 1) + const invalidErrorForFromBase58String = invalidFunctionError("fromBase58String", 1) + const invalidErrorForFromBase64String = invalidFunctionError("fromBase64String", 1) + + test("RIDE-118. Function fromBaseString should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomStringArrayElement(), fromBase16String], [randomStringArrayElement(), fromBase16StringArgBeforeFunc], [randomStringArrayElement(), fromBase58String], [randomStringArrayElement(), fromBase58StringArgBeforeFunc], [randomStringArrayElement(), fromBase64String], [randomStringArrayElement(), fromBase64StringArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + // invalid data + test("RIDE-119. Function fromBaseString should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomBoolean(), fromBase16String, nonMatchingTypes("String")], [randomAliasDataArrayElement(), fromBase16StringArgBeforeFunc, nonMatchingTypes("String")], [randomByteVectorArrayElement(), fromBase58String, nonMatchingTypes("String")], [randomDigestAlgorithmTypeArrayElement(), fromBase58StringArgBeforeFunc, nonMatchingTypes("String")], [randomByteVectorArrayElement(), fromBase64String, nonMatchingTypes("String")], [randomUnionArrayElement(), fromBase64StringArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), invalidFromBase16String, invalidErrorForFromBase16String], [randomStringArrayElement(), invalidFromBase58String, invalidErrorForFromBase58String], [randomStringArrayElement(), invalidFromBase64String, invalidErrorForFromBase64String], [randomStringArrayElement(), invalidFromBase16StringArgBeforeFunction, invalidErrorForFromBase16String], [randomStringArrayElement(), invalidFromBase58StringArgBeforeFunction, invalidErrorForFromBase58String], [randomStringArrayElement(), invalidFromBase64StringArgBeforeFunction, invalidErrorForFromBase64String]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/encoding/toBaseString.test.ts b/ride-js-bundle/test/builtInFunctions/encoding/toBaseString.test.ts new file mode 100644 index 00000000000..f5e3864c6fc --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/encoding/toBaseString.test.ts @@ -0,0 +1,43 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("ToBaseString", () => { + const toBase16String = "toBase16String(callerTestData)" + const toBase16StringArgBeforeFunc = "callerTestData.toBase16String()" + const toBase58String = "toBase58String(callerTestData)" + const toBase58StringArgBeforeFunc = "callerTestData.toBase58String()" + const toBase64String = "toBase64String(callerTestData)" + const toBase64StringArgBeforeFunc = "callerTestData.toBase64String()" + const invalidToBase16String = "toBase16String()" + const invalidToBase58String = "toBase58String()" + const invalidToBase64String = "toBase64String()" + const invalidToBase16StringArgBeforeFunction = "callerTestData.toBase16String(callerTestData)" + const invalidToBase58StringArgBeforeFunction = "callerTestData.toBase58String(callerTestData)" + const invalidToBase64StringArgBeforeFunction = "callerTestData.toBase64String(callerTestData)" + const invalidErrorForToBase16String = invalidFunctionError("toBase16String", 1) + const invalidErrorForToBase58String = invalidFunctionError("toBase58String", 1) + const invalidErrorForToBase64String = invalidFunctionError("toBase64String", 1) + + test("RIDE-120. Function toBaseString should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func] of [[randomByteVectorArrayElement(), toBase16String], [randomByteVectorArrayElement(), toBase16StringArgBeforeFunc], [randomByteVectorArrayElement(), toBase58String], [randomByteVectorArrayElement(), toBase58StringArgBeforeFunc], [randomByteVectorArrayElement(), toBase64String], [randomByteVectorArrayElement(), toBase64StringArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-121. Function toBaseString should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, func, error] of [[randomBoolean(), toBase16String, nonMatchingTypes("ByteVector")], [randomAliasDataArrayElement(), toBase16StringArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomStringArrayElement(), toBase58String, nonMatchingTypes("ByteVector")], [randomDigestAlgorithmTypeArrayElement(), toBase58StringArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomInt(), toBase64String, nonMatchingTypes("ByteVector")], [randomUnionArrayElement(), toBase64StringArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidToBase16String, invalidErrorForToBase16String], [randomByteVectorArrayElement(), invalidToBase58String, invalidErrorForToBase58String], [randomByteVectorArrayElement(), invalidToBase64String, invalidErrorForToBase64String], [randomByteVectorArrayElement(), invalidToBase16StringArgBeforeFunction, invalidErrorForToBase16String], [randomByteVectorArrayElement(), invalidToBase58StringArgBeforeFunction, invalidErrorForToBase58String], [randomByteVectorArrayElement(), invalidToBase64StringArgBeforeFunction, invalidErrorForToBase64String]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256.test.ts new file mode 100644 index 00000000000..f2946c343bd --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Blake2b256", () => { + const blake2b256 = "blake2b256(callerTestData)" + const blake2b256ArgBeforeFunc = "callerTestData.blake2b256()" + const invalidBlake2b256 = "blake2b256()" + const invalidBlake2b256ArgBeforeFunc = "callerTestData.blake2b256(callerTestData)" + const invalidErrorBlake2b256 = invalidFunctionError("blake2b256", 1) + + test("RIDE-122. Function blake2b256 should compile for valid ByteVector", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), blake2b256], [randomByteVectorArrayElement(), blake2b256ArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-123. Function blake2b256 should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), blake2b256, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), blake2b256ArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBlake2b256, invalidErrorBlake2b256], [randomByteVectorArrayElement(), invalidBlake2b256ArgBeforeFunc, invalidErrorBlake2b256]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_128Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_128Kb.test.ts new file mode 100644 index 00000000000..96fc6a99d41 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_128Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Blake2b256_128Kb", () => { + const blake2b256_128Kb = "blake2b256_128Kb(callerTestData)" + const blake2b256_128KbArgBeforeFunc = "callerTestData.blake2b256_128Kb()" + const invalidBlake2b256_128Kb = "blake2b256_128Kb()" + const invalidBlake2b256_128KbArgBeforeFunc = "callerTestData.blake2b256_128Kb(callerTestData)" + const invalidErrorBlake2b256_128Kb = invalidFunctionError("blake2b256_128Kb", 1) + + test("RIDE-130. Function blake2b256_128Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), blake2b256_128Kb], [randomByteVectorArrayElement(), blake2b256_128KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-131. Function blake2b256_128Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), blake2b256_128Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), blake2b256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBlake2b256_128Kb, invalidErrorBlake2b256_128Kb], [randomByteVectorArrayElement(), invalidBlake2b256_128KbArgBeforeFunc, invalidErrorBlake2b256_128Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_16Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_16Kb.test.ts new file mode 100644 index 00000000000..1b159ffcdf4 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_16Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Blake2b256_16Kb", () => { + const blake2b256_16Kb = "blake2b256_16Kb(callerTestData)" + const blake2b256_16KbArgBeforeFunc = "callerTestData.blake2b256_16Kb()" + const invalidBlake2b256_16Kb = "blake2b256_16Kb()" + const invalidBlake2b256_16KbArgBeforeFunc = "callerTestData.blake2b256_16Kb(callerTestData)" + const invalidErrorBlake2b256_16Kb = invalidFunctionError("blake2b256_16Kb", 1) + + test("RIDE-124. Function blake2b256_16Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), blake2b256_16Kb], [randomByteVectorArrayElement(), blake2b256_16KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-125. Function blake2b256 should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), blake2b256_16Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), blake2b256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBlake2b256_16Kb, invalidErrorBlake2b256_16Kb], [randomByteVectorArrayElement(), invalidBlake2b256_16KbArgBeforeFunc, invalidErrorBlake2b256_16Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_32Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_32Kb.test.ts new file mode 100644 index 00000000000..8136ba9c8de --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_32Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Blake2b256_32Kb", () => { + const blake2b256_32Kb = "blake2b256_32Kb(callerTestData)" + const blake2b256_32KbArgBeforeFunc = "callerTestData.blake2b256_32Kb()" + const invalidBlake2b256_32Kb = "blake2b256_32Kb()" + const invalidBlake2b256_32KbArgBeforeFunc = "callerTestData.blake2b256_32Kb(callerTestData)" + const invalidErrorBlake2b256_32Kb = invalidFunctionError("blake2b256_32Kb", 1) + + test("RIDE-126. Function blake2b256 should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), blake2b256_32Kb], [randomByteVectorArrayElement(), blake2b256_32KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-127. Function blake2b256_32Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), blake2b256_32Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), blake2b256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBlake2b256_32Kb, invalidErrorBlake2b256_32Kb], [randomByteVectorArrayElement(), invalidBlake2b256_32KbArgBeforeFunc, invalidErrorBlake2b256_32Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_64Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_64Kb.test.ts new file mode 100644 index 00000000000..16624bc0bcf --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/blake2b256/blake2b256_64Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Blake2b256_64Kb", () => { + const blake2b256_64Kb = "blake2b256_64Kb(callerTestData)" + const blake2b256_64KbArgBeforeFunc = "callerTestData.blake2b256_64Kb()" + const invalidBlake2b256_64Kb = "blake2b256_64Kb()" + const invalidBlake2b256_64KbArgBeforeFunc = "callerTestData.blake2b256_64Kb(callerTestData)" + const invalidErrorBlake2b256_64Kb = invalidFunctionError("blake2b256_64Kb", 1) + + test("RIDE-128. Function blake2b256_64Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), blake2b256_64Kb], [randomByteVectorArrayElement(), blake2b256_64KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-128. Function blake2b256_64Kb должна выдавать ошибку при невалидных данных", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), blake2b256_64Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), blake2b256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBlake2b256_64Kb, invalidErrorBlake2b256_64Kb], [randomByteVectorArrayElement(), invalidBlake2b256_64KbArgBeforeFunc, invalidErrorBlake2b256_64Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256.test.ts new file mode 100644 index 00000000000..410229926d0 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Keccak256", () => { + const keccak256 = "keccak256(callerTestData)" + const keccak256ArgBeforeFunc = "callerTestData.keccak256()" + const invalidKeccak256 = "keccak256()" + const invalidKeccak256ArgBeforeFunc = "callerTestData.keccak256(callerTestData)" + const invalidErrorKeccak256 = invalidFunctionError("keccak256", 1) + + test("RIDE-132. Function Keccak256 should compile for valid ByteVector", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), keccak256], [randomByteVectorArrayElement(), keccak256ArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-133. Function blake2b256 should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), keccak256, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), keccak256ArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidKeccak256, invalidErrorKeccak256], [randomByteVectorArrayElement(), invalidKeccak256ArgBeforeFunc, invalidErrorKeccak256]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_128Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_128Kb.test.ts new file mode 100644 index 00000000000..e7510d25bca --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_128Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Keccak256_128Kb", () => { + const keccak256_128Kb = "keccak256_128Kb(callerTestData)" + const keccak256_128KbArgBeforeFunc = "callerTestData.keccak256_128Kb()" + const invalidKeccak256_128Kb = "keccak256_128Kb()" + const invalidKeccak256_128KbArgBeforeFunc = "callerTestData.keccak256_128Kb(callerTestData)" + const invalidErrorKeccak256_128Kb = invalidFunctionError("keccak256_128Kb", 1) + + test("RIDE-140. Function keccak256_128Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), keccak256_128Kb], [randomByteVectorArrayElement(), keccak256_128KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-141. Function keccak256_128Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), keccak256_128Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), keccak256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidKeccak256_128Kb, invalidErrorKeccak256_128Kb], [randomByteVectorArrayElement(), invalidKeccak256_128KbArgBeforeFunc, invalidErrorKeccak256_128Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_16Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_16Kb.test.ts new file mode 100644 index 00000000000..bad750cea08 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_16Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Keccak256_16Kb", () => { + const keccak256_16Kb = "keccak256_16Kb(callerTestData)" + const keccak256_16KbArgBeforeFunc = "callerTestData.keccak256_16Kb()" + const invalidKeccak256_16Kb = "keccak256_16Kb()" + const invalidKeccak256_16KbArgBeforeFunc = "callerTestData.keccak256_16Kb(callerTestData)" + const invalidErrorKeccak256_16Kb = invalidFunctionError("keccak256_16Kb", 1) + + test("RIDE-134. Function keccak256_16Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), keccak256_16Kb], [randomByteVectorArrayElement(), keccak256_16KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-135. Function keccak256_16Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), keccak256_16Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), keccak256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidKeccak256_16Kb, invalidErrorKeccak256_16Kb], [randomByteVectorArrayElement(), invalidKeccak256_16KbArgBeforeFunc, invalidErrorKeccak256_16Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_32Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_32Kb.test.ts new file mode 100644 index 00000000000..cb5a3c06f2a --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_32Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Keccak256_32Kb", () => { + const keccak256_32Kb = "keccak256_32Kb(callerTestData)" + const keccak256_32KbArgBeforeFunc = "callerTestData.keccak256_32Kb()" + const invalidKeccak256_32Kb = "keccak256_32Kb()" + const invalidKeccak256_32KbArgBeforeFunc = "callerTestData.keccak256_32Kb(callerTestData)" + const invalidErrorKeccak256_32Kb = invalidFunctionError("keccak256_32Kb", 1) + + test("RIDE-136. Function keccak256_32Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), keccak256_32Kb], [randomByteVectorArrayElement(), keccak256_32KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-137. Function keccak256_32Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), keccak256_32Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), keccak256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidKeccak256_32Kb, invalidErrorKeccak256_32Kb], [randomByteVectorArrayElement(), invalidKeccak256_32KbArgBeforeFunc, invalidErrorKeccak256_32Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_64Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_64Kb.test.ts new file mode 100644 index 00000000000..20d34746cea --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/keccak256/keccak256_64Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Keccak256_64Kb", () => { + const keccak256_64Kb = "keccak256_64Kb(callerTestData)" + const keccak256_64KbArgBeforeFunc = "callerTestData.keccak256_64Kb()" + const invalidKeccak256_64Kb = "keccak256_64Kb()" + const invalidKeccak256_64KbArgBeforeFunc = "callerTestData.keccak256_64Kb(callerTestData)" + const invalidErrorKeccak256_64Kb = invalidFunctionError("keccak256_64Kb", 1) + + test("RIDE-138. Function keccak256_64Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), keccak256_64Kb], [randomByteVectorArrayElement(), keccak256_64KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-139. Function keccak256_64Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), keccak256_64Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), keccak256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidKeccak256_64Kb, invalidErrorKeccak256_64Kb], [randomByteVectorArrayElement(), invalidKeccak256_64KbArgBeforeFunc, invalidErrorKeccak256_64Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256.test.ts new file mode 100644 index 00000000000..ea68970d752 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersions, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Sha256", () => { + const sha256 = "sha256(callerTestData)" + const sha256ArgBeforeFunc = "callerTestData.sha256()" + const invalidSha256 = "sha256()" + const invalidSha256ArgBeforeFunc = "callerTestData.sha256(callerTestData)" + const invalidErrorSha256 = invalidFunctionError("sha256", 1) + + test("RIDE-142. Function sha256 should compile for valid ByteVector", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sha256], [randomByteVectorArrayElement(), sha256ArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-143. Function sha256 should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sha256, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sha256ArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSha256, invalidErrorSha256], [randomByteVectorArrayElement(), invalidSha256ArgBeforeFunc, invalidErrorSha256]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_128Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_128Kb.test.ts new file mode 100644 index 00000000000..8a2caedbc2d --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_128Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Sha256_128Kb", () => { + const sha256_128Kb = "sha256_128Kb(callerTestData)" + const sha256_128KbArgBeforeFunc = "callerTestData.sha256_128Kb()" + const invalidSha256_128Kb = "sha256_128Kb()" + const invalidSha256_128KbArgBeforeFunc = "callerTestData.sha256_128Kb(callerTestData)" + const invalidErrorSha256_128Kb = invalidFunctionError("sha256_128Kb", 1) + + test("RIDE-150. Function sha256_128Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sha256_128Kb], [randomByteVectorArrayElement(), sha256_128KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-151. Function sha256_128Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sha256_128Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sha256_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSha256_128Kb, invalidErrorSha256_128Kb], [randomByteVectorArrayElement(), invalidSha256_128KbArgBeforeFunc, invalidErrorSha256_128Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_16Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_16Kb.test.ts new file mode 100644 index 00000000000..4eab04b1405 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_16Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Sha256_16Kb", () => { + const sha256_16Kb = "sha256_16Kb(callerTestData)" + const sha256_16KbArgBeforeFunc = "callerTestData.sha256_16Kb()" + const invalidSha256_16Kb = "sha256_16Kb()" + const invalidSha256_16KbArgBeforeFunc = "callerTestData.sha256_16Kb(callerTestData)" + const invalidErrorSha256_16Kb = invalidFunctionError("sha256_16Kb", 1) + + test("RIDE-144. Function sha256_16Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sha256_16Kb], [randomByteVectorArrayElement(), sha256_16KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-145. Function sha256_16Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sha256_16Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sha256_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSha256_16Kb, invalidErrorSha256_16Kb], [randomByteVectorArrayElement(), invalidSha256_16KbArgBeforeFunc, invalidErrorSha256_16Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_32Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_32Kb.test.ts new file mode 100644 index 00000000000..f0f85b1d7da --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_32Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Sha256_32Kb", () => { + const sha256_32Kb = "sha256_32Kb(callerTestData)" + const sha256_32KbArgBeforeFunc = "callerTestData.sha256_32Kb()" + const invalidSha256_32Kb = "sha256_32Kb()" + const invalidSha256_32KbArgBeforeFunc = "callerTestData.sha256_32Kb(callerTestData)" + const invalidErrorSha256_32Kb = invalidFunctionError("sha256_32Kb", 1) + + test("RIDE-146. Function sha256_32Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sha256_32Kb], [randomByteVectorArrayElement(), sha256_32KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-147. Function sha256_32Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sha256_32Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sha256_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSha256_32Kb, invalidErrorSha256_32Kb], [randomByteVectorArrayElement(), invalidSha256_32KbArgBeforeFunc, invalidErrorSha256_32Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_64Kb.test.ts b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_64Kb.test.ts new file mode 100644 index 00000000000..6eb0b1e324f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/hashing/sha256/sha256_64Kb.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { GreaterV3ResultBinaryEntry, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, rideV3Result } from "../../../helpers/testData"; + +describe("Sha256_64Kb", () => { + const sha256_64Kb = "sha256_64Kb(callerTestData)" + const sha256_64KbArgBeforeFunc = "callerTestData.sha256_64Kb()" + const invalidSha256_64Kb = "sha256_64Kb()" + const invalidSha256_64KbArgBeforeFunc = "callerTestData.sha256_64Kb(callerTestData)" + const invalidErrorSha256_64Kb = invalidFunctionError("sha256_64Kb", 1) + + test("RIDE-148. Function sha256_64Kb should compile for valid ByteVector", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sha256_64Kb], [randomByteVectorArrayElement(), sha256_64KbArgBeforeFunc]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-149. Function sha256_64Kb should throw an error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sha256_64Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sha256_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSha256_64Kb, invalidErrorSha256_64Kb], [randomByteVectorArrayElement(), invalidSha256_64KbArgBeforeFunc, invalidErrorSha256_64Kb]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/cons.test.ts b/ride-js-bundle/test/builtInFunctions/list/cons.test.ts new file mode 100644 index 00000000000..2e0435e70e0 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/cons.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomBoolean, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersions, intList, invalidFunctionError, nonMatchingTypes, stringList } from "../../helpers/testData"; + +describe("Cons", () => { + const cons = "cons(foo, bar)" + const consArgBeforeFunc = "foo.cons(bar)" + const invalidCons = "cons(foo)" + const invalidConsArgBeforeFunc = "foo.cons(foo, bar)" + const invalidErrorCons = invalidFunctionError("cons", 2) + + test("RIDE-152. Function Cons should compile for valid list", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, cons], [randomInt(), intList, cons], [randomStringArrayElement(), stringList, consArgBeforeFunc], [randomInt(), intList, consArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-153. Function Cons should throw an error for invalid data or type", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), cons, nonMatchingTypes("")], [randomStringArrayElement(), randomBoolean(), consArgBeforeFunc, nonMatchingTypes("")], [randomInt(), intList, invalidCons, invalidErrorCons], [randomStringArrayElement(), stringList, invalidConsArgBeforeFunc, invalidErrorCons]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/containsElement.test.ts b/ride-js-bundle/test/builtInFunctions/list/containsElement.test.ts new file mode 100644 index 00000000000..87399d11d91 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/containsElement.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersionsWithoutV3, intList, invalidFunctionError, nonMatchingTypes, stringList } from "../../helpers/testData"; + +describe("ContainsElement", () => { + const containsElement = "containsElement(bar, foo)" + const containsElementArgBeforeFunc = "bar.containsElement(foo)" + const invalidContainsElement = "containsElement(foo)" + const invalidContainsElementArgBeforeFunc = "foo.containsElement(foo, bar)" + const invalidErrorContainsElement = invalidFunctionError("containsElement", 2) + + test("RIDE-154. Function ContainsElement should compile for valid list", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, containsElement], [randomInt(), intList, containsElement], [randomStringArrayElement(), stringList, containsElementArgBeforeFunc], [randomInt(), intList, containsElementArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-155. Function ContainsElement should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), containsElement, nonMatchingTypes("")], [randomStringArrayElement(), randomIssuesArrayElement(), containsElementArgBeforeFunc, nonMatchingTypes("")], [randomInt(), intList, invalidContainsElement, invalidErrorContainsElement], [randomStringArrayElement(), stringList, invalidContainsElementArgBeforeFunc, invalidErrorContainsElement]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/getElement.test.ts b/ride-js-bundle/test/builtInFunctions/list/getElement.test.ts new file mode 100644 index 00000000000..1ae1334fe9e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/getElement.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { actualVersions, intList, invalidFunctionError, nonMatchingTypes, stringList } from "../../helpers/testData"; + +describe("GetElement", () => { + const getElement = "getElement(bar, foo)" + const getElementArgBeforeFunc = "bar.getElement(foo)" + const invalidGetElement = "getElement(foo)" + const invalidGetElementArgBeforeFunc = "foo.getElement(bar, foo)" + const invalidErrorGetElement = invalidFunctionError("getElement", 2) + + test("RIDE-156. Function GetElement should compile for valid list", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomInt(), stringList, getElement], [randomInt(), intList, getElement], [randomInt(), stringList, getElementArgBeforeFunc], [randomInt(), intList, getElementArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-157. Function GetElement should throw an error for invalid data or type", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), getElement, nonMatchingTypes("")], [randomStringArrayElement(), randomIssuesArrayElement(), getElementArgBeforeFunc, nonMatchingTypes("")], [randomInt(), intList, invalidGetElement, invalidErrorGetElement], [randomStringArrayElement(), stringList, invalidGetElementArgBeforeFunc, invalidErrorGetElement]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/indexOf.test.ts b/ride-js-bundle/test/builtInFunctions/list/indexOf.test.ts new file mode 100644 index 00000000000..4b4841f9eb7 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/indexOf.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, stringList } from "../../helpers/testData"; + +describe("IndexOf", () => { + const indexOf = "indexOf(bar, foo)" + const indexOfArgBeforeFunc = "bar.indexOf(foo)" + const invalidIndexOf = "indexOf()" + const invalidIndexOfArgBeforeFunc = "bar.indexOf(bar, foo)" + + test("RIDE-158. Function IndexOf should compile for valid list", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, indexOf], [randomInt(), intList, indexOf], [randomStringArrayElement(), stringList, indexOfArgBeforeFunc], [randomInt(), intList, indexOfArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-159. Function IndexOf should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[stringList, stringList, indexOf], [randomByteVectorArrayElement(), intList, indexOfArgBeforeFunc], [randomInt(), intList, invalidIndexOf], [randomStringArrayElement(), stringList, invalidIndexOfArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/lastIndexOf.test.ts b/ride-js-bundle/test/builtInFunctions/list/lastIndexOf.test.ts new file mode 100644 index 00000000000..524692d194b --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/lastIndexOf.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, stringList } from "../../helpers/testData"; + +describe("LastIndexOf", () => { + const lastIndexOf = "lastIndexOf(bar, foo)" + const lastIndexOfArgBeforeFunc = "bar.lastIndexOf(foo)" + const invalidLastIndexOf = "lastIndexOf()" + const invalidLastIndexOfArgBeforeFunc = "bar.indexOf(bar, foo)" + + test("RIDE-160. Function LastIndexOf should compile for valid list", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, lastIndexOf], [randomInt(), intList, lastIndexOf], [randomStringArrayElement(), stringList, lastIndexOfArgBeforeFunc], [randomInt(), intList, lastIndexOfArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-161. Function IndexOf should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[stringList, stringList, lastIndexOf], [randomByteVectorArrayElement(), intList, lastIndexOfArgBeforeFunc], [randomInt(), intList, invalidLastIndexOf], [randomStringArrayElement(), stringList, invalidLastIndexOfArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/max.test.ts b/ride-js-bundle/test/builtInFunctions/list/max.test.ts new file mode 100644 index 00000000000..07bd3486e3b --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/max.test.ts @@ -0,0 +1,49 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Max", () => { + const max = "max(callerTestData)" + const maxArgBeforeFunc = "callerTestData.max()" + const invalidMax = "max()" + const invalidMaxArgBeforeFunc = "callerTestData.max(callerTestData)" + const maxForBigInt = "max([callerTestData])" + const maxForBigIntArgBeforeFunc = "[callerTestData].max()" + const invalidMaxForBigInt = "[callerTestData].max([callerTestData], [callerTestData])" + + test("RIDE-162. Function Max should compile with a list", () => { + for (const version of actualVersionsWithoutV3) { + for (const [data, func, dataType] of [[intList, max, "Int"], [intList, maxArgBeforeFunc, "Int"]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-163. Function Max should compile with a BigInt", () => { + for (const version of versionsSupportingTheNewFeatures) { + for (const [data, func, dataType] of [[`toBigInt(${randomInt()})`, maxForBigInt, "BigInt"], [`toBigInt(${randomInt()})`, maxForBigIntArgBeforeFunc, "BigInt"]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-164. Function Max should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + for (const [data, func, dataType, error] of [[randomUnionArrayElement(), max, "Int", nonMatchingTypes("List[Int]")], [randomDigestAlgorithmTypeArrayElement(), maxArgBeforeFunc, "Int", nonMatchingTypes("List[Int]")], [intList, invalidMax, "Int", invalidFunctionError("max", 1)], [intList, invalidMaxArgBeforeFunc, "Int", invalidFunctionError("max", 1)], [intList, invalidMaxForBigInt, "Int", invalidFunctionError("max", 1)]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + if (version === V4) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/min.test.ts b/ride-js-bundle/test/builtInFunctions/list/min.test.ts new file mode 100644 index 00000000000..b0eab39db58 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/min.test.ts @@ -0,0 +1,49 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V4 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomDigestAlgorithmTypeArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, intList, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Min", () => { + const min = "min(callerTestData)" + const minArgBeforeFunc = "callerTestData.min()" + const invalidMin = "min()" + const invalidMinArgBeforeFunc = "callerTestData.min(callerTestData)" + const minForBigInt = "min([callerTestData])" + const minForBigIntArgBeforeFunc = "[callerTestData].min()" + const invalidMinForBigInt = "[callerTestData].min([callerTestData], [callerTestData])" + + test("RIDE-165. Function Min should compile with a list", () => { + for (const version of actualVersionsWithoutV3) { + for (const [data, func, dataType] of [[intList, min, "Int"], [intList, minArgBeforeFunc, "Int"]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-166. Function Min should compile with a BigInt", () => { + for (const version of versionsSupportingTheNewFeatures) { + for (const [data, func, dataType] of [[`toBigInt(${randomInt()})`, minForBigInt, "BigInt"], [`toBigInt(${randomInt()})`, minForBigIntArgBeforeFunc, "BigInt"]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-167. Function Min should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + for (const [data, func, dataType, error] of [[randomUnionArrayElement(), min, "Int", nonMatchingTypes("List[Int]")], [randomDigestAlgorithmTypeArrayElement(), minArgBeforeFunc, "Int", nonMatchingTypes("List[Int]")], [intList, invalidMin, "Int", invalidFunctionError("min", 1)], [intList, invalidMinArgBeforeFunc, "Int", invalidFunctionError("min", 1)], [intList, invalidMinForBigInt, "Int", invalidFunctionError("min", 1)]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + if (version === V4) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/removeByIndex.test.ts b/ride-js-bundle/test/builtInFunctions/list/removeByIndex.test.ts new file mode 100644 index 00000000000..b301649e752 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/removeByIndex.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement } from "../../helpers/randomData"; +import { actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, stringList } from "../../helpers/testData"; + +describe("RemoveByIndex", () => { + const removeByIndex = "removeByIndex(bar, foo)" + const removeByIndexArgBeforeFunc = "bar.removeByIndex(foo)" + const invalidRemoveByIndex = "removeByIndex(foo)" + const invalidRemoveByIndexArgBeforeFunc = "foo.removeByIndex(bar, foo)" + const invalidErrorRemoveByIndex = invalidFunctionError("removeByIndex", 2) + + test("RIDE-168. Function RemoveByIndex should compile for valid list", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func] of [[randomInt(), stringList, removeByIndex], [randomInt(), stringList, removeByIndexArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-169. Function RemoveByIndex should throw an error for invalid data or type", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), removeByIndex, nonMatchingTypes("List[T]")], [randomInt(), randomIssuesArrayElement(), removeByIndexArgBeforeFunc, nonMatchingTypes("List[T]")], [randomInt(), stringList, invalidRemoveByIndex, invalidErrorRemoveByIndex], [randomInt(), stringList, invalidRemoveByIndexArgBeforeFunc, invalidErrorRemoveByIndex]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/replaceByIndex.test.ts b/ride-js-bundle/test/builtInFunctions/list/replaceByIndex.test.ts new file mode 100644 index 00000000000..fa856acce7a --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/replaceByIndex.test.ts @@ -0,0 +1,41 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, allStdLibVersions, V8 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { nonMatchingTypes, invalidFunctionError, stringList } from "../../helpers/testData"; + +describe("ReplaceByIndex", () => { + const replaceByIndex = `replaceByIndex(bar, 1, foo)`; + const replaceByIndexArgBeforeFunc = `bar.replaceByIndex(1, foo)`; + const invalidReplaceByIndex = `replaceByIndex(1, foo)`; + const invalidReplaceByIndexArgBeforeFunc = `foo.replaceByIndex(bar, 1, foo)`; + const invalidErrorReplaceByIndex = invalidFunctionError("replaceByIndex", 3); + + test("replaceByIndex functions compiles with a list", () => { + for (const version of allStdLibVersions.filter((v) => v >= V8)) { + const precondition = new ContractGenerator("", version); + for (const [data, list, func] of [ + [randomStringArrayElement(), stringList, replaceByIndex], + [randomStringArrayElement(), stringList, replaceByIndexArgBeforeFunc] + ]) { + const script = precondition.simpleRideCode(data, list, func); + assertCompileSuccessDApp(script, version); + } + } + }); + + test("Compilation errors ReplaceByIndex functions", () => { + for (const version of allStdLibVersions.filter((v) => v >= V8)) { + const precondition = new ContractGenerator("", version); + for (const [data, list, func, error] of [ + [randomInt(), randomAliasDataArrayElement(), replaceByIndex, nonMatchingTypes("List[T]")], + [randomInt(), randomIssuesArrayElement(), replaceByIndexArgBeforeFunc, nonMatchingTypes("List[T]")], + [randomInt(), stringList, invalidReplaceByIndex, invalidErrorReplaceByIndex], + [randomInt(), stringList, invalidReplaceByIndexArgBeforeFunc, invalidErrorReplaceByIndex] + ]) { + const script = precondition.simpleRideCode(data, list, func); + assertCompileErrorDApp(script, version, error); + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/list/size.test.ts b/ride-js-bundle/test/builtInFunctions/list/size.test.ts new file mode 100644 index 00000000000..faef0135999 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/list/size.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList } from "../../helpers/testData"; + +describe("Size", () => { + const size = "size(callerTestData)" + const sizeArgBeforeFunc = "callerTestData.size()" + const invalidSize = "size()" + const invalidSizeArgBeforeFunc = "callerTestData.size(callerTestData)" + + test("RIDE-170. Function Size should compile for valid list", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[intList, size], [intList, sizeArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-171. Function Size should throw an error for invalid data or type", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomUnionArrayElement(), size], [randomAddressDataArrayElement(), sizeArgBeforeFunc], [intList, invalidSize], [intList, invalidSizeArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/math/fraction.test.ts b/ride-js-bundle/test/builtInFunctions/math/fraction.test.ts new file mode 100644 index 00000000000..06d470afa3c --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/math/fraction.test.ts @@ -0,0 +1,75 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, invalidFunctionError, nonMatchingTypes, oldVersions, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Fraction", () => { + let union = randomUnionArrayElement() + const fractionInt = `fraction(callerTestData, ${randomInt()}, ${randomInt()})` + const fractionIntArgBeforeFunc = `callerTestData.fraction(${randomInt()}, ${randomInt()})` + const fractionIntAndUnion = `fraction(callerTestData, ${randomInt()}, ${randomInt()}, ${union})` + const fractionIntAndUnionArgBeforeFunc = `callerTestData.fraction(${randomInt()}, ${randomInt()}, ${union})` + + union = randomUnionArrayElement() + const fractionBigInt = `fraction(callerTestData, callerTestData, callerTestData)` + const fractionBigIntArgBeforeFunc = `callerTestData.fraction(callerTestData, callerTestData)` + const fractionBigIntAndUnion = `fraction(callerTestData, callerTestData, callerTestData, ${union})` + const fractionBigIntAndUnionArgBeforeFunc = `callerTestData.fraction(callerTestData, callerTestData, ${union})` + + const invalidFractionFunction = `fraction(callerTestData)` + const invalidFractionFunctionArgBeforeFunc = `callerTestData.fraction()` + const fractionError = invalidFunctionError("fraction", 3) + + test("RIDE-172. Fraction should compile with the Int type", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), fractionInt], [randomInt(), fractionIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-173. Fraction should compile with the Int and Union types - Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + for (const [data, func, dataType] of [[randomInt(), fractionIntAndUnion, "Int"], [randomInt(), fractionIntAndUnionArgBeforeFunc, "Int"], [`toBigInt(${randomInt()})`, fractionBigInt, "BigInt"], [`toBigInt(${randomInt()})`, fractionBigIntArgBeforeFunc, "BigInt"], [`toBigInt(${randomInt()})`, fractionBigIntAndUnion, "BigInt"], [`toBigInt(${randomInt()})`, fractionBigIntAndUnionArgBeforeFunc, "BigInt"]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-174. Fraction should throw an error for invalid data", () => { + for (const version of actualVersions) { + for (const [data, func, dataType, error] of [[randomInt(), invalidFractionFunction, "Int", fractionError], [randomInt(), invalidFractionFunctionArgBeforeFunc, "Int", fractionError], [randomStringArrayElement(), fractionInt, "Int", nonMatchingTypes("Int")], [randomAddressDataArrayElement(), fractionIntArgBeforeFunc, "Int", nonMatchingTypes("Int")]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + if (version < V5) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); + + test("RIDE-175. Fraction should raise a compilation error for BigInt - Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + for (const [data, func, dataType, error] of [[randomStringArrayElement(), fractionBigInt, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD], [randomAliasDataArrayElement(), fractionBigIntArgBeforeFunc, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD], [randomStringArrayElement(), fractionBigIntAndUnion, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD], [randomAliasDataArrayElement(), fractionBigIntAndUnionArgBeforeFunc, "BigInt", CANT_FIND_A_FUNCTION_OVERLOAD], [randomIssuesArrayElement(), fractionIntAndUnion, "Int", CANT_FIND_A_FUNCTION_OVERLOAD], [randomIssuesArrayElement(), fractionIntAndUnionArgBeforeFunc, "Int", CANT_FIND_A_FUNCTION_OVERLOAD]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-176. Fraction should raise an error for versions V3 and V4 with incorrect argument count", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("Int", version) + const script = precondition.onlyMatcherContract(randomInt(), fractionIntAndUnion) + assertCompileErrorDApp(script, version, fractionError) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/math/log.test.ts b/ride-js-bundle/test/builtInFunctions/math/log.test.ts new file mode 100644 index 00000000000..cd553b09910 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/math/log.test.ts @@ -0,0 +1,60 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Log", () => { + const union = randomUnionArrayElement() + const logInt = `log(callerTestData, ${randomInt()}, ${randomInt()}, 4, 2, ${union})` + const logIntArgBeforeFunc = `callerTestData.log(${randomInt()}, ${randomInt()}, 4, 2, ${union})` + const logBigInt = `log(callerTestData, 6, callerTestData, ${randomInt()}, 2, ${union})` + const logBigIntArgBeforeFunc = `callerTestData.log(6, callerTestData, ${randomInt()}, 2, ${union})` + const invalidLogInt = `log(callerTestData, 10, ${union})` + const invalidLogIntArgBeforeFunc = `callerTestData.log(10, ${union})` + const logError = invalidFunctionError("log", 6) + + test("RIDE-177. Log function should compile with Int", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), logInt], [randomInt(), logIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-178. Log function should compile with BigInt for Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[`toBigInt(${randomInt()})`, logBigInt], [`toBigInt(${randomInt()})`, logBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-179. Log function should throw an error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomStringArrayElement(), logInt, nonMatchingTypes("Int")], [randomAddressDataArrayElement(), logIntArgBeforeFunc, nonMatchingTypes("Int")], [randomInt(), invalidLogInt, logError], [randomInt(), invalidLogIntArgBeforeFunc, logError]]) { + const script = precondition.onlyMatcherContract(data, func) + if (version < V5) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); + + test("RIDE-180. Log function should throw an error for invalid data BigInt - Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomStringArrayElement(), logBigInt], [randomAliasDataArrayElement(), logBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/math/median.test.ts b/ride-js-bundle/test/builtInFunctions/math/median.test.ts new file mode 100644 index 00000000000..4f802cd607f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/math/median.test.ts @@ -0,0 +1,58 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Median", () => { + const medianInt = `median([callerTestData, ${randomInt()}, ${randomInt()}])` + const medianIntArgBeforeFunc = `[callerTestData, ${randomInt()}, ${randomInt()}].median()` + const medianBigInt = `median(callerTestData)` + const medianBigIntArgBeforeFunc = `callerTestData.median()` + const invalidMedianInt = `median()` + const medianError = invalidFunctionError("median", 1) + + test("RIDE-181. Median functions should compile with Int", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), medianInt], [randomInt(), medianIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-182. Median functions should compile with BigInt for Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[`[toBigInt(${randomInt()})]`, medianBigInt], [`[toBigInt(${randomInt()})]`, medianBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-183. Median functions should throw an error for invalid Int data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomInt(), invalidMedianInt, medianError], [randomStringArrayElement(), medianInt, nonMatchingTypes("List[Int]")], [randomAddressDataArrayElement(), medianIntArgBeforeFunc, nonMatchingTypes("List[Int]")]]) { + const script = precondition.onlyMatcherContract(data, func) + if (version < V5) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); + + test("RIDE-184. Median function should throw an error for invalid BigInt data - Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomStringArrayElement(), medianBigInt], [randomAliasDataArrayElement(), medianBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/math/pow.test.ts b/ride-js-bundle/test/builtInFunctions/math/pow.test.ts new file mode 100644 index 00000000000..636e733ddf6 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/math/pow.test.ts @@ -0,0 +1,59 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, versionsSupportingTheNewFeatures } from "../../helpers/testData"; + +describe("Pow", () => { + const union = randomUnionArrayElement() + const powInt = `pow(callerTestData, 6, ${randomInt()}, 4, ${randomInt()}, ${union})` + const powIntArgBeforeFunc = `callerTestData.pow(6, ${randomInt()}, ${randomInt()}, 2, ${union})` + const powBigInt = `pow(callerTestData, 6, callerTestData, 4, 2, ${union})` + const powBigIntArgBeforeFunc = `callerTestData.pow(${randomInt()}, callerTestData, 4, 2, ${union})` + const invalidPowInt = `pow()` + const powError = invalidFunctionError("pow", 6) + + test("RIDE-185. Pow functions should compile with Int", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), powInt], [randomInt(), powIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-186. Pow functions should compile with BigInt for Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[`toBigInt(${randomInt()})`, powBigInt], [`toBigInt(${randomInt()})`, powBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-187. Median functions should throw an error for invalid Int data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func, error] of [[randomInt(), invalidPowInt, powError], [randomStringArrayElement(), powInt, nonMatchingTypes("Int")], [randomAddressDataArrayElement(), powIntArgBeforeFunc, nonMatchingTypes("Int")]]) { + const script = precondition.onlyMatcherContract(data, func) + if (version < V5) { + assertCompileErrorDApp(script, version, error) + } else { + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + } + }); + + test("RIDE-188. Median function should throw an error for invalid BigInt data - Ride V5, V6", () => { + for (const version of versionsSupportingTheNewFeatures) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func] of [[randomStringArrayElement(), powBigInt], [randomAliasDataArrayElement(), powBigIntArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/math/sqrt.test.ts b/ride-js-bundle/test/builtInFunctions/math/sqrt.test.ts new file mode 100644 index 00000000000..2475ffe665e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/math/sqrt.test.ts @@ -0,0 +1,38 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V5, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomByteVectorArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, CANT_FIND_FUNCTION, versionsWithoutV6 } from "../../helpers/testData"; + +describe("Sqrt", () => { + const union = randomUnionArrayElement() + const sqrtIntAndUnion = `sqrt(callerTestData, ${randomInt()}, ${randomInt()}, ${union})` + const sqrtIntAndUnionArgBeforeFunc = `callerTestData.sqrt(${randomInt()}, 3, ${union})` + const invalidSqrtFunction = `sqrt(callerTestData)` + + test("RIDE-189. Sqrt functions compile with Int and BigInt", () => { + for (const [data, func, dataType] of [[randomInt(), sqrtIntAndUnion, "Int"], [randomInt(), sqrtIntAndUnionArgBeforeFunc, "Int"], [`toBigInt(${randomInt()})`, sqrtIntAndUnion, "BigInt"], [`toBigInt(${randomInt()})`, sqrtIntAndUnionArgBeforeFunc, "BigInt"]]) { + const precondition = new ContractGenerator(dataType, V6) + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, V6) + } + }); + + test("RIDE-190. Sqrt functions should throw an error for invalid Int data", () => { + for (const [data, func, dataType] of [[randomStringArrayElement(), sqrtIntAndUnion, "Int"], [randomInt(), invalidSqrtFunction, "Int"], [randomByteVectorArrayElement(), sqrtIntAndUnion, "BigInt"], [`toBigInt(${randomInt()})`, invalidSqrtFunction, "BigInt"]]) { + const precondition = new ContractGenerator(dataType, V6) + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, V6, CANT_FIND_A_FUNCTION_OVERLOAD) + } + }); + + test("RIDE-191. Can't find a function Sqrt for V3 - V5", () => { + for (const version of versionsWithoutV6) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), sqrtIntAndUnion], [randomInt(), sqrtIntAndUnionArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/negativeTestsOfUnsupportedMethods.test.ts b/ride-js-bundle/test/builtInFunctions/negativeTestsOfUnsupportedMethods.test.ts new file mode 100644 index 00000000000..23f26422662 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/negativeTestsOfUnsupportedMethods.test.ts @@ -0,0 +1,91 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, V3, V4 } from "../helpers/jsTestBase"; +import { ContractGenerator } from "../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomStringArrayElement } from "../helpers/randomData"; +import { CANT_FIND_FUNCTION, GreaterV3ResultBinaryEntry, UNDEFINED_TYPE, intList, oldVersions, rideV3Result, stringList } from "../helpers/testData"; + +describe("NegativeTestsOfUnsupportedMethods", () => { + const toBigInt = "toBigInt(callerTestData)" + const toBigIntArgBeforeFunc = "callerTestData.toBigInt()" + const invokeArgBeforeFunc = "addressFromStringValue(dapp2).invoke(\"bar\",[a],[AttachedPayment(byteVector, payment)])" + + const blake2b256_16Kb = "blake2b256_16Kb(callerTestData)" + const blake2b256_32Kb = "blake2b256_32Kb(callerTestData)" + const blake2b256_64Kb = "blake2b256_64Kb(callerTestData)" + const blake2b256_128Kb = "blake2b256_128Kb(callerTestData)" + const keccak256_16Kb = "keccak256_16Kb(callerTestData)" + const keccak256_32Kb = "keccak256_32Kb(callerTestData)" + const keccak256_64Kb = "keccak256_64Kb(callerTestData)" + const keccak256_128Kb = "keccak256_128Kb(callerTestData)" + + const containsElement = "containsElement(foo, bar)" + const indexOf = "indexOf(bar, foo)" + const removeByIndex = "removeByIndex(bar, foo)" + + const max = "max(callerTestData)" + const min = "min(callerTestData)" + + test("RIDE-280. toBigInt function should throw a compilation error for RIDE versions V3 and V4.", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("BigInt", version) + for (const [data, func, error] of [[randomInt(), toBigInt, UNDEFINED_TYPE], [randomStringArrayElement(), toBigIntArgBeforeFunc, UNDEFINED_TYPE]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-281. compilation error 'invalid data invoke' should occur for RIDE versions V3 and V4 when an argument is placed before the function.", () => { + for (const version of oldVersions) { + const precondition = new ContractGenerator("", version) + const script = precondition.codeForDAppInvocation(randomByteVectorArrayElement(), randomAddressDataArrayElement(), invokeArgBeforeFunc) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + }); + + test("RIDE-282. blake2b256 functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("ByteVector", V3) + for (const [data, func, error] of [[randomByteVectorArrayElement(), blake2b256_16Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), blake2b256_32Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), blake2b256_64Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), blake2b256_128Kb, CANT_FIND_FUNCTION]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, V3, error) + } + }); + + test("RIDE-283. keccak256 functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("ByteVector", V3) + for (const [data, func, error] of [[randomByteVectorArrayElement(), keccak256_16Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), keccak256_32Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), keccak256_64Kb, CANT_FIND_FUNCTION], [randomByteVectorArrayElement(), keccak256_128Kb, CANT_FIND_FUNCTION]]) { + const script = precondition.codeFromMatchingAndCase(data, func, rideV3Result, GreaterV3ResultBinaryEntry) + assertCompileErrorDApp(script, V3, error) + } + }); + + test("RIDE-284. containsElement functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("", V3) + const script = precondition.simpleRideCode(randomStringArrayElement(), stringList, containsElement) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); + + test("RIDE-285. indexOf functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("", V3) + const script = precondition.simpleRideCode(randomInt(), intList, indexOf) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); + + test("RIDE-286. max functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("", V3) + const script = precondition.simpleRideCode(randomInt(), intList, max) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); + + test("RIDE-287. min functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("", V3) + const script = precondition.simpleRideCode(randomInt(), intList, min) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); + + test("RIDE-288. removeByIndex functions should throw an error for RIDE version V3.", () => { + const precondition = new ContractGenerator("", V3) + const script = precondition.simpleRideCode(randomInt(), intList, removeByIndex) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/contains.test.ts b/ride-js-bundle/test/builtInFunctions/string/contains.test.ts new file mode 100644 index 00000000000..cf8c3aa4edd --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/contains.test.ts @@ -0,0 +1,40 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("Contains", () => { + const contains = "contains(bar, foo)" + const containsArgBeforeFunc = "bar.contains(foo)" + const invalidContains = "contains(foo)" + const invalidContainsArgBeforeFunc = "foo.contains(bar, foo)" + const invalidErrorContains = invalidFunctionError("contains", 2) + + test("RIDE-208. function contains should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), contains], [randomStringArrayElement(), randomStringArrayElement(), containsArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-209. function contains throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), containsArgBeforeFunc, nonMatchingTypes("String")], [randomInt(), randomIssuesArrayElement(), containsArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), randomStringArrayElement(), invalidContains, invalidErrorContains], [randomStringArrayElement(), randomStringArrayElement(), invalidContainsArgBeforeFunc, invalidErrorContains]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + + } + }); + + test("RIDE-210. Can't find a function contains for RIDE V3", () => { + const precondition = new ContractGenerator("String", V3) + const script = precondition.simpleRideCode(randomStringArrayElement(), randomStringArrayElement(), contains) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/drop.test.ts b/ride-js-bundle/test/builtInFunctions/string/drop.test.ts new file mode 100644 index 00000000000..bc75314723d --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/drop.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Drop", () => { + const drop = `drop(callerTestData, ${randomInt()})` + const dropArgBeforeFunction = `callerTestData.drop(${randomInt()})` + const invalidDrop = `drop(callerTestData)` + const invalidDropArgBeforeFunc = `callerTestData.drop(callerTestData, ${randomInt()})` + + test("RIDE-211. function drop should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomStringArrayElement(), drop], [randomStringArrayElement(), dropArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-212. function drop throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), drop], [randomUnionArrayElement(), dropArgBeforeFunction], [randomStringArrayElement(), invalidDrop], [randomStringArrayElement(), invalidDropArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/dropRight.test.ts b/ride-js-bundle/test/builtInFunctions/string/dropRight.test.ts new file mode 100644 index 00000000000..aeea1442b0f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/dropRight.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("DropRight", () => { + const dropRight = `dropRight(callerTestData, ${randomInt()})` + const dropRightArgBeforeFunction = `callerTestData.dropRight(${randomInt()})` + const invalidDropRight = `dropRight(callerTestData)` + const invalidDropRightArgBeforeFunc = `callerTestData.dropRight(callerTestData, ${randomInt()})` + + test("RIDE-213. function dropRight should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomStringArrayElement(), dropRight], [randomStringArrayElement(), dropRightArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-214. function dropRight throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), dropRight], [randomUnionArrayElement(), dropRightArgBeforeFunction], [randomStringArrayElement(), invalidDropRight], [randomStringArrayElement(), invalidDropRightArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/indexOf.test.ts b/ride-js-bundle/test/builtInFunctions/string/indexOf.test.ts new file mode 100644 index 00000000000..943a0165dd4 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/indexOf.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList, stringList } from "../../helpers/testData"; + +describe("IndexOf", () => { + const indexOf = "indexOf(bar, foo)" + const indexOfWithOffset = `indexOf(bar, foo, ${randomInt()})` + const indexOfArgBeforeFunc = "bar.indexOf(foo)" + const indexOfWithOffsetArgBeforeFunc = `bar.indexOf(foo, ${randomInt()})` + const invalidIndexOf = "indexOf()" + + test("RIDE-215. function indexOf should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func] of [[randomStringArrayElement(), randomStringArrayElement(), indexOf], [randomStringArrayElement(), randomStringArrayElement(), indexOfWithOffset], [randomStringArrayElement(), randomStringArrayElement(), indexOfArgBeforeFunc], [randomStringArrayElement(), randomStringArrayElement(), indexOfWithOffsetArgBeforeFunc]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-216. function indexOf - Non-matching types - Can't find a function overload", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func] of [[stringList, randomStringArrayElement(), indexOf], [randomInt(), randomStringArrayElement(), indexOfArgBeforeFunc], [stringList, randomStringArrayElement(), indexOfWithOffset], [randomInt(), randomStringArrayElement(), indexOfWithOffsetArgBeforeFunc], [randomInt(), intList, invalidIndexOf]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/lastIndexOf.test.ts b/ride-js-bundle/test/builtInFunctions/string/lastIndexOf.test.ts new file mode 100644 index 00000000000..4a5784c3868 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/lastIndexOf.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, actualVersions, intList, stringList } from "../../helpers/testData"; + +describe("LastIndexOf", () => { + const lastIndexOf = "lastIndexOf(bar, foo)" + const lastIndexOfWithOffset = `lastIndexOf(bar, foo, ${randomInt()})` + const lastIndexOfArgBeforeFunc = "bar.lastIndexOf(foo)" + const lastIndexOfWithOffsetArgBeforeFunc = `bar.lastIndexOf(foo, ${randomInt()})` + const invalidLastIndexOf = "lastIndexOf()" + + test("RIDE-217. function lastIndexOf should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func] of [[randomStringArrayElement(), randomStringArrayElement(), lastIndexOf], [randomStringArrayElement(), randomStringArrayElement(), lastIndexOfWithOffset], [randomStringArrayElement(), randomStringArrayElement(), lastIndexOfArgBeforeFunc], [randomStringArrayElement(), randomStringArrayElement(), lastIndexOfWithOffsetArgBeforeFunc]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-218. function lastIndexOf - Non-matching types - Can't find a function overload", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func] of [[stringList, randomStringArrayElement(), lastIndexOf], [randomInt(), randomStringArrayElement(), lastIndexOfArgBeforeFunc], [stringList, randomStringArrayElement(), lastIndexOfWithOffset], [randomInt(), randomStringArrayElement(), lastIndexOfWithOffsetArgBeforeFunc], [randomInt(), intList, invalidLastIndexOf]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString.test.ts b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString.test.ts new file mode 100644 index 00000000000..7d8c6a9d951 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes, stringList } from "../../../helpers/testData"; + +describe("MakeString", () => { + const makeString = "makeString(bar, foo)" + const makeStringArgBeforeFunc = "bar.makeString(foo)" + const invalidMakeString = "makeString(foo)" + const invalidMakeStringArgBeforeFunc = "foo.makeString(bar, foo)" + const invalidErrorMakeString = invalidFunctionError("makeString", 2) + + test("RIDE-192. makeString function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, makeString], [randomStringArrayElement(), stringList, makeStringArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-193. makeString function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), makeStringArgBeforeFunc, nonMatchingTypes("List[String]")], [randomInt(), randomIssuesArrayElement(), makeStringArgBeforeFunc, nonMatchingTypes("List[String]")], [randomStringArrayElement(), stringList, invalidMakeString, invalidErrorMakeString], [randomStringArrayElement(), stringList, invalidMakeStringArgBeforeFunc, invalidErrorMakeString]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_11C.test.ts b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_11C.test.ts new file mode 100644 index 00000000000..e226ff61cd9 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_11C.test.ts @@ -0,0 +1,38 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V5, V6 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, invalidFunctionError, nonMatchingTypes, stringList, versionsWithoutV6 } from "../../../helpers/testData"; + +describe("MakeString_11C", () => { + const makeString_11C = `makeString_11C(bar, foo)` + const makeString_11CArgBeforeFunc = `bar.makeString_11C(foo)` + const invalidMakeString_11CFunction = `makeString_11C(foo)` + const invalidErrorMakeString_11C = invalidFunctionError("makeString_11C", 2) + + test("RIDE-197. makeString_11C function should compile for valid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, makeString_11C], [randomStringArrayElement(), stringList, makeString_11CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, V6) + } + }); + + test("RIDE-198. makeString_11C function should throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func, error] of [[randomStringArrayElement(), stringList, invalidMakeString_11CFunction, invalidErrorMakeString_11C], [randomIssuesArrayElement(), stringList, makeString_11C, nonMatchingTypes("String")], [randomInt(), stringList, makeString_11CArgBeforeFunc, nonMatchingTypes("String")]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, V6, error) + } + }); + + test("RIDE-199. Can't find a function makeString_11C for RIDE versions V3 - V5", () => { + for (const version of versionsWithoutV6) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, makeString_11C], [randomStringArrayElement(), stringList, makeString_11CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_2C.test.ts b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_2C.test.ts new file mode 100644 index 00000000000..b0b10ed58eb --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/makeStringFunctions/makeString_2C.test.ts @@ -0,0 +1,38 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V5, V6 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, invalidFunctionError, nonMatchingTypes, stringList, versionsWithoutV6 } from "../../../helpers/testData"; + +describe("MakeString_2C", () => { + const makeString_2C = `makeString_2C(bar, foo)` + const makeString_2CArgBeforeFunc = `bar.makeString_2C(foo)` + const invalidMakeString_2CFunction = `makeString_2C(foo)` + const invalidErrorMakeString_2C = invalidFunctionError("makeString_2C", 2) + + test("RIDE-194. makeString_2C function should compile for valid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, makeString_2C], [randomStringArrayElement(), stringList, makeString_2CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, V6) + } + }); + + test("RIDE-195. makeString_2C function should throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func, error] of [[randomStringArrayElement(), stringList, invalidMakeString_2CFunction, invalidErrorMakeString_2C], [randomIssuesArrayElement(), stringList, makeString_2C, nonMatchingTypes("String")], [randomInt(), stringList, makeString_2CArgBeforeFunc, nonMatchingTypes("String")]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, V6, error) + } + }); + + test("RIDE-196. Can't find a function makeString_2C for RIDE versions V3 - V5", () => { + for (const version of versionsWithoutV6) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), stringList, makeString_2C], [randomStringArrayElement(), stringList, makeString_2CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/size.test.ts b/ride-js-bundle/test/builtInFunctions/string/size.test.ts new file mode 100644 index 00000000000..b495877ef11 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/size.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultIntegerEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Size", () => { + const size = `size(callerTestData)` + const sizeArgBeforeFunction = `callerTestData.size()` + const invalidSize = `size()` + const invalidSizeArgBeforeFunc = `callerTestData.size(callerTestData, callerTestData)` + + test("RIDE-219. function size should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomStringArrayElement(), size], [randomStringArrayElement(), sizeArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileSuccessDApp(script, version) + + } + } + }); + + test("RIDE-220. function size throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), size], [randomUnionArrayElement(), sizeArgBeforeFunction], [randomStringArrayElement(), invalidSize], [randomStringArrayElement(), invalidSizeArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultIntegerEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split.test.ts b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split.test.ts new file mode 100644 index 00000000000..f119e9650ca --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAliasDataArrayElement, randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("Split", () => { + const split = "split(bar, foo)" + const splitArgBeforeFunc = "bar.split(foo)" + const invalidSplit = "split(foo)" + const invalidSplitArgBeforeFunc = "foo.split(bar, foo)" + const invalidErrorSplit = invalidFunctionError("split", 2) + + test("RIDE-200. split function should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), split], [randomStringArrayElement(), randomStringArrayElement(), splitArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-201. split function should throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, list, func, error] of [[randomInt(), randomAliasDataArrayElement(), splitArgBeforeFunc, nonMatchingTypes("String")], [randomInt(), randomIssuesArrayElement(), splitArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), randomStringArrayElement(), invalidSplit, invalidErrorSplit], [randomStringArrayElement(), randomStringArrayElement(), invalidSplitArgBeforeFunc, invalidErrorSplit]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_4C.test.ts b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_4C.test.ts new file mode 100644 index 00000000000..a056bebc9df --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_4C.test.ts @@ -0,0 +1,38 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V5, V6 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, invalidFunctionError, nonMatchingTypes, versionsWithoutV6 } from "../../../helpers/testData"; + +describe("Split_4C", () => { + const split_4C = `split_4C(bar, foo)` + const split_4CArgBeforeFunc = `bar.split_4C(foo)` + const invalidSplit_4C = `split_4C(foo)` + const invalidErrorSplit_4C = invalidFunctionError("split_4C", 2) + + test("RIDE-202. split_4C function should compile for valid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), split_4C], [randomStringArrayElement(), randomStringArrayElement(), split_4CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, V6) + } + }); + + test("RIDE-203. split_4C function should throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func, error] of [[randomIssuesArrayElement(), randomStringArrayElement(), split_4C, nonMatchingTypes("String")], [randomInt(), randomStringArrayElement(), split_4CArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), randomStringArrayElement(), invalidSplit_4C, invalidErrorSplit_4C]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, V6, error) + } + }); + + test("RIDE-204. Can't find a function split_4C for RIDE versions V3 - V5", () => { + for (const version of versionsWithoutV6) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), split_4C], [randomStringArrayElement(), randomStringArrayElement(), split_4CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_51C.test.ts b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_51C.test.ts new file mode 100644 index 00000000000..a32c94e7d6f --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/splitFunctions/split_51C.test.ts @@ -0,0 +1,38 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V5, V6 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomInt, randomIssuesArrayElement, randomStringArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, invalidFunctionError, nonMatchingTypes, versionsWithoutV6 } from "../../../helpers/testData"; + +describe("Split_51C", () => { + const split_51C = `split_51C(bar, foo)` + const split_51CArgBeforeFunc = `bar.split_51C(foo)` + const invalidSplit_51C = `split_51C(foo)` + const invalidErrorSplit_51C = invalidFunctionError("split_51C", 2) + + test("RIDE-205. split_51C function should compile for valid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), split_51C], [randomStringArrayElement(), randomStringArrayElement(), split_51CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileSuccessDApp(script, V6) + } + }); + + test("RIDE-206. split_51C function should throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("String", V6) + for (const [data, list, func, error] of [[randomIssuesArrayElement(), randomStringArrayElement(), split_51C, nonMatchingTypes("String")], [randomInt(), randomStringArrayElement(), split_51CArgBeforeFunc, nonMatchingTypes("String")], [randomStringArrayElement(), randomStringArrayElement(), invalidSplit_51C, invalidErrorSplit_51C]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, V6, error) + } + }); + + test("RIDE-207. Can't find a function split_4C for RIDE versions V3 - V5", () => { + for (const version of versionsWithoutV6) { + const precondition = new ContractGenerator("String", version) + for (const [data, list, func] of [[randomStringArrayElement(), randomStringArrayElement(), split_51C], [randomStringArrayElement(), randomStringArrayElement(), split_51CArgBeforeFunc]]) { + const script = precondition.simpleRideCode(data, list, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/take.test.ts b/ride-js-bundle/test/builtInFunctions/string/take.test.ts new file mode 100644 index 00000000000..2c1171424ea --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/take.test.ts @@ -0,0 +1,32 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("Take", () => { + const take = `take(callerTestData, ${randomInt()})` + const takeArgBeforeFunction = `callerTestData.take(${randomInt()})` + const invalidTake = `take(callerTestData)` + const invalidTakeArgBeforeFunc = `callerTestData.take(callerTestData, ${randomInt()})` + + test("RIDE-221. function take should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomStringArrayElement(), take], [randomStringArrayElement(), takeArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-222. function take throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), take], [randomUnionArrayElement(), takeArgBeforeFunction], [randomStringArrayElement(), invalidTake], [randomStringArrayElement(), invalidTakeArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/string/takeRight.test.ts b/ride-js-bundle/test/builtInFunctions/string/takeRight.test.ts new file mode 100644 index 00000000000..1e430385e2e --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/string/takeRight.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_A_FUNCTION_OVERLOAD, GreaterV3ResultStringEntry, actualVersions, rideV3Result } from "../../helpers/testData"; + +describe("TakeRight", () => { + const takeRight = `takeRight(callerTestData, ${randomInt()})` + const takeRightArgBeforeFunction = `callerTestData.takeRight(${randomInt()})` + const invalidTakeRight = `takeRight(callerTestData)` + const invalidTakeRightArgBeforeFunc = `callerTestData.takeRight(callerTestData, ${randomInt()})` + + test("RIDE-223. function takeRight should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomStringArrayElement(), takeRight], [randomStringArrayElement(), takeRightArgBeforeFunction]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileSuccessDApp(script, version) + + } + } + }); + + test("RIDE-224. function takeRight throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("", version) + for (const [data, func] of [[randomAddressDataArrayElement(), takeRight], [randomUnionArrayElement(), takeRightArgBeforeFunction], [randomStringArrayElement(), invalidTakeRight], [randomStringArrayElement(), invalidTakeRightArgBeforeFunc]]) { + const script = precondition.codeWithoutMatcher(data, func, rideV3Result, GreaterV3ResultStringEntry) + assertCompileErrorDApp(script, version, CANT_FIND_A_FUNCTION_OVERLOAD) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/union/extract.test.ts b/ride-js-bundle/test/builtInFunctions/union/extract.test.ts new file mode 100644 index 00000000000..3b17b35e931 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/union/extract.test.ts @@ -0,0 +1,40 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3, V4, V6 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, MATCHING_NOT_EXHAUSTIVE, actualVersionsWithoutV3, invalidFunctionError } from "../../helpers/testData"; + +describe("Extract", () => { + const extract = "extract(callerTestData)" + const extractArgBeforeFunc = "callerTestData.extract()" + const invalidExtract = "extract()" + const invalidExtractArgBeforeFunc = "callerTestData.extract(callerTestData)" + + const invalidErrorExtract = invalidFunctionError("extract", 1) + + test("RIDE-225. function extract should compile for valid data", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, func] of [[randomInt(), extract], [randomInt(), extractArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-226. function extract throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("Int", V3) + for (const [data, func, error] of [[randomUnionArrayElement(), extract, MATCHING_NOT_EXHAUSTIVE], [randomUnionArrayElement(), extractArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE], [randomInt(), invalidExtract, invalidErrorExtract], [randomInt(), invalidExtractArgBeforeFunc, invalidErrorExtract]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, V3, error) + } + }); + + test("RIDE-227. invalid extract functions for RIDE V4 - V6", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), extract], [randomInt(), extractArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/union/isDefined.test.ts b/ride-js-bundle/test/builtInFunctions/union/isDefined.test.ts new file mode 100644 index 00000000000..4764e048360 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/union/isDefined.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { MATCHING_NOT_EXHAUSTIVE, actualVersions, invalidFunctionError } from "../../helpers/testData"; + +describe("IsDefined", () => { + const isDefined = "isDefined(callerTestData)" + const isDefinedArgBeforeFunc = "callerTestData.isDefined()" + const invalidIsDefined = "isDefined()" + const invalidIsDefinedArgBeforeFunc = "callerTestData.isDefined(callerTestData)" + const invalidErrorIsDefined = invalidFunctionError("isDefined", 1) + + test("RIDE-228. function isDefined should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomAddressDataArrayElement(), isDefined], [randomAliasDataArrayElement(), isDefinedArgBeforeFunc], [randomByteVectorArrayElement(), isDefined], [randomStringArrayElement(), isDefinedArgBeforeFunc], [randomUnionArrayElement(), isDefined], [randomDigestAlgorithmTypeArrayElement(), isDefinedArgBeforeFunc], [randomInt(), isDefined], [randomBoolean(), isDefinedArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-229. function isDefined throw a compilation error for can't find overload", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), invalidIsDefined, MATCHING_NOT_EXHAUSTIVE], [randomAddressDataArrayElement(), invalidIsDefinedArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE], [randomInt(), invalidIsDefined, invalidErrorIsDefined], [randomInt(), invalidIsDefinedArgBeforeFunc, invalidErrorIsDefined]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/union/value.test.ts b/ride-js-bundle/test/builtInFunctions/union/value.test.ts new file mode 100644 index 00000000000..36e9b372838 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/union/value.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { MATCHING_NOT_EXHAUSTIVE, actualVersions, invalidFunctionError } from "../../helpers/testData"; + +describe("Value", () => { + const value = "value(callerTestData)" + const valueArgBeforeFunc = "callerTestData.value()" + const invalidValue = "value()" + const invalidValueArgBeforeFunc = "callerTestData.value(callerTestData)" + const invalidErrorValue = invalidFunctionError("value", 1) + + test("RIDE-230. function value should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Int", version) + for (const [data, func] of [[randomInt(), value], [randomInt(), valueArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-231. function value throw a compilation error for can't find overload", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), value, MATCHING_NOT_EXHAUSTIVE], [randomAddressDataArrayElement(), valueArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE], [randomInt(), invalidValue, invalidErrorValue], [randomInt(), invalidValueArgBeforeFunc, invalidErrorValue]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/union/valueOrElse.test.ts b/ride-js-bundle/test/builtInFunctions/union/valueOrElse.test.ts new file mode 100644 index 00000000000..bf9a497b2f3 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/union/valueOrElse.test.ts @@ -0,0 +1,41 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomInt, randomStringArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, CANT_MATCH_INFERRED_TYPE, actualVersionsWithoutV3, invalidFunctionError } from "../../helpers/testData"; + +describe("ValueOrElse", () => { + const valueOrElse = "valueOrElse(bar, foo)" + const valueOrElseArgBeforeFunc = "bar.valueOrElse(foo)" + const invalidValueOrElse = "valueOrElse(foo)" + const invalidValueOrElseArgBeforeFunc = "foo.valueOrElse(foo, bar)" + const invalidErrorValueOrElse = invalidFunctionError("valueOrElse", 2) + + test("RIDE-232. function valueOrElse should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func] of [[randomStringArrayElement(), randomStringArrayElement(), valueOrElse], [randomInt(), randomInt(), valueOrElse], [randomAliasDataArrayElement(), randomAliasDataArrayElement(), valueOrElse], [randomAddressDataArrayElement(), randomAddressDataArrayElement(), valueOrElseArgBeforeFunc], [randomByteVectorArrayElement(), randomByteVectorArrayElement(), valueOrElseArgBeforeFunc], [randomBoolean(), randomBoolean(), valueOrElseArgBeforeFunc]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-233. function valueOrElse throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("", version) + for (const [firstData, secondData, func, error] of [[randomInt(), randomByteVectorArrayElement(), valueOrElse, CANT_MATCH_INFERRED_TYPE], [randomInt(), randomStringArrayElement(), valueOrElseArgBeforeFunc, CANT_MATCH_INFERRED_TYPE], [randomStringArrayElement(), randomStringArrayElement(), invalidValueOrElse, invalidErrorValueOrElse], [randomByteVectorArrayElement(), randomByteVectorArrayElement(), invalidValueOrElseArgBeforeFunc, invalidErrorValueOrElse]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-234. Can't find a function valueOrElse for RIDE V3", () => { + const precondition = new ContractGenerator("", V3) + for (const [firstData, secondData, func] of [[randomAliasDataArrayElement(), randomAliasDataArrayElement(), valueOrElse], [randomAddressDataArrayElement(), randomAddressDataArrayElement(), valueOrElseArgBeforeFunc]]) { + const script = precondition.simpleRideCode(firstData, secondData, func) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/union/valueOrErrorMessage.test.ts b/ride-js-bundle/test/builtInFunctions/union/valueOrErrorMessage.test.ts new file mode 100644 index 00000000000..552ef356dda --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/union/valueOrErrorMessage.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomAliasDataArrayElement, randomBoolean, randomByteVectorArrayElement, randomInt, randomStringArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { MATCHING_NOT_EXHAUSTIVE, actualVersions, invalidFunctionError } from "../../helpers/testData"; + +describe("ValueOrErrorMessage", () => { + const valueOrErrorMessage = `valueOrErrorMessage(callerTestData, \"error message\")` + const valueOrErrorMessageArgBeforeFunction = `callerTestData.valueOrErrorMessage(\"error message\")` + const invalidValueOrErrorMessage = `valueOrErrorMessage(callerTestData)` + const invalidValueOrErrorMessageArgBeforeFunc = `callerTestData.valueOrErrorMessage(callerTestData, \"error message\")` + const valueOrErrorInvalidFunctionMessage = invalidFunctionError("valueOrErrorMessage", 2) + + test("RIDE-235. valueOrErrorMessage functions are compiled with valid data types.", () => { + for (const version of actualVersions) { + for (const [dataType, firstData, func] of [["Int", randomInt(), valueOrErrorMessage], ["Boolean", randomBoolean(), valueOrErrorMessage], ["String", randomStringArrayElement(), valueOrErrorMessage], ["ByteVector", randomByteVectorArrayElement(), valueOrErrorMessageArgBeforeFunction], ["Address", randomAddressDataArrayElement(), valueOrErrorMessageArgBeforeFunction], ["Alias", randomAliasDataArrayElement(), valueOrErrorMessageArgBeforeFunction]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(firstData, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-236. valueOrErrorMessage function should throw a compilation error for invalid data.", () => { + for (const version of actualVersions) { + for (const [dataType, firstData, func, error] of [["Alias", randomAddressDataArrayElement(), valueOrErrorMessage, MATCHING_NOT_EXHAUSTIVE], ["String", randomUnionArrayElement(), valueOrErrorMessageArgBeforeFunction, MATCHING_NOT_EXHAUSTIVE], ["String", randomStringArrayElement(), invalidValueOrErrorMessage, valueOrErrorInvalidFunctionMessage], ["ByteVector", randomByteVectorArrayElement(), invalidValueOrErrorMessageArgBeforeFunc, valueOrErrorInvalidFunctionMessage]]) { + const precondition = new ContractGenerator(dataType, version) + const script = precondition.onlyMatcherContract(firstData, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/bn256Groth16Verify.test.ts b/ride-js-bundle/test/builtInFunctions/verification/bn256Groth16Verify.test.ts new file mode 100644 index 00000000000..c055db56ccb --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/bn256Groth16Verify.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("Bn256Groth16Verify", () => { + const bn256Groth16Verify = `bn256Groth16Verify(callerTestData, callerTestData, callerTestData)` + const bn256Groth16VerifyArgBeforeFunc = `callerTestData.bn256Groth16Verify(callerTestData, callerTestData)` + const invalidBn256Groth16Verify = "bn256Groth16Verify()" + const invalidBn256Groth16VerifyArgBeforeFunc = "callerTestData.bn256Groth16Verify(callerTestData)" + const invalidErrorBn256Groth16Verify = invalidFunctionError("bn256Groth16Verify", 3) + + test("RIDE-265. bn256Groth16Verify function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), bn256Groth16Verify], [randomByteVectorArrayElement(), bn256Groth16VerifyArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-266. bn256Groth16Verify function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), bn256Groth16Verify, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), bn256Groth16VerifyArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidBn256Groth16Verify, invalidErrorBn256Groth16Verify], [randomByteVectorArrayElement(), invalidBn256Groth16VerifyArgBeforeFunc, invalidErrorBn256Groth16Verify]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-267. Can't find a function bn256Groth16Verify", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), bn256Groth16Verify) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/checkMerkleProof.test.ts b/ride-js-bundle/test/builtInFunctions/verification/checkMerkleProof.test.ts new file mode 100644 index 00000000000..f60404f6a8a --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/checkMerkleProof.test.ts @@ -0,0 +1,40 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, MATCHING_NOT_EXHAUSTIVE, actualVersionsWithoutV3, invalidFunctionError } from "../../helpers/testData"; + +describe("CheckMerkleProof", () => { + const checkMerkleProof = "checkMerkleProof(callerTestData, callerTestData, callerTestData)" + const checkMerkleProofArgBeforeFunc = "callerTestData.checkMerkleProof(callerTestData, callerTestData)" + const invalidCheckMerkleProof = "checkMerkleProof()" + const invalidCheckMerkleProofArgBeforeFunc = "callerTestData.checkMerkleProof(callerTestData)" + + const invalidErrorCheckMerkleProof = invalidFunctionError("checkMerkleProof", 3) + + test("RIDE-268. checkMerkleProof function should compile for valid data", () => { + const precondition = new ContractGenerator("Boolean", V3) + for (const [data, func] of [[randomByteVectorArrayElement(), checkMerkleProof], [randomByteVectorArrayElement(), checkMerkleProofArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, V3) + } + }); + + test("RIDE-269. checkMerkleProof function should throw a compilation error for invalid data", () => { + const precondition = new ContractGenerator("Boolean", V3) + for (const [data, func, error] of [[randomUnionArrayElement(), checkMerkleProof, MATCHING_NOT_EXHAUSTIVE], [randomAddressDataArrayElement(), checkMerkleProofArgBeforeFunc, MATCHING_NOT_EXHAUSTIVE], [randomByteVectorArrayElement(), invalidCheckMerkleProof, invalidErrorCheckMerkleProof], [randomByteVectorArrayElement(), invalidCheckMerkleProofArgBeforeFunc, invalidErrorCheckMerkleProof]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, V3, error) + } + }); + + test("RIDE-270. Can't find a function checkMerkleProof", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), checkMerkleProof], [randomByteVectorArrayElement(), checkMerkleProofArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, CANT_FIND_FUNCTION) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/createMerkleRoot.test.ts b/ride-js-bundle/test/builtInFunctions/verification/createMerkleRoot.test.ts new file mode 100644 index 00000000000..3bcce8662f5 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/createMerkleRoot.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomInt, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("CreateMerkleRoot", () => { + const createMerkleRoot = `createMerkleRoot([callerTestData], callerTestData, ${randomInt()})` + const createMerkleRootArgBeforeFunc = `[callerTestData].createMerkleRoot(callerTestData, ${randomInt()})` + const invalidCreateMerkleRoot = "createMerkleRoot()" + const invalidCreateMerkleRootArgBeforeFunc = "[callerTestData].createMerkleRoot(callerTestData)" + const invalidErrorCreateMerkleRoot = invalidFunctionError("createMerkleRoot", 3) + + test("RIDE-271. createMerkleRoot function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), createMerkleRoot], [randomByteVectorArrayElement(), createMerkleRootArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-272. createMerkleRoot function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), createMerkleRoot, nonMatchingTypes("List[ByteVector]")], [randomAddressDataArrayElement(), createMerkleRootArgBeforeFunc, nonMatchingTypes("List[ByteVector]")], [randomByteVectorArrayElement(), invalidCreateMerkleRoot, invalidErrorCreateMerkleRoot], [randomByteVectorArrayElement(), invalidCreateMerkleRootArgBeforeFunc, invalidErrorCreateMerkleRoot]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-273. Can't find a function createMerkleRoot", () => { + const precondition = new ContractGenerator("ByteVector", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), createMerkleRoot) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/ecrecover.test.ts b/ride-js-bundle/test/builtInFunctions/verification/ecrecover.test.ts new file mode 100644 index 00000000000..26c587301cd --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/ecrecover.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("Ecrecover", () => { + const ecrecover = "ecrecover(callerTestData, callerTestData)" + const ecrecoverArgBeforeFunc = "callerTestData.ecrecover(callerTestData)" + const invalidEcrecover = "ecrecover()" + const invalidEcrecoverArgBeforeFunc = "callerTestData.ecrecover()" + const invalidErrorEcrecover = invalidFunctionError("ecrecover", 2) + + test("RIDE-274. ecrecover function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func] of [[randomByteVectorArrayElement(), ecrecover], [randomByteVectorArrayElement(), ecrecoverArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-275. ecrecover function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("ByteVector", version) + for (const [data, func, error] of [[randomUnionArrayElement(), ecrecover, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), ecrecoverArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidEcrecover, invalidErrorEcrecover], [randomByteVectorArrayElement(), invalidEcrecoverArgBeforeFunc, invalidErrorEcrecover]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-276. Can't find a function ecrecover", () => { + const precondition = new ContractGenerator("ByteVector", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), ecrecover) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/groth16Verify.test.ts b/ride-js-bundle/test/builtInFunctions/verification/groth16Verify.test.ts new file mode 100644 index 00000000000..0836299e9fb --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/groth16Verify.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../helpers/jsTestBase"; +import { ContractGenerator } from "../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../helpers/testData"; + +describe("Groth16Verify", () => { + const groth16Verify = "groth16Verify(callerTestData, callerTestData, callerTestData)" + const groth16VerifyArgBeforeFunc = "callerTestData.groth16Verify(callerTestData, callerTestData)" + const invalidGroth16Verify = "groth16Verify()" + const invalidGroth16VerifyArgBeforeFunc = "callerTestData.groth16Verify()" + const invalidErrorGroth16Verify = invalidFunctionError("groth16Verify", 3) + + test("RIDE-277. groth16Verify function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), groth16Verify], [randomByteVectorArrayElement(), groth16VerifyArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-278. groth16Verify function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), groth16Verify, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), groth16VerifyArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidGroth16Verify, invalidErrorGroth16Verify], [randomByteVectorArrayElement(), invalidGroth16VerifyArgBeforeFunc, invalidErrorGroth16Verify]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-279. Can't find a function groth16Verify", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), groth16Verify) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify.test.ts b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify.test.ts new file mode 100644 index 00000000000..677c389a417 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("RsaVerify", () => { + const rsaVerify = `rsaVerify(${randomDigestAlgorithmTypeArrayElement()}, callerTestData, callerTestData, callerTestData)` + const rsaVerifyArgBeforeFunc = `${randomDigestAlgorithmTypeArrayElement()}.rsaVerify(callerTestData, callerTestData, callerTestData)` + const invalidRsaVerify = `rsaVerify()` + const invalidRsaVerifyArgBeforeFunc = `callerTestData.rsaVerify(callerTestData)` + const invalidErrorRsaVerify = invalidFunctionError("rsaVerify", 4) + + test("RIDE-237. function rsaVerify should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), rsaVerify], [randomByteVectorArrayElement(), rsaVerifyArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-238. function rsaVerify throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), rsaVerify, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), rsaVerifyArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidRsaVerify, invalidErrorRsaVerify], [randomByteVectorArrayElement(), invalidRsaVerifyArgBeforeFunc, invalidErrorRsaVerify]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_128Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_128Kb.test.ts new file mode 100644 index 00000000000..b253603d551 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_128Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("RsaVerify_128Kb", () => { + const rsaVerify_128Kb = `rsaVerify_128Kb(${randomDigestAlgorithmTypeArrayElement()}, callerTestData, callerTestData, callerTestData)` + const rsaVerify_128KbArgBeforeFunc = `${randomDigestAlgorithmTypeArrayElement()}.rsaVerify_128Kb(callerTestData, callerTestData, callerTestData)` + const invalidRsaVerify_128Kb = "rsaVerify_128Kb()" + const invalidRsaVerify_128KbArgBeforeFunc = "callerTestData.rsaVerify_128Kb(callerTestData)" + const invalidErrorRsaVerify_128Kb = invalidFunctionError("rsaVerify_128Kb", 4) + + test("RIDE-248. rsaVerify_128Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), rsaVerify_128Kb], [randomByteVectorArrayElement(), rsaVerify_128KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-249. rsaVerify_128Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), rsaVerify_128Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), rsaVerify_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidRsaVerify_128Kb, invalidErrorRsaVerify_128Kb], [randomByteVectorArrayElement(), invalidRsaVerify_128KbArgBeforeFunc, invalidErrorRsaVerify_128Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-250. Can't find a function rsaVerify_128Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), rsaVerify_128Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_16Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_16Kb.test.ts new file mode 100644 index 00000000000..4e9d43d7b3b --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_16Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("RsaVerify_16Kb", () => { + const rsaVerify_16Kb = `rsaVerify_16Kb(${randomDigestAlgorithmTypeArrayElement()}, callerTestData, callerTestData, callerTestData)` + const rsaVerify_16KbArgBeforeFunc = `${randomDigestAlgorithmTypeArrayElement()}.rsaVerify_16Kb(callerTestData, callerTestData, callerTestData)` + const invalidRsaVerify_16Kb = "rsaVerify_16Kb()" + const invalidRsaVerify_16KbArgBeforeFunc = "callerTestData.rsaVerify_16Kb(callerTestData)" + const invalidErrorRsaVerify_16Kb = invalidFunctionError("rsaVerify_16Kb", 4) + + test("RIDE-239. rsaVerify_16Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), rsaVerify_16Kb], [randomByteVectorArrayElement(), rsaVerify_16KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-240. rsaVerify_16Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), rsaVerify_16Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), rsaVerify_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidRsaVerify_16Kb, invalidErrorRsaVerify_16Kb], [randomByteVectorArrayElement(), invalidRsaVerify_16KbArgBeforeFunc, invalidErrorRsaVerify_16Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-241. Can't find a function makeString_2C for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), rsaVerify_16Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_32Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_32Kb.test.ts new file mode 100644 index 00000000000..f996fc9177c --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_32Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("RsaVerify_32Kb", () => { + const rsaVerify_32Kb = `rsaVerify_32Kb(${randomDigestAlgorithmTypeArrayElement()}, callerTestData, callerTestData, callerTestData)` + const rsaVerify_32KbArgBeforeFunc = `${randomDigestAlgorithmTypeArrayElement()}.rsaVerify_32Kb(callerTestData, callerTestData, callerTestData)` + const invalidRsaVerify_32Kb = "rsaVerify_32Kb()" + const invalidRsaVerify_32KbArgBeforeFunc = "callerTestData.rsaVerify_32Kb(callerTestData)" + const invalidErrorRsaVerify_32Kb = invalidFunctionError("rsaVerify_32Kb", 4) + + test("RIDE-242. rsaVerify_32Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), rsaVerify_32Kb], [randomByteVectorArrayElement(), rsaVerify_32KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-243. rsaVerify_32Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), rsaVerify_32Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), rsaVerify_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidRsaVerify_32Kb, invalidErrorRsaVerify_32Kb], [randomByteVectorArrayElement(), invalidRsaVerify_32KbArgBeforeFunc, invalidErrorRsaVerify_32Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-244. Can't find a function rsaVerify_32Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), rsaVerify_32Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_64Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_64Kb.test.ts new file mode 100644 index 00000000000..1e356f83d81 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/rsaVerify/rsaVerify_64Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomDigestAlgorithmTypeArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("RsaVerify_64Kb", () => { + const rsaVerify_64Kb = `rsaVerify_64Kb(${randomDigestAlgorithmTypeArrayElement()}, callerTestData, callerTestData, callerTestData)` + const rsaVerify_64KbArgBeforeFunc = `${randomDigestAlgorithmTypeArrayElement()}.rsaVerify_64Kb(callerTestData, callerTestData, callerTestData)` + const invalidRsaVerify_64Kb = "rsaVerify_64Kb()" + const invalidRsaVerify_64KbArgBeforeFunc = "callerTestData.rsaVerify_64Kb(callerTestData)" + const invalidErrorRsaVerify_64Kb = invalidFunctionError("rsaVerify_64Kb", 4) + + test("RIDE-245. rsaVerify_64Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), rsaVerify_64Kb], [randomByteVectorArrayElement(), rsaVerify_64KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-246. rsaVerify_64Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), rsaVerify_64Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), rsaVerify_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidRsaVerify_64Kb, invalidErrorRsaVerify_64Kb], [randomByteVectorArrayElement(), invalidRsaVerify_64KbArgBeforeFunc, invalidErrorRsaVerify_64Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-247. Can't find a function rsaVerify_64Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), rsaVerify_64Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify.test.ts b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify.test.ts new file mode 100644 index 00000000000..99b9b1cd830 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify.test.ts @@ -0,0 +1,33 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { actualVersions, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("SigVerify", () => { + const sigVerify = `sigVerify(callerTestData, callerTestData, callerTestData)` + const sigVerifyArgBeforeFunc = `callerTestData.sigVerify(callerTestData, callerTestData)` + const invalidSigVerify = `sigVerify()` + const invalidSigVerifyArgBeforeFunc = `callerTestData.sigVerify(callerTestData)` + const invalidErrorSigVerify = invalidFunctionError("sigVerify", 3) + + test("RIDE-251. function sigVerify should compile for valid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sigVerify], [randomByteVectorArrayElement(), sigVerifyArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-252. function rsaVerify throw a compilation error for invalid data", () => { + for (const version of actualVersions) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sigVerify, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sigVerifyArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSigVerify, invalidErrorSigVerify], [randomByteVectorArrayElement(), invalidSigVerifyArgBeforeFunc, invalidErrorSigVerify]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_128Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_128Kb.test.ts new file mode 100644 index 00000000000..8fd2f958cd3 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_128Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("SigVerify_128Kb", () => { + const sigVerify_128Kb = `sigVerify_128Kb(callerTestData, callerTestData, callerTestData)` + const sigVerify_128KbArgBeforeFunc = `callerTestData.sigVerify_128Kb(callerTestData, callerTestData)` + const invalidSigVerify_128Kb = "sigVerify_128Kb()" + const invalidSigVerify_128KbArgBeforeFunc = "callerTestData.sigVerify_128Kb(callerTestData)" + const invalidErrorSigVerify_128Kb = invalidFunctionError("sigVerify_128Kb", 3) + + test("RIDE-262. sigVerify_128Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sigVerify_128Kb], [randomByteVectorArrayElement(), sigVerify_128KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-263. sigVerify_128Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sigVerify_128Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sigVerify_128KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSigVerify_128Kb, invalidErrorSigVerify_128Kb], [randomByteVectorArrayElement(), invalidSigVerify_128KbArgBeforeFunc, invalidErrorSigVerify_128Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-264. Can't find a function sigVerify_128Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), sigVerify_128Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_16Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_16Kb.test.ts new file mode 100644 index 00000000000..4b7d5afece8 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_16Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("SigVerify_16Kb", () => { + const sigVerify_16Kb = `sigVerify_16Kb(callerTestData, callerTestData, callerTestData)` + const sigVerify_16KbArgBeforeFunc = `callerTestData.sigVerify_16Kb(callerTestData, callerTestData)` + const invalidSigVerify_16Kb = "sigVerify_16Kb()" + const invalidSigVerify_16KbArgBeforeFunc = "callerTestData.sigVerify_16Kb(callerTestData)" + const invalidErrorSigVerify_16Kb = invalidFunctionError("sigVerify_16Kb", 3) + + test("RIDE-253. sigVerify_16Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sigVerify_16Kb], [randomByteVectorArrayElement(), sigVerify_16KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-254. sigVerify_16Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sigVerify_16Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sigVerify_16KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSigVerify_16Kb, invalidErrorSigVerify_16Kb], [randomByteVectorArrayElement(), invalidSigVerify_16KbArgBeforeFunc, invalidErrorSigVerify_16Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-255. Can't find a function sigVerify_16Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), sigVerify_16Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_32Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_32Kb.test.ts new file mode 100644 index 00000000000..48134667e67 --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_32Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("SigVerify_32Kb", () => { + const sigVerify_32Kb = `sigVerify_32Kb(callerTestData, callerTestData, callerTestData)` + const sigVerify_32KbArgBeforeFunc = `callerTestData.sigVerify_32Kb(callerTestData, callerTestData)` + const invalidSigVerify_32Kb = "sigVerify_32Kb()" + const invalidSigVerify_32KbArgBeforeFunc = "callerTestData.sigVerify_32Kb(callerTestData)" + const invalidErrorSigVerify_32Kb = invalidFunctionError("sigVerify_32Kb", 3) + + test("RIDE-256. sigVerify_32Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sigVerify_32Kb], [randomByteVectorArrayElement(), sigVerify_32KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-257. sigVerify_32Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sigVerify_32Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sigVerify_32KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSigVerify_32Kb, invalidErrorSigVerify_32Kb], [randomByteVectorArrayElement(), invalidSigVerify_32KbArgBeforeFunc, invalidErrorSigVerify_32Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-258. Can't find a function sigVerify_32Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), sigVerify_32Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_64Kb.test.ts b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_64Kb.test.ts new file mode 100644 index 00000000000..5de785e4b0d --- /dev/null +++ b/ride-js-bundle/test/builtInFunctions/verification/sigVerify/sigVerify_64Kb.test.ts @@ -0,0 +1,39 @@ +import { describe, test } from "vitest"; +import { assertCompileErrorDApp, assertCompileSuccessDApp, V3 } from "../../../helpers/jsTestBase"; +import { ContractGenerator } from "../../../helpers/contractGenerator"; +import { randomAddressDataArrayElement, randomByteVectorArrayElement, randomUnionArrayElement } from "../../../helpers/randomData"; +import { CANT_FIND_FUNCTION, actualVersionsWithoutV3, invalidFunctionError, nonMatchingTypes } from "../../../helpers/testData"; + +describe("SigVerify_64Kb", () => { + const sigVerify_64Kb = `sigVerify_64Kb(callerTestData, callerTestData, callerTestData)` + const sigVerify_64KbArgBeforeFunc = `callerTestData.sigVerify_64Kb(callerTestData, callerTestData)` + const invalidSigVerify_64Kb = "sigVerify_64Kb()" + const invalidSigVerify_64KbArgBeforeFunc = "callerTestData.sigVerify_64Kb(callerTestData)" + const invalidErrorSigVerify_64Kb = invalidFunctionError("sigVerify_64Kb", 3) + + test("RIDE-259. sigVerify_64Kb function should compile for valid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func] of [[randomByteVectorArrayElement(), sigVerify_64Kb], [randomByteVectorArrayElement(), sigVerify_64KbArgBeforeFunc]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileSuccessDApp(script, version) + } + } + }); + + test("RIDE-260. sigVerify_64Kb function should throw a compilation error for invalid data", () => { + for (const version of actualVersionsWithoutV3) { + const precondition = new ContractGenerator("Boolean", version) + for (const [data, func, error] of [[randomUnionArrayElement(), sigVerify_64Kb, nonMatchingTypes("ByteVector")], [randomAddressDataArrayElement(), sigVerify_64KbArgBeforeFunc, nonMatchingTypes("ByteVector")], [randomByteVectorArrayElement(), invalidSigVerify_64Kb, invalidErrorSigVerify_64Kb], [randomByteVectorArrayElement(), invalidSigVerify_64KbArgBeforeFunc, invalidErrorSigVerify_64Kb]]) { + const script = precondition.onlyMatcherContract(data, func) + assertCompileErrorDApp(script, version, error) + } + } + }); + + test("RIDE-261. Can't find a function sigVerify_64Kb for RIDE V3", () => { + const precondition = new ContractGenerator("Boolean", V3) + const script = precondition.onlyMatcherContract(randomByteVectorArrayElement(), sigVerify_64Kb) + assertCompileErrorDApp(script, V3, CANT_FIND_FUNCTION) + }); +}); diff --git a/ride-js-bundle/test/helpers/compiler.ts b/ride-js-bundle/test/helpers/compiler.ts new file mode 100644 index 00000000000..76091561b5a --- /dev/null +++ b/ride-js-bundle/test/helpers/compiler.ts @@ -0,0 +1,65 @@ +// Tests exercise the real shipped public API of @waves/ride-js (the wrapped glue), +// which loads ./interop (real @waves/ts-lib-crypto globals) and the single combined +// ScalaJS artifact. We require the built CommonJS entry (dist/index.js) — the glue +// uses require/module.exports/global, so it must be consumed as CJS, not the TS +// source. `npm test` runs `pretest` (build:scalajs + build:ts) to produce it. +import { createRequire } from "module"; + +const require = createRequire(import.meta.url); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const ride = require("../../dist/index.js"); + +// The public `compile` wraps a successful result under `.result` ({ bytes, base64, +// size, ast, complexity, verifierComplexity, callableComplexities, ... }); on +// failure it returns a flat `{ error }`. `parseAndCompile`/`decompile`/`scriptInfo` +// are raw passthroughs. +export interface CompileResult { + error?: unknown; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + result?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +} + +export interface ParseAndCompileResult { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + exprAst?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + dAppAst?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ast?: any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + errorList?: any[]; + error?: unknown; + complexity?: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +} + +export function compile( + input: string, + estimatorVersion: number, + needCompaction = false, + removeUnusedCode = false, + libraries: Record = {} +): CompileResult { + return ride.compile(input, estimatorVersion, needCompaction, removeUnusedCode, libraries); +} + +export function parseAndCompile( + input: string, + estimatorVersion: number, + needCompaction = false, + removeUnusedCode = false, + libraries: Record = {} +): ParseAndCompileResult { + return ride.parseAndCompile(input, estimatorVersion, needCompaction, removeUnusedCode, libraries); +} + +export function decompile(input: string): { result?: string; error?: string } { + return ride.decompile(input); +} + +export function scriptInfo(input: string): Record { + return ride.scriptInfo(input); +} diff --git a/ride-js-bundle/test/helpers/contractGenerator.ts b/ride-js-bundle/test/helpers/contractGenerator.ts new file mode 100644 index 00000000000..07db81dafa6 --- /dev/null +++ b/ride-js-bundle/test/helpers/contractGenerator.ts @@ -0,0 +1,157 @@ +// Port of testHelpers/GeneratorContractsForBuiltInFunctions.scala +import { V3 } from "./jsTestBase"; + +export class ContractGenerator { + constructor( + public readonly dataType: string, + private readonly libVersion: number + ) {} + + codeFromMatchingAndCase(testData: string, func: string, testDataForV3: string, testDataForGreaterV3: string): string { + const caseForVersion = this.caseForVersions(testDataForV3, testDataForGreaterV3); + return ` + +@Callable(i) + func expression() = { + let callerTestData = ${testData} + let valueOrUnit = ${func} + let throwMessage = "not ${this.dataType}" + let val = match(valueOrUnit) { + case b:${this.dataType} => b + case _ => throwMessage.throw() + } + ${caseForVersion} + } +`; + } + + codeOwnData(ownDataFunction: string, testDataForV3: string, testDataForGreaterV3: string): string { + const caseForVersion = this.caseForVersions(testDataForV3, testDataForGreaterV3); + return ` + +@Callable(i) + func expression() = { + let valueOrUnit = ${ownDataFunction} + let val = match(valueOrUnit) { + case b:${this.dataType} => b + case _ => throw("not ${this.dataType}") + } + ${caseForVersion} + } +`; + } + + codeWithoutMatcher(testData: string, func: string, testDataForV3: string, testDataForGreaterV3: string): string { + const caseForVersion = this.caseForVersions(testDataForV3, testDataForGreaterV3); + return ` + +@Callable(i) + func expression() = { + let callerTestData = ${testData} + let val = ${func} + ${caseForVersion} + } +`; + } + + codeOwnDataWithoutMatcher(ownDataFunction: string, caseForVersions: string): string { + return ` + + @Callable(i) + func expression() = { + let val = ${ownDataFunction} + ${caseForVersions} + } +`; + } + + onlyMatcherContract(testData: string, func: string): string { + return ` + + let callerTestData = ${testData} + let x = match ${func} { + case h:${this.dataType} => h + case _ => throw("not ${this.dataType}") + } +`; + } + + simpleRideCode(foo: string, bar: string, testFunction: string): string { + return ` + +let foo = ${foo} +let bar = ${bar} +let callerTestData = ${testFunction} +`; + } + + codeForDAppInvocation(byteVector: string, payment: string, func: string): string { + return ` + +func foo(dapp2: String, a: Int, key1: String, key2: String) = { + let byteVector = ${byteVector} + let payment = ${payment} + strict res = ${func} + match res { + case r : Int => + ( + [ + IntegerEntry(key1, r), + IntegerEntry(key2, wavesBalance(addressFromStringValue(dapp2)).regular) + ], + unit + ) + case _ => throw("Incorrect invoke result") + } + } + + @Callable(i) + func bar(a: Int) = { + ( + [ + ScriptTransfer(i.caller, 100000000, unit) + ], + a * 2 + ) + } +`; + } + + codeForAddressFromRecipient(addressOrAlias: string, func: string, address: string): string { + return ` +let addressOrAlias = ${addressOrAlias}; + match (tx) { + case t: TransferTransaction => ${func} == ${address} + case _ => false + } +`; + } + + codeForCalculateAssetId(testData: string, func: string): string { + return ` +@Callable(inv) + func issueAndId() = { + let issue = ${testData} + let id = ${func} + ([issue])} +`; + } + + codeForCalculateLeaseId(testData: string, func: string): string { + return ` +@Callable(i) + func foo() = { + let lease = Lease(${testData}, 100000000) + let id = ${func} + ([ + lease, + BinaryEntry("lease", id) + ], unit) + } +`; + } + + private caseForVersions(testDataForV3: string, testDataForGreaterV3: string): string { + return this.libVersion > V3 ? testDataForGreaterV3 : testDataForV3; + } +} diff --git a/ride-js-bundle/test/helpers/jsTestBase.ts b/ride-js-bundle/test/helpers/jsTestBase.ts new file mode 100644 index 00000000000..19b45644a8e --- /dev/null +++ b/ride-js-bundle/test/helpers/jsTestBase.ts @@ -0,0 +1,92 @@ +// Port of com/wavesplatform/JsTestBase.scala +// Assertion helpers + script wrappers built on the public compiler API. +import { expect } from "vitest"; +import { compile } from "./compiler"; + +// StdLibVersion collapses to its numeric id in JS. +export const V1 = 1; +export const V2 = 2; +export const V3 = 3; +export const V4 = 4; +export const V5 = 5; +export const V6 = 6; +export const V7 = 7; +export const V8 = 8; +export const V9 = 9; + +// Mirrors DirectiveDictionary[StdLibVersion].all (all defined library versions). +export const allStdLibVersions: number[] = [V1, V2, V3, V4, V5, V6, V7, V8, V9]; + +export interface DAppComplexitiesResult { + complexity: number; + verifierComplexity: number; + callableComplexities: Record; + userFunctionComplexities: Record; + globalVariableComplexities: Record; +} + +export function assertCompileError(code: string, expectingError: string, estimator = 3): void { + const error = compile(code, estimator).error; + expect(String(error)).toContain(expectingError); +} + +export function assertCompileErrorDApp(code: string, version: number, expectingError: string, estimator = 3): void { + const error = compile(dApp(code, version), estimator).error; + expect(String(error)).toContain(expectingError); +} + +export function assertCompileErrorExpression(code: string, version: number, expectingError: string, estimator = 3): void { + const error = compile(expression(code, version), estimator).error; + expect(String(error)).toContain(expectingError); +} + +export function assertCompileSuccess(code: string, estimator = 3): void { + const error = compile(code, estimator).error; + expect(error).toBeUndefined(); +} + +export function assertCompileSuccessDApp(code: string, version: number, estimator = 3): void { + const error = compile(dApp(code, version), estimator).error; + expect(error).toBeUndefined(); +} + +export function assertCompileSuccessExpression(code: string, version: number, estimator = 3): void { + const error = compile(expression(code, version), estimator).error; + expect(error).toBeUndefined(); +} + +export function expressionComplexity(code: string, version = V6, estimator = 3): number { + // The wrapped public `compile` nests a successful result under `.result`. + return compile(expression(code, version), estimator).result.complexity as number; +} + +export function dAppComplexities(code: string, version = V6, estimator = 3): DAppComplexitiesResult { + const { result } = compile(dApp(code, version), estimator); + return { + complexity: result.complexity as number, + verifierComplexity: result.verifierComplexity as number, + callableComplexities: result.callableComplexities as Record, + userFunctionComplexities: result.userFunctionComplexities as Record, + globalVariableComplexities: result.globalVariableComplexities as Record + }; +} + +export function expression(code: string, version: number): string { + return ` +{-# STDLIB_VERSION ${version} #-} +{-# CONTENT_TYPE EXPRESSION #-} +{-# SCRIPT_TYPE ACCOUNT #-} + +${code} + `; +} + +export function dApp(code: string, version: number): string { + return ` +{-# STDLIB_VERSION ${version} #-} +{-# CONTENT_TYPE DAPP #-} +{-# SCRIPT_TYPE ACCOUNT #-} + +${code} + `; +} diff --git a/ride-js-bundle/test/helpers/randomData.ts b/ride-js-bundle/test/helpers/randomData.ts new file mode 100644 index 00000000000..4ef3435582f --- /dev/null +++ b/ride-js-bundle/test/helpers/randomData.ts @@ -0,0 +1,90 @@ +// Port of testHelpers/RandomDataGenerator.scala +// Picks random RIDE source fragments from fixed fixtures. As in the original, +// randomness only selects which valid/invalid fixture is fed to the compiler; +// assertions are about compile success/error, not the concrete value. + +function pick(arr: readonly string[]): string { + return arr[Math.floor(Math.random() * arr.length)]; +} + +export const addressDataArray: readonly string[] = [ + "Address(base58'')", + "Address(base58'3MDaMwqLtwBGcJrTA5tstJfY95GqnNnDDAS')", + "Address(base58'3PDaScqLtwBGcJrTA5tstJfY95GqnNnLxGA')", + "Address(base58'3P3aScAJsxBGcJrTA5tstJfY95GqnNnHLGA')" +]; + +export const aliasDataArray: readonly string[] = [ + 'Alias("merry_1312@pro")', + 'Alias("four")', + 'Alias("1111this_alias_30@long-symbols")', + 'Alias("")' +]; + +export const byteVectorArray: readonly string[] = [ + "base16'52696465'", + "base58'8t38fWQhrYJsqxXtPpiRCEk1g5RJdq9bG5Rkr2N7mDFC'", + "base64'UmlkZQ=='" +]; + +export const stringArray: readonly string[] = [ + '"3P3aScAJsxBGcJrTA5tstJfY95GqnNnHLGAlsadjbf87"', + '"8t38fWQhrYJsqxXtPpiRCEk1g5RJdq9bG5Rkr2N7mDFC"', + '"3MDaMwqLtwBGcJrTA5tstJfY95GqnNnDDASmsakmd091"', + '"3P3aScAJsxBGGqnNnHLGAlsadjbf87"', + '"8t38fWQhrYJsqxXtPpiRasdiuh32he98ddr2N7"', + '"091"' +]; + +export const issuesArray: readonly string[] = [ + 'Issue("superToken", "token for super humans", 1000, 2, true)', + 'Issue("trueToken", "real token in real life", 5_000_000_000, 5, false)', + 'Issue("oneMoreToken", "just one more token in this crypto world", 1_500_000_000, 5, true)', + 'Issue("assetForAll", "asset for all peoples", 1_500_000_000, 5, true)' +]; + +export const unionArray: readonly string[] = ["DOWN", "CEILING", "FLOOR", "HALFUP", "HALFEVEN"]; + +export const digestAlgorithmTypeArray: readonly string[] = [ + "NOALG", + "MD5", + "SHA1", + "SHA224", + "SHA256", + "SHA384", + "SHA512", + "SHA3224", + "SHA3256", + "SHA3384", + "SHA3512" +]; + +export function randomInt(): number { + return Math.floor(Math.random() * 90000000); +} + +export function randomBoolean(): boolean { + return randomInt() % 2 === 0; +} + +export const randomAddressDataArrayElement = (): string => pick(addressDataArray); +export const randomAliasDataArrayElement = (): string => pick(aliasDataArray); +export const randomByteVectorArrayElement = (): string => pick(byteVectorArray); +export const randomStringArrayElement = (): string => pick(stringArray); +export const randomIssuesArrayElement = (): string => pick(issuesArray); +export const randomUnionArrayElement = (): string => pick(unionArray); +export const randomDigestAlgorithmTypeArrayElement = (): string => pick(digestAlgorithmTypeArray); + +export function entryMap(key: string): string { + const entryArray: Record = { + BinaryEntry: `[BinaryEntry("key", ${randomByteVectorArrayElement()})]`, + IntegerEntry: `[IntegerEntry("key", ${randomInt()})]`, + StringEntry: `[StringEntry("key", ${randomStringArrayElement()})]`, + BooleanEntry: `[BooleanEntry("key", ${randomBoolean()})]` + }; + return entryArray[key]; +} + +export function dataEntryForTests(value: string): string { + return `[DataEntry("key", ${value})]`; +} diff --git a/ride-js-bundle/test/helpers/testData.ts b/ride-js-bundle/test/helpers/testData.ts new file mode 100644 index 00000000000..48be01b0bf9 --- /dev/null +++ b/ride-js-bundle/test/helpers/testData.ts @@ -0,0 +1,61 @@ +// Port of testHelpers/TestDataConstantsAndMethods.scala +import { V3, V4, V5, V6 } from "./jsTestBase"; +import { entryMap } from "./randomData"; + +export const oldVersions: number[] = [V3, V4]; +export const versionsSupportingTheNewFeatures: number[] = [V5, V6]; +export const versionsWithoutV6: number[] = [V3, V4, V5]; +export const actualVersionsWithoutV3: number[] = [V4, V5, V6]; +export const actualVersions: number[] = [V3, V4, V5, V6]; + +export const CANT_FIND_A_FUNCTION_OVERLOAD = "Can't find a function overload"; +export const CANT_FIND_FUNCTION = "Can't find a function"; +export const CANT_MATCH_INFERRED_TYPE = "Can't match inferred types of T over"; +export const MATCHING_NOT_EXHAUSTIVE = "Matching not exhaustive:"; +export const UNDEFINED_TYPE = "Undefined type: `BigInt`"; +export const stringList = '["a", "b", "c", "d", "e", "f", "g"]'; +export const intList = "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"; +export const thisVariable = "this"; + +export function nonMatchingTypes(expectType: string): string { + return `Non-matching types: expected: ${expectType}`; +} + +export function invalidFunctionError(functionName: string, numberOfArguments: number): string { + return `Function '${functionName}' requires ${numberOfArguments} arguments`; +} + +export const binaryEntryForTests: string = entryMap("BinaryEntry"); +export const integerEntryForTests: string = entryMap("IntegerEntry"); +export const stringEntryForTests: string = entryMap("StringEntry"); +export const booleanEntryForTests: string = entryMap("BooleanEntry"); + +export const rideV3Result = ` +WriteSet([ + DataEntry("dataType", val) + ]) +`; + +export const GreaterV3ResultBinaryEntry = ` +[ + BinaryEntry("bin", val) +] +`; + +export const GreaterV3ResultBooleanEntry = ` +[ + BooleanEntry("boolean", val) +] +`; + +export const GreaterV3ResultIntegerEntry = ` +[ + IntegerEntry("integer", val) +] +`; + +export const GreaterV3ResultStringEntry = ` +[ + StringEntry("String", val) +] +`; diff --git a/ride-js-bundle/test/jsApi.test.ts b/ride-js-bundle/test/jsApi.test.ts new file mode 100644 index 00000000000..f12a865605c --- /dev/null +++ b/ride-js-bundle/test/jsApi.test.ts @@ -0,0 +1,246 @@ +import { describe, test, expect } from "vitest"; +import { parseAndCompile } from "./helpers/compiler"; +import { + assertCompileError, + assertCompileSuccess, + expressionComplexity, + dAppComplexities, + dApp, + V5, + V6 +} from "./helpers/jsTestBase"; + +// Mirrors Scala's String.stripMargin: strips leading whitespace + '|' per line. +// Needed for the position-sensitive AST tests, whose expected posStart/posEnd +// offsets depend on the exact byte layout of the original Scala literals. +function stripMargin(s: string): string { + return s + .split("\n") + .map((line) => line.replace(/^\s*\|/, "")) + .join("\n"); +} + +function simpleDApp(result: string): string { + return dApp( + ` +@Callable(i) +func f() = ${result} + `, + V6 + ); +} + +describe("JsAPITest", () => { + test("expression error and success", () => { + assertCompileError("1 + 1", "Script should return boolean"); + assertCompileSuccess("true"); + }); + + test("dApp error and success", () => { + assertCompileError(simpleDApp("true"), "CallableFunction needs to return"); + assertCompileSuccess(simpleDApp("[]")); + }); + + test("expression complexity", () => { + expect(expressionComplexity("sigVerify(base16'', base58'', base64'')", V5)).toBe(200); + expect(expressionComplexity("sigVerify(base16'', base58'', base64'')")).toBe(180); + }); + + test("dApp complexities", () => { + const r = dAppComplexities( + ` + let x = 1 + 1 + func f(list: List[Int]) =list.size() + + @Callable(i) + func c1() = [] + + @Callable(i) + func c2() = [IntegerEntry("key", x)] + + @Verifier(tx) + func verify() = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) + ` + ); + expect(r.complexity).toBe(182); + expect(r.verifierComplexity).toBe(182); + expect(r.callableComplexities).toEqual({ c1: 1, c2: 4 }); + expect(r.userFunctionComplexities).toEqual({ f: 2 }); + expect(r.globalVariableComplexities).toEqual({ x: 1 }); + }); + + test("AST result type for declarations", () => { + const compiled = parseAndCompile( + dApp( + ` + func sum(acc: List[Int], elem: Int) = acc :+ elem + let arr = [1, 2, 3, 4, 5] + let letFold = FOLD<5>(arr, [], sum) + + @Callable(i) + func default() = { + let letCall = i.caller.toString() + let letIf = if (true) then 1 else "" + let letMatch = match letIf { + case _: Int => true + case _: String => Address(base58'') + } + func funcRef() = letCall + [] + } + `, + V6 + ), + 3 + ); + const callables = compiled.dAppAst.annFuncList; + + const invocation = callables[0].func.expr.dec.expr.args[0].ref; + expect(invocation.name).toBe("i"); + expect(invocation.resultType.type).toBe("Invocation"); + + const letCall = callables[0].func.expr.dec; + expect(letCall.name.value).toBe("letCall"); + expect(letCall.expr.resultType.type).toBe("String"); + + const letIf = callables[0].func.expr.body.dec; + expect(letIf.name.value).toBe("letIf"); + expect(JSON.stringify(letIf.expr.resultType.unionTypes)).toBe('[{"type":"Int"},{"type":"String"}]'); + + const letMatch = callables[0].func.expr.body.body.dec; + expect(letMatch.name.value).toBe("letMatch"); + expect(JSON.stringify(letMatch.expr.resultType.unionTypes)).toBe('[{"type":"Boolean"},{"type":"Address"}]'); + + const funcRef = callables[0].func.expr.body.body.body.dec; + expect(funcRef.name.value).toBe("funcRef"); + expect(funcRef.expr.resultType.type).toBe("String"); + + const letFold = compiled.dAppAst.decList[2]; + expect(letFold.name.value).toBe("letFold"); + expect(JSON.stringify(letFold.expr.resultType)).toBe('{"listOf":{"type":"Int"}}'); + }); + + test("AST result should be fixed while using libraries", () => { + const script = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# IMPORT lib1, lib2, lib3 #-} + | let a = 5 + | func f() = 3 + | true + `); + + const import1 = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# CONTENT_TYPE LIBRARY #-} + | func inc(a: Int) = a + 1 + `); + + const anotherImport1 = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# CONTENT_TYPE LIBRARY #-} + | func inc(a: Int) = { + | if (true) then throw() else a + 1 + | } + `); + + const import2 = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# CONTENT_TYPE LIBRARY #-} + | func dec(a: Int) = a - 1 + `); + + const import3 = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# CONTENT_TYPE LIBRARY #-} + | func multiply(a: Int, b: Int) = a * b + `); + + const r1 = parseAndCompile(script, 3, false, false, { lib1: import1, lib2: import2, lib3: import3 }); + const r2 = parseAndCompile(script, 3, false, false, { lib1: anotherImport1, lib2: import2, lib3: import3 }); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function checkPos(expr: any): void { + const letDec = expr.exprAst.expr.body.body.body.dec; + expect(letDec.type).toBe("LET"); + expect(letDec.name.value).toBe("a"); + expect(letDec.posStart).toBe(64); + expect(letDec.posEnd).toBe(73); + + const func = expr.exprAst.expr.body.body.body.body.dec; + expect(func.type).toBe("FUNC"); + expect(func.name.value).toBe("f"); + expect(func.posStart).toBe(75); + expect(func.posEnd).toBe(87); + } + + checkPos(r1); + checkPos(r2); + }); + + test("correct AST for library", () => { + const library = stripMargin(` + | {-# SCRIPT_TYPE ACCOUNT #-} + | {-# CONTENT_TYPE LIBRARY #-} + | func f() = 1 + `); + + const result = parseAndCompile(library, 3); + const expected = ` +{ + "dec": { + "type": "FUNC", + "posStart": 62, + "posEnd": 74, + "name": { + "value": "f", + "posStart": 67, + "posEnd": 68 + }, + "argList": [], + "expr": { + "type": "CONST_LONG", + "posStart": 73, + "posEnd": 74, + "resultType": { + "type": "Int" + }, + "ctx": [] + } + }, + "body": { + "type": "TRUE", + "posStart": 84, + "posEnd": 88, + "resultType": { + "type": "Boolean" + }, + "ctx": [] + }, + "type": "BLOCK", + "posStart": 62, + "posEnd": 88, + "resultType": { + "type": "Boolean" + }, + "ctx": [] +} + `; + expect(JSON.stringify(result.exprAst.expr)).toBe(JSON.stringify(JSON.parse(expected))); + expect(JSON.stringify(result.errorList)).toBe("[]"); + }); + + test("ill-formed characters", () => { + const invalidChar = "\ud87e"; + const script = ` +{-# STDLIB_VERSION 6 #-} +{-# CONTENT_TYPE DAPP #-} +{-# SCRIPT_TYPE ACCOUNT #-} + +func call(a: String, b: Int) = { + let zzz = "aaa${invalidChar}bbb" + ([], zzz) +} + `; + assertCompileError(script, "contains ill-formed characters"); + }); +}); diff --git a/ride-js-bundle/tsconfig.json b/ride-js-bundle/tsconfig.json new file mode 100644 index 00000000000..5e9034fa085 --- /dev/null +++ b/ride-js-bundle/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "node", + "lib": ["ES2020"], + "types": ["node"], + "rootDir": "src", + "outDir": "dist", + "declaration": false, + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "strict": false + }, + "include": ["src/**/*.ts"] +} diff --git a/ride-js-bundle/vitest.config.ts b/ride-js-bundle/vitest.config.ts new file mode 100644 index 00000000000..c0c887dcaba --- /dev/null +++ b/ride-js-bundle/vitest.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + globals: false, + include: ["test/**/*.test.ts"] + } +}); diff --git a/ride-js-bundle/webpack.config.js b/ride-js-bundle/webpack.config.js new file mode 100644 index 00000000000..fd60737a23d --- /dev/null +++ b/ride-js-bundle/webpack.config.js @@ -0,0 +1,15 @@ +const path = require("path"); +const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); + +// Browser bundle. The entry (dist/index.js) requires the single combined ScalaJS +// artifact (scalajs/ride-scalajs.js) exactly once, so it is inlined once here too. +module.exports = { + mode: "production", + entry: "./dist/index.js", + output: { + path: path.resolve(__dirname, "dist"), + filename: "ride.min.js", + library: "RideJS" + }, + plugins: [new NodePolyfillPlugin()] +};