diff --git a/.github/workflows/Linux_2.12_App_Chain_Node_Core_Tests.yml b/.github/workflows/Linux_2.12_App_Chain_Node_Core_Tests.yml index ccf83cf8ba..b8b5df28db 100644 --- a/.github/workflows/Linux_2.12_App_Chain_Node_Core_Tests.yml +++ b/.github/workflows/Linux_2.12_App_Chain_Node_Core_Tests.yml @@ -23,4 +23,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.12.12 downloadBitcoind coverage chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls cryptoJVM/test cryptoTest/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTest/test core/coverageReport core/coverageAggregate core/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test + run: sbt ++2.12.12 downloadBitcoind coverage chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls cryptoJVM/test cryptoTestJVM/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTestJVM/test coreJVM/coverageReport coreJVM/coverageAggregate coreJVM/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test diff --git a/.github/workflows/Linux_2.12_KeyManager_Wallet_DLC_Tests.yml b/.github/workflows/Linux_2.12_KeyManager_Wallet_DLC_Tests.yml index db629708d3..d390197102 100644 --- a/.github/workflows/Linux_2.12_KeyManager_Wallet_DLC_Tests.yml +++ b/.github/workflows/Linux_2.12_KeyManager_Wallet_DLC_Tests.yml @@ -23,4 +23,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.12.12 downloadBitcoind coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtils/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls + run: sbt ++2.12.12 downloadBitcoind coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtilsJVM/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls diff --git a/.github/workflows/Linux_2.13_App_Chain_Node_Core_Tests.yml b/.github/workflows/Linux_2.13_App_Chain_Node_Core_Tests.yml index 27774caef4..5dd6de93d9 100644 --- a/.github/workflows/Linux_2.13_App_Chain_Node_Core_Tests.yml +++ b/.github/workflows/Linux_2.13_App_Chain_Node_Core_Tests.yml @@ -23,4 +23,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.13.5 downloadBitcoind coverage chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls cryptoTest/test cryptoJVM/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTest/test core/coverageReport core/coverageAggregate core/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test + run: sbt ++2.13.5 downloadBitcoind coverage chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls cryptoTestJVM/test cryptoJVM/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTestJVM/test coreJVM/coverageReport coreJVM/coverageAggregate coreJVM/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test diff --git a/.github/workflows/Linux_2.13_KeyManager_Wallet_DLC_Tests.yml b/.github/workflows/Linux_2.13_KeyManager_Wallet_DLC_Tests.yml index b018316d8f..96e6843b9d 100644 --- a/.github/workflows/Linux_2.13_KeyManager_Wallet_DLC_Tests.yml +++ b/.github/workflows/Linux_2.13_KeyManager_Wallet_DLC_Tests.yml @@ -23,4 +23,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.13.5 downloadBitcoind coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtils/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls + run: sbt ++2.13.5 downloadBitcoind coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtilsJVM/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls diff --git a/.github/workflows/Mac_2.13_RPC_Tests.yml b/.github/workflows/Mac_2.13_RPC_Tests.yml index b1e9db325c..f66fc62f9d 100644 --- a/.github/workflows/Mac_2.13_RPC_Tests.yml +++ b/.github/workflows/Mac_2.13_RPC_Tests.yml @@ -25,4 +25,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.13.5 downloadBitcoind downloadEclair coverage cryptoTest/test coreTest/test appCommonsTest/test bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls + run: sbt ++2.13.5 downloadBitcoind downloadEclair coverage cryptoTestJVM/test coreTestJVM/test appCommonsTest/test bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls diff --git a/.github/workflows/Mac_2.13_Wallet_Node_DLC_Tests.yml b/.github/workflows/Mac_2.13_Wallet_Node_DLC_Tests.yml index dd9daec8d8..8a901af232 100644 --- a/.github/workflows/Mac_2.13_Wallet_Node_DLC_Tests.yml +++ b/.github/workflows/Mac_2.13_Wallet_Node_DLC_Tests.yml @@ -23,4 +23,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.13.5 downloadBitcoind coverage walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcOracleTest/test asyncUtils/test dlcOracle/coverageReport dlcOracle/coveralls \ No newline at end of file + run: sbt ++2.13.5 downloadBitcoind coverage walletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcOracleTest/test asyncUtilsJVM/test dlcOracle/coverageReport dlcOracle/coveralls \ No newline at end of file diff --git a/.github/workflows/Secp_Disabled_Tests.yml b/.github/workflows/Secp_Disabled_Tests.yml index 2e3c15896e..3523f84631 100644 --- a/.github/workflows/Secp_Disabled_Tests.yml +++ b/.github/workflows/Secp_Disabled_Tests.yml @@ -25,4 +25,4 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: run tests - run: sbt ++2.13.5 cryptoTest/test coreTest/test + run: sbt ++2.13.5 cryptoTestJVM/test coreTestJVM/test diff --git a/.github/workflows/Windows.yml b/.github/workflows/Windows.yml index ea41d435d6..021ff07674 100644 --- a/.github/workflows/Windows.yml +++ b/.github/workflows/Windows.yml @@ -26,5 +26,5 @@ jobs: ~/.bitcoin-s/binaries key: ${{ runner.os }}-cache - name: Windows Crypto, Core, and Database tests - run: sbt ++2.13.5 cryptoTest/test coreTest/test dbCommonsTest/test + run: sbt ++2.13.5 cryptoTestJVM/test coreTestJVM/test dbCommonsTest/test shell: bash diff --git a/bitcoind-rpc/bitcoind-rpc.sbt b/bitcoind-rpc/bitcoind-rpc.sbt index 62a4ac2c93..95421ee768 100644 --- a/bitcoind-rpc/bitcoind-rpc.sbt +++ b/bitcoind-rpc/bitcoind-rpc.sbt @@ -8,8 +8,6 @@ name := "bitcoin-s-bitcoind-rpc" libraryDependencies ++= Deps.bitcoindRpc -dependsOn(Projects.core) - CommonSettings.prodSettings TaskKeys.downloadBitcoind := { diff --git a/build.sbt b/build.sbt index 9419fe39e1..504444c664 100644 --- a/build.sbt +++ b/build.sbt @@ -37,7 +37,7 @@ lazy val commonJsSettings = { scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }, - sbt.Keys.publish / skip := true + skip.in(publish) := true ) ++ CommonSettings.settings ++ //get rid of -Xfatal-warnings for now with scalajs //this will just give us a bunch of warnings rather than errors @@ -63,22 +63,54 @@ lazy val cryptoJS = crypto.js lazy val cryptoJVM = crypto.jvm.dependsOn(secp256k1jni) -lazy val core = project - .in(file("core")) +lazy val core = crossProject(JVMPlatform, JSPlatform) + .crossType(CrossType.Pure) + .settings(name := "bitcoin-s-core") .settings(libraryDependencies ++= Deps.core.value) - .dependsOn(cryptoJVM) + .settings(CommonSettings.settings: _*) + .jvmSettings(CommonSettings.jvmSettings: _*) + .jsSettings(commonJsSettings: _*) + .in(file("core")) + .dependsOn(crypto) + +lazy val coreJVM = core.jvm + +lazy val coreJS = core.js + +lazy val asyncUtils = crossProject(JVMPlatform, JSPlatform) + .crossType(CrossType.Pure) + .in(file("async-utils")) + .settings(CommonSettings.prodSettings: _*) + .settings(name := "bitcoin-s-async-utils") + .jvmSettings(CommonSettings.jvmSettings: _*) + .jsSettings(commonJsSettings: _*) + .dependsOn(core) + +lazy val asyncUtilsJVM = asyncUtils.jvm + +lazy val testkitCore = crossProject(JVMPlatform, JSPlatform) + .crossType(CrossType.Pure) + .in(file("testkit-core")) + .settings(CommonSettings.prodSettings: _*) + .settings(name := "bitcoin-s-testkit-core", + libraryDependencies ++= Deps.testkitCore.value) + .jvmSettings(CommonSettings.jvmSettings: _*) + .jsSettings(commonJsSettings: _*) + .dependsOn(asyncUtils, core, crypto) + +lazy val testkitCoreJVM = testkitCore.jvm lazy val bitcoindRpc = project .in(file("bitcoind-rpc")) .settings(CommonSettings.prodSettings: _*) .dependsOn( - asyncUtils, + asyncUtilsJVM, appCommons ) lazy val eclairRpc = project .in(file("eclair-rpc")) - .dependsOn(asyncUtils, bitcoindRpc) + .dependsOn(asyncUtilsJVM, bitcoindRpc) val jsProjects: Vector[ProjectReference] = Vector(cryptoJS) @@ -87,17 +119,20 @@ val jsProjects: Vector[ProjectReference] = Vector(cryptoJS) lazy val `bitcoin-s` = project .in(file(".")) .aggregate( - asyncUtils, + asyncUtilsJVM, secp256k1jni, chain, chainTest, cli, cliTest, - core, - coreTest, + coreJVM, + coreJS, + coreTestJVM, + coreTestJS, cryptoJVM, cryptoJS, - cryptoTest, + cryptoTestJVM, + cryptoTestJS, dbCommons, dbCommonsTest, feeProvider, @@ -121,7 +156,7 @@ lazy val `bitcoin-s` = project appServerTest, appCommons, appCommonsTest, - testkitCore, + testkitCoreJVM, testkit, zmq, oracleServer, @@ -134,11 +169,14 @@ lazy val `bitcoin-s` = project chainTest, cli, cliTest, - core, - coreTest, + coreJVM, + coreJS, + coreTestJVM, + coreTestJS, cryptoJVM, cryptoJS, - cryptoTest, + cryptoTestJVM, + cryptoTestJS, dbCommons, dbCommonsTest, feeProvider, @@ -296,41 +334,49 @@ lazy val secp256k1jni = project */ val testAndCompile = "compile->compile;test->test" -lazy val cryptoTest = project +lazy val cryptoTest = crossProject(JVMPlatform, JSPlatform) + .crossType(CrossType.Pure) .in(file("crypto-test")) .settings(CommonSettings.testSettings: _*) + .jvmSettings(CommonSettings.jvmSettings: _*) + .jsSettings(commonJsSettings: _*) .settings( name := "bitcoin-s-crypto-test", libraryDependencies ++= Deps.cryptoTest.value ) .dependsOn( - cryptoJVM % testAndCompile, + crypto, testkitCore ) -lazy val coreTest = project +lazy val cryptoTestJVM = cryptoTest.jvm + +lazy val cryptoTestJS = cryptoTest.js + +lazy val coreTest = crossProject(JVMPlatform, JSPlatform) + .crossType(CrossType.Pure) .in(file("core-test")) .settings(CommonSettings.testSettings: _*) .settings( name := "bitcoin-s-core-test", libraryDependencies ++= Deps.coreTest.value ) + .jvmSettings(CommonSettings.jvmSettings: _*) + .jsSettings(commonJsSettings: _*) .dependsOn( - core % testAndCompile, + core, testkitCore ) -lazy val asyncUtils = project - .in(file("async-utils")) - .settings(CommonSettings.prodSettings) - .settings(name := "bitcoin-s-async-utils") - .dependsOn(core) +lazy val coreTestJVM = coreTest.jvm + +lazy val coreTestJS = coreTest.js lazy val appCommons = project .in(file("app-commons")) .settings(CommonSettings.prodSettings: _*) .dependsOn( - core % testAndCompile + coreJVM % testAndCompile ) lazy val appCommonsTest = project @@ -429,7 +475,7 @@ lazy val chain = project name := "bitcoin-s-chain", libraryDependencies ++= Deps.chain ) - .dependsOn(core, dbCommons) + .dependsOn(coreJVM, dbCommons) .enablePlugins(FlywayPlugin) lazy val chainTest = project @@ -440,7 +486,7 @@ lazy val chainTest = project name := "bitcoin-s-chain-test", libraryDependencies ++= Deps.chainTest ) - .dependsOn(chain, core % testAndCompile, testkit, zmq) + .dependsOn(chain, coreJVM % testAndCompile, testkit, zmq) .enablePlugins(FlywayPlugin) lazy val dbCommons = project @@ -450,7 +496,7 @@ lazy val dbCommons = project name := "bitcoin-s-db-commons", libraryDependencies ++= Deps.dbCommons.value ) - .dependsOn(core, appCommons) + .dependsOn(coreJVM, appCommons) lazy val dbCommonsTest = project .in(file("db-commons-test")) @@ -467,7 +513,7 @@ lazy val feeProvider = project name := "bitcoin-s-fee-provider", libraryDependencies ++= Deps.feeProvider.value ) - .dependsOn(core, appCommons) + .dependsOn(coreJVM, appCommons) lazy val feeProviderTest = project .in(file("fee-provider-test")) @@ -476,7 +522,7 @@ lazy val feeProviderTest = project name := "bitcoin-s-fee-provider-test", libraryDependencies ++= Deps.feeProviderTest.value ) - .dependsOn(core, core % testAndCompile, testkit) + .dependsOn(coreJVM % testAndCompile, testkit) lazy val zmq = project .in(file("zmq")) @@ -484,7 +530,7 @@ lazy val zmq = project .settings(name := "bitcoin-s-zmq", libraryDependencies ++= Deps.bitcoindZmq.value) .dependsOn( - core % testAndCompile + coreJVM % testAndCompile ) lazy val bitcoindRpcTest = project @@ -492,7 +538,7 @@ lazy val bitcoindRpcTest = project .settings(CommonSettings.testSettings: _*) .settings(name := "bitcoin-s-bitcoind-rpc-test", libraryDependencies ++= Deps.bitcoindRpcTest.value) - .dependsOn(core % testAndCompile, testkit) + .dependsOn(coreJVM % testAndCompile, testkit) lazy val bench = project .in(file("bench")) @@ -502,7 +548,7 @@ lazy val bench = project name := "bitcoin-s-bench", skip in publish := true ) - .dependsOn(core % testAndCompile, testkit) + .dependsOn(coreJVM % testAndCompile, testkit) lazy val eclairRpcTest = project .in(file("eclair-rpc-test")) @@ -511,7 +557,7 @@ lazy val eclairRpcTest = project libraryDependencies ++= Deps.eclairRpcTest.value, name := "bitcoin-s-eclair-rpc-test" ) - .dependsOn(core % testAndCompile, testkit) + .dependsOn(coreJVM % testAndCompile, testkit) lazy val nodeDbSettings = dbFlywaySettings("nodedb") @@ -525,8 +571,8 @@ lazy val node = libraryDependencies ++= Deps.node ) .dependsOn( - asyncUtils, - core, + asyncUtilsJVM, + coreJVM, chain, dbCommons, bitcoindRpc @@ -550,19 +596,12 @@ lazy val nodeTest = libraryDependencies ++= Deps.nodeTest.value ) .dependsOn( - core % testAndCompile, + coreJVM % testAndCompile, node, testkit ) .enablePlugins(FlywayPlugin) -lazy val testkitCore = project - .in(file("testkit-core")) - .settings(CommonSettings.prodSettings: _*) - .settings(name := "bitcoin-s-testkit-core", - libraryDependencies ++= Deps.testkitCore.value) - .dependsOn(asyncUtils, core % testAndCompile, cryptoJVM) - lazy val testkit = project .in(file("testkit")) .settings(CommonSettings.prodSettings: _*) @@ -571,8 +610,8 @@ lazy val testkit = project libraryDependencies ++= Deps.testkit.value ) .dependsOn( - asyncUtils, - core % testAndCompile, + asyncUtilsJVM, + coreJVM % testAndCompile, appServer, chain, bitcoindRpc, @@ -581,7 +620,7 @@ lazy val testkit = project wallet, zmq, dlcOracle, - testkitCore + testkitCoreJVM ) lazy val docs = project @@ -592,7 +631,7 @@ lazy val docs = project bitcoindRpc, chain, cli, - core, + coreJVM, eclairRpc, keyManager, secp256k1jni, @@ -604,7 +643,7 @@ lazy val docs = project lazy val keyManager = project .in(file("key-manager")) .settings(CommonSettings.prodSettings: _*) - .dependsOn(core, dbCommons) + .dependsOn(coreJVM, dbCommons) lazy val keyManagerTest = project .in(file("key-manager-test")) @@ -623,7 +662,7 @@ lazy val wallet = project name := "bitcoin-s-wallet", libraryDependencies ++= Deps.wallet(scalaVersion.value) ) - .dependsOn(core, appCommons, dbCommons, keyManager) + .dependsOn(coreJVM, appCommons, dbCommons, keyManager) .enablePlugins(FlywayPlugin) lazy val walletTest = project @@ -634,7 +673,7 @@ lazy val walletTest = project name := "bitcoin-s-wallet-test", libraryDependencies ++= Deps.walletTest ) - .dependsOn(core % testAndCompile, testkit, wallet) + .dependsOn(coreJVM % testAndCompile, testkit, wallet) .enablePlugins(FlywayPlugin) lazy val dlcOracle = project @@ -644,7 +683,7 @@ lazy val dlcOracle = project name := "bitcoin-s-dlc-oracle", libraryDependencies ++= Deps.dlcOracle ) - .dependsOn(core, keyManager, dbCommons) + .dependsOn(coreJVM, keyManager, dbCommons) lazy val dlcOracleTest = project .in(file("dlc-oracle-test")) @@ -653,7 +692,7 @@ lazy val dlcOracleTest = project name := "bitcoin-s-dlc-oracle-test", libraryDependencies ++= Deps.dlcOracleTest ) - .dependsOn(core % testAndCompile, dlcOracle, testkit) + .dependsOn(coreJVM % testAndCompile, dlcOracle, testkit) /** Given a database name, returns the appropriate * Flyway settings we apply to a project (chain, node, wallet) diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/words/EnglishWordsBip39Test.scala b/core-test/.jvm/src/main/scala/org/bitcoins/core/crypto/words/EnglishWordsBip39Test.scala similarity index 100% rename from core-test/src/test/scala/org/bitcoins/core/crypto/words/EnglishWordsBip39Test.scala rename to core-test/.jvm/src/main/scala/org/bitcoins/core/crypto/words/EnglishWordsBip39Test.scala diff --git a/core-test/src/test/resources/000000000000000000050f70113ab1932c195442cb49bcc4ee4d7f426c8a3295.txt b/core-test/.jvm/src/test/resources/000000000000000000050f70113ab1932c195442cb49bcc4ee4d7f426c8a3295.txt similarity index 100% rename from core-test/src/test/resources/000000000000000000050f70113ab1932c195442cb49bcc4ee4d7f426c8a3295.txt rename to core-test/.jvm/src/test/resources/000000000000000000050f70113ab1932c195442cb49bcc4ee4d7f426c8a3295.txt diff --git a/core-test/src/test/resources/00000000000000000008513c860373da0484f065983aeb063ebf81c172e81d48.txt b/core-test/.jvm/src/test/resources/00000000000000000008513c860373da0484f065983aeb063ebf81c172e81d48.txt similarity index 100% rename from core-test/src/test/resources/00000000000000000008513c860373da0484f065983aeb063ebf81c172e81d48.txt rename to core-test/.jvm/src/test/resources/00000000000000000008513c860373da0484f065983aeb063ebf81c172e81d48.txt diff --git a/core-test/src/test/resources/trezor.txt b/core-test/.jvm/src/test/resources/trezor.txt similarity index 100% rename from core-test/src/test/resources/trezor.txt rename to core-test/.jvm/src/test/resources/trezor.txt diff --git a/core/src/main/resources/bip39-wordlists/english.txt b/core/.jvm/src/main/resources/bip39-wordlists/english.txt similarity index 100% rename from core/src/main/resources/bip39-wordlists/english.txt rename to core/.jvm/src/main/resources/bip39-wordlists/english.txt diff --git a/core/core.sbt b/core/core.sbt index 815886b801..364a95128f 100644 --- a/core/core.sbt +++ b/core/core.sbt @@ -1,3 +1,5 @@ -name := "bitcoin-s-core" +//name := "bitcoin-s-core" -CommonSettings.prodSettings +//libraryDependencies ++= Deps.core + +//CommonSettings.prodSettings diff --git a/crypto-test/src/test/scala/org/bitcoins/crypto/BIP340Test.scala b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleBIP340Test.scala similarity index 98% rename from crypto-test/src/test/scala/org/bitcoins/crypto/BIP340Test.scala rename to crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleBIP340Test.scala index 92e76b5f26..bbbf16d1ad 100644 --- a/crypto-test/src/test/scala/org/bitcoins/crypto/BIP340Test.scala +++ b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleBIP340Test.scala @@ -7,7 +7,7 @@ import scodec.bits.ByteVector import scala.util.{Failure, Success, Try} /** Tests from https://github.com/sipa/bips/blob/bip-taproot/bip-0340/test-vectors.csv */ -class BIP340Test extends BitcoinSUnitTest { +class BouncyCastleBIP340Test extends BitcoinSUnitTest { behavior of "Schnorr Signing" def testSign( diff --git a/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleECDigitalSignatureTest.scala b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleECDigitalSignatureTest.scala new file mode 100644 index 0000000000..14c6619cc2 --- /dev/null +++ b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleECDigitalSignatureTest.scala @@ -0,0 +1,19 @@ +package org.bitcoins.crypto + +import org.bitcoins.testkitcore.gen.CryptoGenerators +import org.bitcoins.testkitcore.util.BitcoinSUnitTest + +class BouncyCastleECDigitalSignatureTest extends BitcoinSUnitTest { + + behavior of "BouncyCastleECDigitalSignatureTest" + + it must "be able to generate valid signatures with bouncy castle" in { + forAll(CryptoGenerators.privateKey, CryptoGenerators.sha256Digest) { + case (privKey: ECPrivateKey, hash: Sha256Digest) => + val sig = BouncycastleCryptoRuntime.sign(privKey, hash.bytes) + val pubKey = privKey.publicKey + + assert(pubKey.verify(hash, sig)) + } + } +} diff --git a/crypto-test/src/test/scala/org/bitcoins/crypto/BouncyCastleSecp256k1Test.scala b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleSecp256k1Test.scala similarity index 100% rename from crypto-test/src/test/scala/org/bitcoins/crypto/BouncyCastleSecp256k1Test.scala rename to crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/BouncyCastleSecp256k1Test.scala diff --git a/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/JvmECPublicKeyTest.scala b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/JvmECPublicKeyTest.scala new file mode 100644 index 0000000000..c2a8cfe7ba --- /dev/null +++ b/crypto-test/.jvm/src/test/scala/org/bitcoins/crypto/JvmECPublicKeyTest.scala @@ -0,0 +1,22 @@ +package org.bitcoins.crypto + +import org.bitcoins.testkitcore.gen.CryptoGenerators +import org.bitcoins.testkitcore.util.BitcoinSUnitTest + +/** Public key tests specific to the JVM */ +class JvmECPublicKeyTest extends BitcoinSUnitTest { + + behavior of "JVMECPublicKeytest" + + it must "have serialization symmetry from ECPublicKey -> ECPoint -> ECPublicKey" in { + CryptoContext.cryptoRuntime match { + case _: BouncycastleCryptoRuntime | _: LibSecp256k1CryptoRuntime => + forAll(CryptoGenerators.publicKey) { pubKey => + val p = BouncyCastleUtil.decodePoint(pubKey) + val pub2 = BouncyCastleUtil.decodePubKey(p, pubKey.isCompressed) + assert(pubKey == pub2) + } + case _ => succeed + } + } +} diff --git a/crypto-test/src/test/scala/org/bitcoins/crypto/ECDigitalSignatureTest.scala b/crypto-test/src/test/scala/org/bitcoins/crypto/ECDigitalSignatureTest.scala index 89a8e39533..4d0db069f2 100644 --- a/crypto-test/src/test/scala/org/bitcoins/crypto/ECDigitalSignatureTest.scala +++ b/crypto-test/src/test/scala/org/bitcoins/crypto/ECDigitalSignatureTest.scala @@ -94,14 +94,4 @@ class ECDigitalSignatureTest extends BitcoinSUnitTest { } } - it must "be able to generate valid signatures with bouncy castle" in { - forAll(CryptoGenerators.privateKey, CryptoGenerators.sha256Digest) { - case (privKey: ECPrivateKey, hash: Sha256Digest) => - val sig = BouncycastleCryptoRuntime.sign(privKey, hash.bytes) - val pubKey = privKey.publicKey - - assert(pubKey.verify(hash, sig)) - } - } - } diff --git a/crypto-test/src/test/scala/org/bitcoins/crypto/ECPublicKeyTest.scala b/crypto-test/src/test/scala/org/bitcoins/crypto/ECPublicKeyTest.scala index 0315d4b954..861ce8fd8f 100644 --- a/crypto-test/src/test/scala/org/bitcoins/crypto/ECPublicKeyTest.scala +++ b/crypto-test/src/test/scala/org/bitcoins/crypto/ECPublicKeyTest.scala @@ -30,18 +30,6 @@ class ECPublicKeyTest extends BitcoinSUnitTest { assert(ECPublicKey() != ECPublicKey()) } - it must "have serialization symmetry from ECPublicKey -> ECPoint -> ECPublicKey" in { - CryptoContext.cryptoRuntime match { - case _: BouncycastleCryptoRuntime | _: LibSecp256k1CryptoRuntime => - forAll(CryptoGenerators.publicKey) { pubKey => - val p = BouncyCastleUtil.decodePoint(pubKey) - val pub2 = BouncyCastleUtil.decodePubKey(p, pubKey.isCompressed) - assert(pubKey == pub2) - } - case _ => succeed - } - } - it must "decompress keys correctly" in { forAll(CryptoGenerators.privateKey) { privKey => val pubKey = privKey.publicKey diff --git a/project/CommonSettings.scala b/project/CommonSettings.scala index fedf3cc1ab..a97a3e257f 100644 --- a/project/CommonSettings.scala +++ b/project/CommonSettings.scala @@ -38,8 +38,10 @@ object CommonSettings { url("https://twitter.com/Chris_Stewart_5") ) ), - scalacOptions in Compile := compilerOpts(scalaVersion = scalaVersion.value), - Test / scalacOptions := testCompilerOpts(scalaVersion = scalaVersion.value), + scalacOptions in Compile ++= compilerOpts(scalaVersion = + scalaVersion.value), + Test / scalacOptions ++= testCompilerOpts(scalaVersion = + scalaVersion.value), //remove annoying import unused things in the scala console //https://stackoverflow.com/questions/26940253/in-sbt-how-do-you-override-scalacoptions-for-console-in-all-configurations scalacOptions in (Compile, console) ~= (_ filterNot (s => @@ -51,8 +53,8 @@ object CommonSettings { //we don't want -Xfatal-warnings for publishing with publish/publishLocal either scalacOptions in (Compile, doc) ~= (_ filterNot (s => s == "-Xfatal-warnings")), - scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value, - scalacOptions in Test := testCompilerOpts(scalaVersion.value), + scalacOptions in (Test, console) ++= (scalacOptions in (Compile, console)).value, + scalacOptions in Test ++= testCompilerOpts(scalaVersion.value), licenses += ("MIT", url("http://opensource.org/licenses/MIT")) ) @@ -148,7 +150,7 @@ object CommonSettings { //show full stack trace (-oF) of failed tests and duration of tests (-oD) testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"), logBuffered in Test := false, - publish / skip := true + skip.in(publish) := true ) ++ settings lazy val prodSettings: Seq[Setting[_]] = settings diff --git a/project/Deps.scala b/project/Deps.scala index e49f158c84..59f88d4344 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -34,6 +34,7 @@ object Deps { val akkaActorV = akkaStreamv val slickV = "3.3.3" val sqliteV = "3.34.0" + val scalameterV = "0.17" val scalamockV = "5.1.0" val scalaCollectionCompatV = "2.4.2" diff --git a/testkit-core/src/main/resources/logback-test.xml b/testkit-core/.jvm/src/main/resources/logback-test.xml similarity index 100% rename from testkit-core/src/main/resources/logback-test.xml rename to testkit-core/.jvm/src/main/resources/logback-test.xml