diff --git a/README.md b/README.md index add0e554..16fb70ae 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ Appkit is a foundational non-opinionated library which can be used to create oth libraries, Apps and tools. Here is the list of projects which use Appkit. - [Official Ergo Wallet App](https://github.com/ergoplatform/ergo-wallet-app) - a cross-platform wallet for Ergo supporting Android, iOS (via RoboVM) and Desktop (via Kotlin Compose). Can be used as an example of cross-platform application using Appkit. +- [SigmaFi](https://github.com/K-Singh/Sigma-Finance) - A Decentralized P2P Financial Contracts on the Ergo blockchain. - [ErgoMixer](https://github.com/ergoMixer/ergoMixBack) - a web application for mixing ergs and tokens based on Ergo platform - [ergo-playgrounds](https://github.com/ergoplatform/ergo-playgrounds) - Run contracts + off-chain code in the browser - [ErgoGravity](https://github.com/ErgoGravity) - provides the required tools for Ergo platform to be integrated with Gravity network (`gateway-proxy`, `ergo-susy-proxy`, `ergo-luport-executor`, `startup-script`) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala index 1e4ffb09..963e8439 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala @@ -4,14 +4,15 @@ import org.ergoplatform.appkit.examples.RunMockedScala import org.ergoplatform.appkit.examples.RunMockedScala.createMockedErgoClient import org.ergoplatform.appkit.testing.AppkitTesting import org.ergoplatform.{ErgoAddressEncoder, Pay2SAddress} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{Matchers, PropSpec} import scorex.util.encode.Base16 import sigmastate.serialization.ErgoTreeSerializer -class AddressSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class AddressSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting { def checkIsTestnetP2PKAddress(addr: Address) = { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala index f37e2752..2a9bf2b8 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala @@ -1,19 +1,17 @@ package org.ergoplatform.appkit -import java.util - -import org.ergoplatform.appkit.BoxOperations.{createProver} +import org.ergoplatform.appkit.BoxOperations.createProver import org.ergoplatform.appkit.Parameters.MinFee -import org.ergoplatform.appkit.impl.ErgoTreeContract import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.eval._ import sigmastate.helpers.NegativeTesting import sigmastate.interpreter.CryptoConstants import special.sigma.GroupElement -class AnonymousAccessSpec extends PropSpec with Matchers +class AnonymousAccessSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala index fd9748da..92bf5462 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala @@ -4,13 +4,14 @@ import org.ergoplatform.appkit.examples.ExampleScenarios import org.ergoplatform.appkit.testing.AppkitTesting import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.ValidationRules -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.Values.SigmaPropConstant import sigmastate.serialization.ErgoTreeSerializer class ApiClientSpec - extends PropSpec + extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala index 5a8b75ad..e97ae62f 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala @@ -4,8 +4,9 @@ import org.ergoplatform.appkit.JavaHelpers._ import org.ergoplatform.{ErgoScriptPredef, ErgoBox, UnsignedErgoLikeTransaction} import org.ergoplatform.appkit.impl.{BlockchainContextImpl, InputBoxImpl, UnsignedTransactionBuilderImpl, UnsignedTransactionImpl} import org.ergoplatform.settings.ErgoAlgos +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import sigmastate.helpers.NegativeTesting -import org.scalatest.{Matchers, PropSpec} import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.TestsBase import sigmastate.eval.Colls @@ -15,7 +16,7 @@ import java.util import java.util.Collections import util.{List => JList} -class AppkitProvingInterpreterSpec extends PropSpec +class AppkitProvingInterpreterSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTestingCommon diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/BabelFeeSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/BabelFeeSpec.scala index 4e54240e..9753278f 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/BabelFeeSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/BabelFeeSpec.scala @@ -1,13 +1,14 @@ package org.ergoplatform.appkit -import org.ergoplatform.appkit.babelfee.{BabelFeeBoxContract, BabelFeeBoxState, BabelFeeOperations} -import org.scalatest.{Matchers, PropSpec} +import org.ergoplatform.appkit.babelfee.{BabelFeeOperations, BabelFeeBoxContract, BabelFeeBoxState} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import java.util import java.util.Arrays -class BabelFeeSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class BabelFeeSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with HttpClientTesting with AppkitTestingCommon { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/Bip32SerializationSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/Bip32SerializationSpec.scala index 381e3d21..66722f94 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/Bip32SerializationSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/Bip32SerializationSpec.scala @@ -1,11 +1,11 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.testing.AppkitTesting -import org.ergoplatform.wallet.secrets.{ExtendedPublicKey, ExtendedSecretKey} -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -class Bip32SerializationSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class Bip32SerializationSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting { property("Serialization roundtrip") { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/BoxAttachmentSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/BoxAttachmentSpec.scala index 3bc19683..ecc7a13c 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/BoxAttachmentSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/BoxAttachmentSpec.scala @@ -2,12 +2,12 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.impl.BoxAttachmentBuilder import org.junit.Assert -import org.scalatest.Matchers.{be, convertToAnyShouldWrapper} -import org.scalatest.PropSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import java.util.Collections -class BoxAttachmentSpec extends PropSpec { +class BoxAttachmentSpec extends AnyPropSpec with Matchers { private val textAttachmentContent = "Your loan January" diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala index 2d5c2fd5..4d72985b 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala @@ -1,17 +1,18 @@ package org.ergoplatform.appkit -import org.scalatest.{PropSpec, Matchers} import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.eval._ import sigmastate.interpreter.CryptoConstants import special.sigma.GroupElement import JavaHelpers._ -import java.util.{Arrays, List => JList} +import java.util.{Arrays, List => JList} import org.ergoplatform.appkit.Parameters.MinFee import org.ergoplatform.appkit.testing.AppkitTesting +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec -class ChangeOutputSpec extends PropSpec with Matchers +class ChangeOutputSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala index 9bbe08dc..69b44528 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala @@ -1,13 +1,14 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.eval._ import sigmastate.interpreter.CryptoConstants import special.sigma.GroupElement -class DHTProverSpec extends PropSpec with Matchers +class DHTProverSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ErgoAuthSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/ErgoAuthSpec.scala index c561569a..48f29cad 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ErgoAuthSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ErgoAuthSpec.scala @@ -1,13 +1,14 @@ package org.ergoplatform.appkit -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import scorex.util.Random import sigmastate.interpreter.HintsBag import java.nio.charset.StandardCharsets -class ErgoAuthSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class ErgoAuthSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTestingCommon { property("ErgoAuth address round trip") { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala b/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala index 7f783a77..e9d6d5e1 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala @@ -1,7 +1,9 @@ package org.ergoplatform.appkit -import scalan.util.FileUtil +import scalan.util.{FileUtil => SFileUtil} import JavaHelpers._ +import org.ergoplatform.appkit + import java.util.{List => JList} import java.lang.{String => JString} @@ -10,11 +12,11 @@ trait HttpClientTesting { val addr1 = "9f4QF8AD1nQ3nJahQVkMj8hFSVVzVom77b52JU7EW71Zexg6N8v" def loadNodeResponse(name: String) = { - FileUtil.read(FileUtil.file(s"$responsesDir/node_responses/$name")) + appkit.FileUtil.read(SFileUtil.file(s"$responsesDir/node_responses/$name")) } def loadExplorerResponse(name: String) = { - FileUtil.read(FileUtil.file(s"$responsesDir/explorer_responses/$name")) + appkit.FileUtil.read(SFileUtil.file(s"$responsesDir/explorer_responses/$name")) } case class MockData(nodeResponses: Seq[String] = Nil, explorerResponses: Seq[String] = Nil) { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala index 96bdf868..c1bc912d 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala @@ -2,14 +2,15 @@ package org.ergoplatform.appkit import org.ergoplatform.ErgoBox import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{PropSpec, Matchers} import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.Values.{ByteArrayConstant, EvaluatedValue, IntConstant} +import sigmastate.Values.{EvaluatedValue, ByteArrayConstant, IntConstant} import sigmastate.{SType, TrivialProp} import sigmastate.helpers.TestingHelpers._ import org.ergoplatform.wallet.mnemonic.{Mnemonic => WMnemonic} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec -class JavaHelpersSpec extends PropSpec with Matchers +class JavaHelpersSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting { import ErgoBox._ diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/MnemonicSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/MnemonicSpec.scala index 7844f976..03903163 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/MnemonicSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/MnemonicSpec.scala @@ -1,15 +1,15 @@ package org.ergoplatform.appkit import java.util - import org.ergoplatform.appkit.Mnemonic._ -import org.ergoplatform.appkit.MnemonicValidationException.{MnemonicChecksumException, MnemonicEmptyException, MnemonicWordException, MnemonicWrongListSizeException} +import org.ergoplatform.appkit.MnemonicValidationException.{MnemonicWrongListSizeException, MnemonicChecksumException, MnemonicWordException, MnemonicEmptyException} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{Matchers, PropSpec} import scala.collection.JavaConverters._ -class MnemonicSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks { +class MnemonicSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks { val testMnemonic = "walnut endorse maid alone fuel jump torch company ahead nice abstract earth pig spice reduce" val testEntropy: Array[Byte] = Array[Byte](-10, -55, 58, 24, 3, 117, -34, -15, -7, 81, 116, 5, 50, -84, 3, -94, -70, 73, -93, 45) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala index ac8eed2d..50496266 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala @@ -1,7 +1,8 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.eval._ import sigmastate.interpreter.CryptoConstants @@ -9,7 +10,7 @@ import special.sigma.GroupElement import scala.util.Try -class MultiProveDHTSpec extends PropSpec with Matchers +class MultiProveDHTSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala index 6231c2ef..551c4777 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala @@ -1,7 +1,8 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.eval._ import sigmastate.interpreter.CryptoConstants @@ -9,7 +10,7 @@ import special.sigma.GroupElement import scala.util.Try -class MultiProveDlogSpec extends PropSpec with Matchers +class MultiProveDlogSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala index 48fc868c..0e08d7a6 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala @@ -2,16 +2,17 @@ package org.ergoplatform.appkit import com.google.gson.Gson import com.google.gson.reflect.TypeToken -import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughCoinsForChangeException, NotEnoughErgsException} +import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughErgsException, NotEnoughCoinsForChangeException} import org.ergoplatform.appkit.JavaHelpers._ import org.ergoplatform.appkit.impl.{Eip4TokenBuilder, ErgoTreeContract} import org.ergoplatform.appkit.testing.AppkitTesting import org.ergoplatform.explorer.client.model.{Items, TokenInfo} -import org.ergoplatform.{ErgoBox, ErgoScriptPredef} +import org.ergoplatform.{ErgoScriptPredef, ErgoBox, appkit} import org.scalacheck.Gen -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import scalan.util.FileUtil +import scalan.util.{FileUtil => SFileUtil} import scorex.util.ModifierId import sigmastate.eval.CBigInt import sigmastate.helpers.NegativeTesting @@ -23,7 +24,7 @@ import java.util import java.util.Arrays import java.util.function.Consumer -class TxBuilderSpec extends PropSpec with Matchers +class TxBuilderSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting @@ -461,7 +462,7 @@ class TxBuilderSpec extends PropSpec with Matchers property("Test changebox token amount max 100") { val ergoClient = createMockedErgoClient(data) - val tokenList: Items[TokenInfo] = new Gson().fromJson(FileUtil.read(FileUtil.file(s"appkit/src/test/resources/tokens.json")), new TypeToken[Items[TokenInfo]]() {}.getType) + val tokenList: Items[TokenInfo] = new Gson().fromJson(appkit.FileUtil.read(SFileUtil.file(s"appkit/src/test/resources/tokens.json")), new TypeToken[Items[TokenInfo]]() {}.getType) ergoClient.execute { ctx: BlockchainContext => val (storage, _) = loadStorageE2() diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CliApplicationSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CliApplicationSpec.scala index c342b5f7..88c78979 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CliApplicationSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CliApplicationSpec.scala @@ -1,16 +1,13 @@ package org.ergoplatform.appkit.cli -import org.ergoplatform.appkit.FileMockedErgoClient import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{PropSpec, Matchers} -import org.ergoplatform.appkit.JavaHelpers._ -import java.lang.{String => JString} -import java.util.{List => JList} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec object TestCliApplication extends CliApplication class CliApplicationSpec - extends PropSpec + extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with ConsoleTesting diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CmdLineParserSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CmdLineParserSpec.scala index dd5fdbba..c6e6027c 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CmdLineParserSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CmdLineParserSpec.scala @@ -1,10 +1,11 @@ package org.ergoplatform.appkit.cli import org.ergoplatform.appkit.commands.UsageException -import org.scalatest.{PropSpec, Matchers} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -class CmdLineParserSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks { +class CmdLineParserSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks { import CmdLineParser._ property("parseOptions") { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala index 78bb2fee..557255ce 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala @@ -1,22 +1,23 @@ package org.ergoplatform.appkit.cli -import scalan.util.FileUtil +import org.ergoplatform.appkit +import scalan.util.{FileUtil => SFileUtil} import org.ergoplatform.appkit.JavaHelpers._ + import java.util.{List => JList} import java.lang.{String => JString} - -import org.scalatest.Matchers -import org.ergoplatform.appkit.{FileMockedErgoClient, BlockchainContext} +import org.ergoplatform.appkit.FileMockedErgoClient +import org.scalatest.matchers.should.Matchers trait CommandsTesting extends ConsoleTesting { self: Matchers => def responsesDir: String def loadNodeResponse(name: String) = { - FileUtil.read(FileUtil.file(s"$responsesDir/node_responses/$name")) + appkit.FileUtil.read(SFileUtil.file(s"$responsesDir/node_responses/$name")) } def loadExplorerResponse(name: String) = { - FileUtil.read(FileUtil.file(s"$responsesDir/explorer_responses/$name")) + appkit.FileUtil.read(SFileUtil.file(s"$responsesDir/explorer_responses/$name")) } def testConfigFile: String diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTesting.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTesting.scala index 028ba3bc..c2d58212 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTesting.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTesting.scala @@ -1,8 +1,8 @@ package org.ergoplatform.appkit.cli -import java.io.{StringReader, ByteArrayOutputStream, BufferedReader, PrintStream} +import org.scalatest.matchers.should.Matchers -import org.scalatest.Matchers +import java.io.{PrintStream, StringReader, BufferedReader, ByteArrayOutputStream} trait ConsoleTesting { self: Matchers => diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTests.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTests.scala index e64ff13a..bea96fb9 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTests.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/ConsoleTests.scala @@ -1,11 +1,12 @@ package org.ergoplatform.appkit.cli -import java.io.{InputStreamReader, BufferedReader, PrintStream} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec +import java.io.{PrintStream, InputStreamReader, BufferedReader} import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{PropSpec, Matchers} -class ConsoleTests extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks with ConsoleTesting { +class ConsoleTests extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with ConsoleTesting { val scenario = ConsoleScenario(Seq( WriteRead("Enter line 1> ", "input line 1"), WriteRead("Enter line 2> ", "input line 2"), diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/examples/DataInputsSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/examples/DataInputsSpec.scala index 2163e28f..0ac8abbf 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/examples/DataInputsSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/examples/DataInputsSpec.scala @@ -1,10 +1,11 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.testing.AppkitTesting -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -class DataInputsSpec extends PropSpec with Matchers +class DataInputsSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTesting with HttpClientTesting { diff --git a/build.sbt b/build.sbt index f5a09161..685ff380 100644 --- a/build.sbt +++ b/build.sbt @@ -83,9 +83,10 @@ git.gitUncommittedChanges in ThisBuild := true val mockitoScalaVerstion = "1.11.4" lazy val testingDependencies = Seq( - "org.scalatest" %% "scalatest" % "3.0.8" % "test", - "org.scalactic" %% "scalactic" % "3.0.+" % "test", - "org.scalacheck" %% "scalacheck" % "1.14.+" % "test", + "org.scalatest" %% "scalatest" % "3.2.14" % "test", + "org.scalactic" %% "scalactic" % "3.2.14" % "test", + "org.scalacheck" %% "scalacheck" % "1.15.2" % "test", // last supporting Scala 2.11 + "org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % Test, // last supporting Scala 2.11 "com.lihaoyi" %% "pprint" % "0.6.3" % "test", // the last version with Scala 2.11 support (sigmaState % Test).classifier("tests") ) @@ -133,8 +134,8 @@ assemblyMergeStrategy in assembly := { lazy val allConfigDependency = "compile->compile;test->test" -val sigmaStateVersion = "5.0.5" -val ergoWalletVersion = "5.0.7" +val sigmaStateVersion = "5.0.7" +val ergoWalletVersion = "5.0.10" lazy val sigmaState = ("org.scorexfoundation" %% "sigma-state" % sigmaStateVersion).force() .exclude("ch.qos.logback", "logback-classic") .exclude("org.scorexfoundation", "scrypto") @@ -149,8 +150,9 @@ libraryDependencies ++= Seq( sigmaState, (sigmaState % Test).classifier("tests"), ergoWallet, - "org.scalatest" %% "scalatest" % "3.0.8" % "test", - "org.scalacheck" %% "scalacheck" % "1.14.+" % "test", + "org.scalatest" %% "scalatest" % "3.2.14" % "test", + "org.scalacheck" %% "scalacheck" % "1.15.2" % "test", // last supporting Scala 2.11 + "org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % Test, // last supporting Scala 2.11 "com.squareup.retrofit2" % "retrofit" % "2.6.2", "com.squareup.retrofit2" % "converter-scalars" % "2.6.2", "com.squareup.retrofit2" % "converter-gson" % "2.6.2" @@ -186,7 +188,9 @@ lazy val common = (project in file("common")) resolvers ++= allResolvers, libraryDependencies ++= Seq( sigmaState, - ergoWallet + ergoWallet, + "com.google.guava" % "guava" % "23.0", + "commons-io" % "commons-io" % "2.5" ), publish / skip := true ) diff --git a/common/src/main/java/org/ergoplatform/appkit/Address.java b/common/src/main/java/org/ergoplatform/appkit/Address.java index d269be8b..b45a7fde 100644 --- a/common/src/main/java/org/ergoplatform/appkit/Address.java +++ b/common/src/main/java/org/ergoplatform/appkit/Address.java @@ -19,6 +19,7 @@ import scorex.util.encode.Base58; import sigmastate.Values; import sigmastate.basics.DLogProtocol; +import sigmastate.crypto.Platform; import sigmastate.eval.CostingSigmaDslBuilder$; import sigmastate.serialization.ErgoTreeSerializer; import sigmastate.utils.Helpers; @@ -122,7 +123,7 @@ public ErgoAddress getErgoAddress() { * Extract public key from P2PKAddress and return its group element */ public GroupElement getPublicKeyGE() { - SecP256K1Point point = getPublicKey().value(); + Platform.Ecp point = getPublicKey().value(); return CostingSigmaDslBuilder$.MODULE$.GroupElement(point); } diff --git a/common/src/main/java/org/ergoplatform/appkit/AppkitProvingInterpreter.scala b/common/src/main/java/org/ergoplatform/appkit/AppkitProvingInterpreter.scala index 0a46a4c9..5403f897 100644 --- a/common/src/main/java/org/ergoplatform/appkit/AppkitProvingInterpreter.scala +++ b/common/src/main/java/org/ergoplatform/appkit/AppkitProvingInterpreter.scala @@ -17,7 +17,7 @@ import org.ergoplatform.wallet.protocol.context.{ErgoLikeStateContext, ErgoLikeP import sigmastate.Values.{SigmaBoolean, ErgoTree} import scala.util.Try -import sigmastate.interpreter.Interpreter.{ReductionResult, JitReductionResult, ScriptEnv, FullReductionResult, estimateCryptoVerifyCost} +import sigmastate.interpreter.Interpreter.{ReductionResult, ScriptEnv, estimateCryptoVerifyCost} import sigmastate.interpreter.{ProverResult, Interpreter, ContextExtension, ProverInterpreter, HintsBag} import sigmastate.lang.exceptions.CostLimitException import sigmastate.serialization.SigmaSerializer @@ -26,7 +26,6 @@ import sigmastate.utils.Helpers._ // for Scala 2.11 import sigmastate.utils.{SigmaByteWriter, SigmaByteReader} import scalan.util.Extensions.LongOps import sigmastate.VersionContext -import sigmastate.VersionContext.JitActivationVersion import scala.collection.mutable @@ -371,7 +370,7 @@ object ReducedErgoLikeTransactionSerializer extends SigmaSerializer[ReducedErgoL val cost = r.getULong() val input = tx.inputs(i) val extension = input.extension - val reductionResult = FullReductionResult(JitReductionResult(sb, cost)) + val reductionResult = ReductionResult(sb, cost) reducedInputs(i) = ReducedInputData(reductionResult, extension) unsignedInputs(i) = new UnsignedInput(input.boxId, extension) } diff --git a/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java b/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java index 687ce327..e3acdffa 100644 --- a/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java +++ b/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java @@ -11,6 +11,7 @@ import sigmastate.AvlTreeData; import sigmastate.SType; import sigmastate.Values; +import sigmastate.crypto.Platform; import sigmastate.serialization.ValueSerializer; import sigmastate.serialization.ValueSerializer$; import special.collection.Coll; @@ -103,7 +104,8 @@ static public ErgoValue of(BigInteger value) { } static public ErgoValue of(ECPoint value) { - return new ErgoValue<>(JavaHelpers.SigmaDsl().GroupElement(value), ErgoType.groupElementType()); + GroupElement ge = JavaHelpers.SigmaDsl().GroupElement(new Platform.Ecp(value)); + return new ErgoValue<>(ge, ErgoType.groupElementType()); } static public ErgoValue of(GroupElement ge) { diff --git a/common/src/main/java/org/ergoplatform/appkit/FileUtil.scala b/common/src/main/java/org/ergoplatform/appkit/FileUtil.scala new file mode 100644 index 00000000..22473689 --- /dev/null +++ b/common/src/main/java/org/ergoplatform/appkit/FileUtil.scala @@ -0,0 +1,10 @@ +package org.ergoplatform.appkit + +import org.apache.commons.io.FileUtils + +import java.io.File +import java.nio.charset.Charset + +object FileUtil { + def read(file: File): String = FileUtils.readFileToString(file, Charset.defaultCharset()) +} diff --git a/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala b/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala index e8b0558a..cd6c0374 100644 --- a/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala +++ b/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala @@ -3,7 +3,6 @@ package org.ergoplatform.appkit import org.ergoplatform.wallet.secrets.{ExtendedSecretKey, DerivationPath} import scalan.RType import special.collection.Coll -import com.google.common.base.{Preconditions, Strings} import scala.collection.{mutable, JavaConverters} import scala.collection.compat.immutable.ArraySeq @@ -43,6 +42,7 @@ import org.bouncycastle.crypto.params.KeyParameter import org.ergoplatform.appkit.JavaHelpers.{TokenIdRType, TokenColl} import org.ergoplatform.appkit.scalaapi.Extensions.{PairCollOps, CollBuilderOps} import org.ergoplatform.appkit.scalaapi.Utils +import scalan.util.StringUtil._ import scalan.ExactIntegral.LongIsExactIntegral import sigmastate.eval.CostingSigmaDslBuilder.validationSettings import sigmastate.interpreter.Interpreter.ScriptEnv @@ -216,7 +216,7 @@ object Iso extends LowPriorityIsos { } implicit val jstringToOptionString: Iso[JString, Option[String]] = new Iso[JString, Option[String]] { - override def to(a: JString): Option[String] = if (Strings.isNullOrEmpty(a)) None else Some(a) + override def to(a: JString): Option[String] = if (a.isNullOrEmpty) None else Some(a) override def from(b: Option[String]): JString = if (b.isEmpty) "" else b.get } @@ -442,8 +442,8 @@ object JavaHelpers { registers: Seq[ErgoValue[_]], creationHeight: Int): ErgoBoxCandidate = { import ErgoBox.nonMandatoryRegisters val nRegs = registers.length - Preconditions.checkArgument(nRegs <= nonMandatoryRegisters.length, - "Too many additional registers %d. Max allowed %d", nRegs, nonMandatoryRegisters.length) + require(nRegs <= nonMandatoryRegisters.length, + s"Too many additional registers $nRegs. Max allowed ${nonMandatoryRegisters.length}") implicit val TokenIdRType: RType[TokenId] = RType.arrayRType[Byte].asInstanceOf[RType[TokenId]] val ts = Colls.fromItems(tokens.map(isoErgoTokenToPair.to(_)):_*) val rs = registers.zipWithIndex.map { case (ergoValue, i) => diff --git a/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala index 086ee417..a53fc8c3 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala @@ -2,24 +2,25 @@ package org.ergoplatform.appkit import org.ergoplatform.UnsignedErgoLikeTransaction import org.scalacheck.Gen -import org.scalatest.{Assertion, Matchers} +import org.scalatest.Assertion +import org.scalatest.matchers.should.Matchers import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.CrossVersionProps import sigmastate.interpreter.ContextExtension -import sigmastate.interpreter.Interpreter.{JitReductionResult, FullReductionResult} import sigmastate.serialization.SigmaSerializer import sigmastate.serialization.generators.ObjectGenerators +import sigmastate.interpreter.Interpreter.ReductionResult class ReducedErgoLikeTransactionSpec extends CrossVersionProps with Matchers with ScalaCheckDrivenPropertyChecks with ObjectGenerators { - val printDebugInfo: Boolean = false + override val printDebugInfo: Boolean = false def reducedInputDataGen(extension: ContextExtension): Gen[ReducedInputData] = for { sb <- sigmaBooleanGen cost <- Gen.choose(10L, 1000L) } yield - ReducedInputData(FullReductionResult(JitReductionResult(sb, cost)), extension) + ReducedInputData(ReductionResult(sb, cost), extension) def reducedErgoLikeTransactionGen( unsignedTx: UnsignedErgoLikeTransaction): Gen[ReducedErgoLikeTransaction] = { diff --git a/common/src/test/scala/org/ergoplatform/appkit/SecretStorageSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/SecretStorageSpec.scala index f0c8a24d..901de56b 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/SecretStorageSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/SecretStorageSpec.scala @@ -2,10 +2,11 @@ package org.ergoplatform.appkit import java.io.File import com.google.common.io.Files -import org.scalatest.{PropSpec, Matchers} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -class SecretStorageSpec extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class SecretStorageSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with AppkitTestingCommon { val mnemonicWithPassword = Mnemonic.create("phrase".toCharArray, "mnemonic pass".toCharArray) val encryptionPass = "encryption pass" diff --git a/common/src/test/scala/org/ergoplatform/appkit/TestingBase.scala b/common/src/test/scala/org/ergoplatform/appkit/TestingBase.scala index 6de0a13f..5108bc24 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/TestingBase.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/TestingBase.scala @@ -1,6 +1,7 @@ package org.ergoplatform.appkit +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{Matchers, PropSpec} -trait TestingBase extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +trait TestingBase extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks diff --git a/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala b/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala index 5cd07e73..39ca64c9 100644 --- a/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala +++ b/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala @@ -2,8 +2,9 @@ package org.ergoplatform.appkit.impl import org.ergoplatform.appkit.impl.ScalaBridge.isoSpendingProof import org.ergoplatform.restapi.client.SpendingProof +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.scalatest.{Matchers, PropSpec} import sigmastate.Values.{ByteArrayConstant, IntConstant} import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.generators.ObjectGenerators @@ -11,7 +12,7 @@ import sigmastate.serialization.generators.ObjectGenerators import scala.collection.JavaConverters import JavaConverters._ -class ScalaBridgeTest extends PropSpec with Matchers with ScalaCheckDrivenPropertyChecks +class ScalaBridgeTest extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks with ObjectGenerators { property("isoSpendingProof") { val fakeProof = Array[Byte](0, 1, 2)