diff --git a/app-commons-test/src/test/scala/org/bitcoins/commons/SerializedPSBTTest.scala b/app-commons-test/src/test/scala/org/bitcoins/commons/SerializedPSBTTest.scala index 685d5dd3a1..f373aed5ae 100644 --- a/app-commons-test/src/test/scala/org/bitcoins/commons/SerializedPSBTTest.scala +++ b/app-commons-test/src/test/scala/org/bitcoins/commons/SerializedPSBTTest.scala @@ -5,7 +5,6 @@ import org.bitcoins.core.number.UInt32 import org.bitcoins.core.psbt.{GlobalPSBTRecord, OutputPSBTRecord, PSBT} import org.bitcoins.core.script.crypto.HashType import org.bitcoins.testkit.util.BitcoinSUnitTest -import play.api.libs.json.Json import scodec.bits._ class SerializedPSBTTest extends BitcoinSUnitTest { diff --git a/app/server-test/src/test/scala/org/bitcoins/server/BitcoindRpcAppConfigTest.scala b/app/server-test/src/test/scala/org/bitcoins/server/BitcoindRpcAppConfigTest.scala index d3ea2238cf..42e0bd4c33 100644 --- a/app/server-test/src/test/scala/org/bitcoins/server/BitcoindRpcAppConfigTest.scala +++ b/app/server-test/src/test/scala/org/bitcoins/server/BitcoindRpcAppConfigTest.scala @@ -18,6 +18,7 @@ class BitcoindRpcAppConfigTest extends BitcoinSAsyncTest { override def afterAll(): Unit = { super.afterAll() new Directory(tempDir.toFile).deleteRecursively() + () } it must "be overridable" in { diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/BitcoindInstanceTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/BitcoindInstanceTest.scala index 81b94be58c..c6908a3c42 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/BitcoindInstanceTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/BitcoindInstanceTest.scala @@ -25,7 +25,7 @@ class BitcoindInstanceTest extends BitcoindRpcTest { private val sampleConf: Seq[String] = { val source = Source.fromURL(getClass.getResource("/sample-bitcoin.conf")) - source.getLines.toSeq + source.getLines().toSeq } private val datadir: Path = Files.createTempDirectory(null) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/TestRpcUtilTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/TestRpcUtilTest.scala index 0da1b46751..2daf2921d0 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/TestRpcUtilTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/TestRpcUtilTest.scala @@ -18,11 +18,12 @@ class TestRpcUtilTest extends BitcoindRpcTest { private lazy val clientsF = BitcoindRpcTestUtil.createNodeTriple(clientAccum = clientAccum) - private def trueLater(delay: Int = 1000): Future[Boolean] = + private def trueLater(delay: Int): Future[Boolean] = { Future { Thread.sleep(delay) true } + } private def boolLaterDoneAnd( bool: Boolean, diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MempoolRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MempoolRpcTest.scala index a9bdcce9f0..cb83e3b8fe 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MempoolRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MempoolRpcTest.scala @@ -207,7 +207,7 @@ class MempoolRpcTest extends BitcoindRpcTest { (client, _) <- clientsF regTest = { val regTest = - new File(client.getDaemon.datadir + "/regtest") + new File(client.getDaemon.datadir.getAbsolutePath + "/regtest") assert(regTest.isDirectory) assert(!regTest.list().contains("mempool.dat")) regTest diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MultiWalletRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MultiWalletRpcTest.scala index ddf5c0d475..63d49aef99 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MultiWalletRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/MultiWalletRpcTest.scala @@ -95,11 +95,11 @@ class MultiWalletRpcTest extends BitcoindRpcTest { for { client <- walletClientF _ <- { - val datadir = client.getDaemon.datadir + val datadir = client.getDaemon.datadir.getAbsolutePath client.backupWallet(datadir + "/backup.dat", Some(walletName)) } } yield { - val datadir = client.getDaemon.datadir + val datadir = client.getDaemon.datadir.getAbsolutePath val file = new File(datadir + "/backup.dat") assert(file.exists) assert(file.isFile) @@ -288,8 +288,9 @@ class MultiWalletRpcTest extends BitcoindRpcTest { key <- client.dumpPrivKey(address, Some(walletName)) result <- client - .dumpWallet(client.getDaemon.datadir + "/wallet_dump.dat", - Some(walletName)) + .dumpWallet( + client.getDaemon.datadir.getAbsolutePath + "/wallet_dump.dat", + Some(walletName)) } yield { assert(key == ecPrivateKey) val reader = new Scanner(result.filename) @@ -350,7 +351,8 @@ class MultiWalletRpcTest extends BitcoindRpcTest { client <- walletClientF walletClient <- walletClientF address <- client.getNewAddress(Some(walletName)) - walletFile = client.getDaemon.datadir + "/client_wallet.dat" + walletFile = + client.getDaemon.datadir.getAbsolutePath + "/client_wallet.dat" fileResult <- client.dumpWallet(walletFile, walletNameOpt = Some(walletName)) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/NodeRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/NodeRpcTest.scala index 856a22b930..f4c739ada3 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/NodeRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/NodeRpcTest.scala @@ -26,6 +26,7 @@ class NodeRpcTest extends BitcoindRpcTest { recoverToSucceededIf[MiscError](client.rescanBlockChain()) system.scheduler.scheduleOnce(100.millis) { client.abortRescan() + () } rescanFailedF } diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/WalletRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/WalletRpcTest.scala index 0d62136834..5c254f37fe 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/WalletRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/common/WalletRpcTest.scala @@ -25,7 +25,9 @@ import org.bitcoins.testkit.util.BitcoindRpcTest import scala.async.Async.{async, await} import scala.concurrent.Future import scala.reflect.io.Directory +import scala.annotation.nowarn +@nowarn class WalletRpcTest extends BitcoindRpcTest { lazy val clientsF: Future[ @@ -62,7 +64,7 @@ class WalletRpcTest extends BitcoindRpcTest { for { (client, _, _) <- clientsF result <- { - val datadir = client.getDaemon.datadir + val datadir = client.getDaemon.datadir.getAbsolutePath client.dumpWallet(datadir + "/test.dat") } } yield { @@ -89,11 +91,11 @@ class WalletRpcTest extends BitcoindRpcTest { for { (client, _, _) <- clientsF _ <- { - val datadir = client.getDaemon.datadir + val datadir = client.getDaemon.datadir.getAbsolutePath client.backupWallet(datadir + "/backup.dat") } } yield { - val datadir = client.getDaemon.datadir + val datadir = client.getDaemon.datadir.getAbsolutePath val file = new File(datadir + "/backup.dat") assert(file.exists) assert(file.isFile) @@ -418,7 +420,8 @@ class WalletRpcTest extends BitcoindRpcTest { key <- client.dumpPrivKey(address) result <- client - .dumpWallet(client.getDaemon.datadir + "/wallet_dump.dat") + .dumpWallet( + client.getDaemon.datadir.getAbsolutePath + "/wallet_dump.dat") } yield { assert(key == ecPrivateKey) val reader = new Scanner(result.filename) @@ -476,7 +479,8 @@ class WalletRpcTest extends BitcoindRpcTest { (client, _, _) <- clientsF walletClient <- walletClientF address <- client.getNewAddress - walletFile = client.getDaemon.datadir + "/client_wallet.dat" + walletFile = + client.getDaemon.datadir.getAbsolutePath + "/client_wallet.dat" fileResult <- client.dumpWallet(walletFile) _ <- walletClient.walletPassphrase(password, 1000) @@ -492,7 +496,8 @@ class WalletRpcTest extends BitcoindRpcTest { for { (client, _, _) <- clientsF walletClient <- walletClientF - walletFile = client.getDaemon.datadir + s"/regtest/wallets/$name" + walletFile = + client.getDaemon.datadir.getAbsolutePath + s"/regtest/wallets/$name" _ <- client.createWallet(walletFile) _ <- client.unloadWallet(walletFile) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala index 34021e38eb..8693e116ff 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala @@ -1,10 +1,11 @@ package org.bitcoins.rpc.config -import org.bitcoins.testkit.util.{BitcoinSUnitTest, FileUtil} -import org.bitcoins.rpc.config.BitcoindAuthCredentials.CookieBased -import org.bitcoins.rpc.config.BitcoindAuthCredentials.PasswordBased import org.bitcoins.core.config.RegTest -import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil +import org.bitcoins.rpc.config.BitcoindAuthCredentials.{ + CookieBased, + PasswordBased +} +import org.bitcoins.testkit.util.{BitcoinSUnitTest, FileUtil} class BitcoindAuthCredentialsTest extends BitcoinSUnitTest { it must "handle cookie based auth" in { @@ -51,7 +52,7 @@ class BitcoindAuthCredentialsTest extends BitcoinSUnitTest { val conf = BitcoindConfig(confStr, FileUtil.tmpDir()) BitcoindAuthCredentials.fromConfig(conf) match { - case _: CookieBased => fail + case _: CookieBased => fail() case PasswordBased(username, password) => assert(username == "foo") assert(password == "bar") diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala index 79590b8a61..14f41450e3 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala @@ -34,7 +34,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { |rpcport=4000 """.stripMargin.split("\n") - val conf = BitcoindConfig(confStr, tmpDir) + val conf = BitcoindConfig(confStr.toIndexedSeq, tmpDir) assert(conf.rpcport == 3000) assert(conf.network == RegTest) } @@ -51,7 +51,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { |regtest.rpcport=3000 """.stripMargin.split("\n") - val conf = BitcoindConfig(confStr, tmpDir) + val conf = BitcoindConfig(confStr.toIndexedSeq, tmpDir) assert(conf.rpcport == 4000) assert(conf.network == RegTest) } @@ -66,7 +66,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { |regtest.rpcport=3000 """.stripMargin.split("\n") - val conf = BitcoindConfig(confStr, tmpDir) + val conf = BitcoindConfig(confStr.toIndexedSeq, tmpDir) assert(conf.rpcport == TestNet3.rpcPort) assert(conf.network == TestNet3) } @@ -86,7 +86,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { |rpcport=1000 """.stripMargin.split("\n") - val conf = BitcoindConfig(confStr, tmpDir) + val conf = BitcoindConfig(confStr.toIndexedSeq, tmpDir) assert(conf.rpcport == 3000) assert(conf.network == TestNet3) assert(conf.username.contains("username")) @@ -115,7 +115,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { |rpcuser=username """.stripMargin.split("\n") - val conf = BitcoindConfig(confStr, tmpDir) + val conf = BitcoindConfig(confStr.toIndexedSeq, tmpDir) assert(conf.rpcport == 4000) assert(conf.network == RegTest) assert(conf.username.contains("username")) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v16/BitcoindV16RpcClientTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v16/BitcoindV16RpcClientTest.scala index 3559864d4d..b444438275 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v16/BitcoindV16RpcClientTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v16/BitcoindV16RpcClientTest.scala @@ -109,7 +109,7 @@ class BitcoindV16RpcClientTest extends BitcoindRpcTest { .toVector val address = - BitcoinAddress.fromStringExn("mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB") + BitcoinAddress.fromString("mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB") val outputs: Map[BitcoinAddress, Bitcoins] = Map(address -> Bitcoins(0.1)) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala index 16c27f5668..1ade4b65cf 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala @@ -84,7 +84,7 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest { .toVector val address = - BitcoinAddress.fromStringExn("mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB") + BitcoinAddress.fromString("mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB") val outputs: Map[BitcoinAddress, Bitcoins] = Map(address -> Bitcoins(0.1)) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala index 1146d9d5dd..cad3f468b8 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala @@ -80,7 +80,7 @@ class PsbtRpcTest extends BitcoindRpcTest { finalized <- client.finalizePsbt(processed.psbt) } yield finalized match { case _: FinalizedPsbt => succeed - case _: NonFinalizedPsbt => fail + case _: NonFinalizedPsbt => fail() } } @@ -134,7 +134,7 @@ class PsbtRpcTest extends BitcoindRpcTest { } yield { finalized match { case _: FinalizedPsbt => succeed - case _: NonFinalizedPsbt => fail + case _: NonFinalizedPsbt => fail() } } } diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v18/BitcoindV18RpcClientTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v18/BitcoindV18RpcClientTest.scala index 4ba91d8b89..f48589dba0 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v18/BitcoindV18RpcClientTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v18/BitcoindV18RpcClientTest.scala @@ -94,8 +94,7 @@ class BitcoindV18RpcClientTest extends BitcoindRpcTest { it should "get node addresses given a count" ignore { for { (freshClient, otherFreshClient) <- clientPairF - freshclientnode <- - freshClient.addNode(freshClient.getDaemon.uri, AddNodeArgument.Add) + _ <- freshClient.addNode(freshClient.getDaemon.uri, AddNodeArgument.Add) nodeaddress <- freshClient.getNodeAddresses(1) } yield { assert(nodeaddress.head.address == otherFreshClient.instance.uri) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v20/BitcoindV20RpcClientTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v20/BitcoindV20RpcClientTest.scala index acc3b8b28f..ca6ce72093 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v20/BitcoindV20RpcClientTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v20/BitcoindV20RpcClientTest.scala @@ -7,7 +7,6 @@ import org.bitcoins.commons.jsonmodels.bitcoind.RpcOpts.WalletFlag import org.bitcoins.commons.jsonmodels.bitcoind._ import org.bitcoins.core.config.RegTest import org.bitcoins.core.gcs.{BlockFilter, FilterType} -import org.bitcoins.core.protocol.transaction.EmptyTransaction import org.bitcoins.core.psbt.PSBT import org.bitcoins.crypto.ECPublicKey import org.bitcoins.rpc.client.common.BitcoindVersion diff --git a/chain-test/src/test/scala/org/bitcoins/chain/blockchain/MainnetChainHandlerTest.scala b/chain-test/src/test/scala/org/bitcoins/chain/blockchain/MainnetChainHandlerTest.scala index a126b89782..8f001fb41c 100644 --- a/chain-test/src/test/scala/org/bitcoins/chain/blockchain/MainnetChainHandlerTest.scala +++ b/chain-test/src/test/scala/org/bitcoins/chain/blockchain/MainnetChainHandlerTest.scala @@ -1,11 +1,9 @@ package org.bitcoins.chain.blockchain -import org.bitcoins.chain import org.bitcoins.chain.config.ChainAppConfig import org.bitcoins.chain.pow.Pow import org.bitcoins.core.api.chain.db.{BlockHeaderDb, BlockHeaderDbHelper} import org.bitcoins.core.protocol.blockchain.BlockHeader -import org.bitcoins.crypto.DoubleSha256DigestBE import org.bitcoins.testkit.chain.{ ChainDbUnitTest, ChainTestUtil, diff --git a/core-test/src/test/scala/org/bitcoins/core/util/NumberUtilTest.scala b/core-test/src/test/scala/org/bitcoins/core/util/NumberUtilTest.scala index 07357fc497..ba939e835f 100644 --- a/core-test/src/test/scala/org/bitcoins/core/util/NumberUtilTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/util/NumberUtilTest.scala @@ -249,7 +249,7 @@ class NumberUtilTest extends BitcoinSUnitTest { assert(base10 == expectedBase10) // Add some extra digits for leading zeroes - val numDigits = (Math.log(num) / Math.log(base)).toInt + 5 + val numDigits = (Math.log(num.toDouble) / Math.log(base)).toInt + 5 val decomposed = NumberUtil.decompose(num, base, numDigits) assert(decomposed.head == 0) @@ -306,7 +306,7 @@ class NumberUtilTest extends BitcoinSUnitTest { forAll(Gen.choose(2, 256), Gen.choose(0L, Long.MaxValue)) { case (base, num) => // Add some extra digits for leading zeroes - val numDigits = (Math.log(num) / Math.log(base)).toInt + 5 + val numDigits = (Math.log(num.toDouble) / Math.log(base)).toInt + 5 val digits = NumberUtil.decompose(num, base, numDigits) assert(NumberUtil.fromDigits(digits, base, numDigits) == num) } diff --git a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala index 93bc9e1bca..b3a9c3e65c 100644 --- a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala +++ b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala @@ -27,7 +27,6 @@ import org.bitcoins.rpc.client.common.BitcoindRpcClient import org.bitcoins.rpc.util.AsyncUtil import org.bitcoins.testkit.async.TestAsyncUtil import org.bitcoins.testkit.eclair.rpc.{EclairNodes4, EclairRpcTestUtil} -import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil import org.bitcoins.testkit.util.{BitcoinSAsyncTest, EclairRpcTestClient} import org.scalatest.Assertion @@ -626,7 +625,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { _ = assert(channels.exists(_.state == ChannelState.NORMAL), "Nodes did not have open channel!") preimage = PaymentPreimage.random - wsEventP = Promise[WebSocketEvent] + wsEventP = Promise[WebSocketEvent]() _ <- client.connectToWebSocket { event => if (!wsEventP.isCompleted) { wsEventP.success(event) @@ -1257,6 +1256,6 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { override def afterAll(): Unit = { clients.result().foreach(EclairRpcTestUtil.shutdown) - super.afterAll + super.afterAll() } } diff --git a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcTestUtilTest.scala b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcTestUtilTest.scala index f7c46e6ab2..ed8d55902f 100644 --- a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcTestUtilTest.scala +++ b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcTestUtilTest.scala @@ -14,7 +14,7 @@ class EclairRpcTestUtilTest extends BitcoinSAsyncTest { for { cli <- EclairRpcTestUtil.startedBitcoindRpcClient() address <- cli.getNewAddress - blocks <- cli.generateToAddress(200, address) + _ <- cli.generateToAddress(200, address) } yield cli private val clients = diff --git a/node-test/src/test/scala/org/bitcoins/node/NeutrinoNodeTest.scala b/node-test/src/test/scala/org/bitcoins/node/NeutrinoNodeTest.scala index bf66866635..ab855a364f 100644 --- a/node-test/src/test/scala/org/bitcoins/node/NeutrinoNodeTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/NeutrinoNodeTest.scala @@ -34,7 +34,6 @@ class NeutrinoNodeTest extends NodeUnitTest { getBIP39PasswordOpt(), Some(BitcoindVersion.Experimental)) - private val testTimeout = 30.seconds private var assertionP: Promise[Boolean] = Promise() after { //reset assertion after a test runs, because we @@ -43,12 +42,14 @@ class NeutrinoNodeTest extends NodeUnitTest { //after a NeutrinoNode is constructed :-( assertionP = Promise() } - private var utxos: Set[ScriptPubKey] = _ + //what is going on here?? + private val utxos: Set[ScriptPubKey] = Set.empty private def blockCallback(block: Block): Future[Unit] = { val scriptPubKeys = block.transactions.flatMap(tx => tx.outputs.map(_.scriptPubKey)).toSet assertionP + //is this trivially false always? .success(utxos.intersect(scriptPubKeys) == utxos) .future .map(_ => ()) @@ -137,7 +138,7 @@ class NeutrinoNodeTest extends NodeUnitTest { RpcUtil.retryUntilSatisfiedF(conditionF = () => { node .chainApiFromDb() - .flatMap(_.getFilterHeaderCount) + .flatMap(_.getFilterHeaderCount()) .map(_ == ExpectedCount) }, interval = 1000.millis) @@ -146,7 +147,7 @@ class NeutrinoNodeTest extends NodeUnitTest { RpcUtil.retryUntilSatisfiedF(conditionF = () => { node .chainApiFromDb() - .flatMap(_.getFilterCount) + .flatMap(_.getFilterCount()) .map(_ == ExpectedCount) }, interval = 1000.millis) diff --git a/node-test/src/test/scala/org/bitcoins/node/SpvNodeTest.scala b/node-test/src/test/scala/org/bitcoins/node/SpvNodeTest.scala index a579534859..d7ee4af0af 100644 --- a/node-test/src/test/scala/org/bitcoins/node/SpvNodeTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/SpvNodeTest.scala @@ -88,8 +88,8 @@ class SpvNodeTest extends NodeUnitTest { //we should expect 5 headers have been announced to us via //the send headers message. val has6BlocksF = RpcUtil.retryUntilSatisfiedF( - conditionF = - () => spvNode.chainApiFromDb().flatMap(_.getBlockCount.map(_ == 6)), + conditionF = () => + spvNode.chainApiFromDb().flatMap(_.getBlockCount().map(_ == 6)), interval = 250.millis) has6BlocksF.map { _ => diff --git a/node-test/src/test/scala/org/bitcoins/node/networking/P2PClientTest.scala b/node-test/src/test/scala/org/bitcoins/node/networking/P2PClientTest.scala index 234e6dbc8a..175276f075 100644 --- a/node-test/src/test/scala/org/bitcoins/node/networking/P2PClientTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/networking/P2PClientTest.scala @@ -39,7 +39,6 @@ class P2PClientTest extends BitcoindRpcTest with CachedBitcoinSAppConfig { behavior of "parseIndividualMessages" it must "block header message that is not aligned with a tcp frame" in { - implicit val nodeConf = config.nodeConf val headersMsg = HeadersMessage( CompactSizeUInt(UInt64(2), 1), @@ -98,7 +97,6 @@ class P2PClientTest extends BitcoindRpcTest with CachedBitcoinSAppConfig { // when parsing a merkle block message, thereby screwing up // the parsing of the remainder it must "parse a byte vector with three messages in it" in { - implicit val nodeConf = config.nodeConf val bytes = hex"fabfb5da6d65726b6c65626c6f636b0097000000b4b6e45d00000020387191f7d488b849b4080fdf105c71269fc841a2f0f2944fc5dc785c830c716e37f36373098aae06a668cc74e388caf50ecdcb5504ce936490b4b72940e08859548c305dffff7f20010000000200000002ecd1c722709bfc241f8b94fc64034dcba2c95409dc4cd1d7b864e1128a04e5b044133327b04ff8ac576e7748a4dae4111f0c765dacbfe0c5a9fddbeb8f60d5af0105fabfb5da747800000000000000000000cc0100004413332702000000065b7f0f3eec398047e921037815aa41709b6243a1897f1423194b7558399ae0300000000017160014008dc9d88d1797305f3fbd30d2b36d6bde984a09feffffffe9145055d671fd705a09f028033da614b619205b9926fe5ebe45e15ae8b3231e0100000017160014d74cfac04bb0e6838c35f1f4a0a60d13655be2fbfeffffff797f8ff9c10fa618b6254343a648be995410e82c03fd8accb0de2271a3fb1abd00000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffc794dba971b9479dfcbc662a3aacd641553bdb2418b15c0221c5dfd4471a7a70000000001716001452c13ba0314f7718c234ed6adfea6422ce03a545feffffffb7c3bf1762b15f3b0e0eaa5beb46fe96a9e2829a7413fd900b9b7e0d192ab64800000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffb6ced6cb8dfc2f7f5b37561938ead3bc5ca4036e2b45d9738cc086a10eed4e010100000017160014aebb17e245fe8c98a75f0b6717fcadca30e491e2feffffff02002a7515000000001976a9148374ff8beb55ea2945039881ca26071b5749fafe88ac485620000000000017a91405d36a2b0bdedf3fc58bed6f9e4026f8934a2716876b050000fabfb5da686561646572730000000000010000001406e05800" val (messages, leftover) = P2PClient.parseIndividualMessages(bytes) diff --git a/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala b/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala index 7cb8bffa8c..d7435de590 100644 --- a/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala @@ -33,6 +33,16 @@ class DataMessageHandlerTest extends NodeUnitTest { val resultP: Promise[(MerkleBlock, Vector[Transaction])] = Promise() + val callback: OnMerkleBlockReceived = { + (merkle: MerkleBlock, txs: Vector[Transaction]) => + { + Future { + resultP.success((merkle, txs)) + () + } + } + } + for { sender <- spv.peerMsgSenderF @@ -44,14 +54,6 @@ class DataMessageHandlerTest extends NodeUnitTest { payload1 = MerkleBlockMessage(merkleBlock) payload2 = TransactionMessage(tx) - callback: OnMerkleBlockReceived = - (merkle: MerkleBlock, txs: Vector[Transaction]) => { - Future { - resultP.success((merkle, txs)) - () - } - } - callbacks = NodeCallbacks.onMerkleBlockReceived(callback) dataMessageHandler = DataMessageHandler(genesisChainApi, callbacks) @@ -67,6 +69,12 @@ class DataMessageHandlerTest extends NodeUnitTest { val resultP: Promise[Block] = Promise() + val callback: OnBlockReceived = (block: Block) => { + Future { + resultP.success(block) + () + } + } for { sender <- spv.peerMsgSenderF @@ -75,13 +83,6 @@ class DataMessageHandlerTest extends NodeUnitTest { payload = BlockMessage(block) - callback: OnBlockReceived = (block: Block) => { - Future { - resultP.success(block) - () - } - } - callbacks = NodeCallbacks.onBlockReceived(callback) dataMessageHandler = DataMessageHandler(genesisChainApi, callbacks) @@ -96,6 +97,13 @@ class DataMessageHandlerTest extends NodeUnitTest { val resultP: Promise[Vector[BlockHeader]] = Promise() + val callback: OnBlockHeadersReceived = (headers: Vector[BlockHeader]) => { + Future { + resultP.success(headers) + () + } + } + for { sender <- spv.peerMsgSenderF @@ -104,13 +112,6 @@ class DataMessageHandlerTest extends NodeUnitTest { payload = HeadersMessage(CompactSizeUInt.one, Vector(header)) - callback: OnBlockHeadersReceived = (headers: Vector[BlockHeader]) => { - Future { - resultP.success(headers) - () - } - } - callbacks = NodeCallbacks.onBlockHeadersReceived(callback) dataMessageHandler = DataMessageHandler(genesisChainApi, callbacks) @@ -125,7 +126,15 @@ class DataMessageHandlerTest extends NodeUnitTest { val resultP: Promise[Vector[(DoubleSha256Digest, GolombFilter)]] = Promise() - + val callback: OnCompactFiltersReceived = { + (filters: Vector[(DoubleSha256Digest, GolombFilter)]) => + { + Future { + resultP.success(filters) + () + } + } + } for { sender <- spv.peerMsgSenderF @@ -135,14 +144,6 @@ class DataMessageHandlerTest extends NodeUnitTest { payload = CompactFilterMessage(FilterType.Basic, hash.flip, filter.filter.bytes) - callback: OnCompactFiltersReceived = - (filters: Vector[(DoubleSha256Digest, GolombFilter)]) => { - Future { - resultP.success(filters) - () - } - } - callbacks = NodeCallbacks.onCompactFilterReceived(callback) dataMessageHandler = DataMessageHandler(genesisChainApi, callbacks) diff --git a/node-test/src/test/scala/org/bitcoins/node/networking/peer/PeerMessageHandlerTest.scala b/node-test/src/test/scala/org/bitcoins/node/networking/peer/PeerMessageHandlerTest.scala index 0573dcd29e..76f7a49641 100644 --- a/node-test/src/test/scala/org/bitcoins/node/networking/peer/PeerMessageHandlerTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/networking/peer/PeerMessageHandlerTest.scala @@ -35,7 +35,7 @@ class PeerMessageHandlerTest extends NodeUnitTest { bitcoindPeerF.flatMap(_ => peerHandlerF.map(_.peerMsgSender.connect())) val isConnectedF = TestAsyncUtil.retryUntilSatisfiedF( - () => p2pClientF.flatMap(_.isConnected), + () => p2pClientF.flatMap(_.isConnected()), interval = 500.millis ) @@ -196,6 +196,6 @@ class PeerMessageHandlerTest extends NodeUnitTest { override def afterAll(): Unit = { startedBitcoindF.flatMap(_.stop()) - super.afterAll + super.afterAll() } } diff --git a/project/CommonSettings.scala b/project/CommonSettings.scala index 6f12c42922..318af4cac4 100644 --- a/project/CommonSettings.scala +++ b/project/CommonSettings.scala @@ -54,7 +54,7 @@ object CommonSettings { scalacOptions in (Compile, doc) ~= (_ filterNot (s => s == "-Xfatal-warnings")), scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value, - scalacOptions in Test := testCompilerOpts, + scalacOptions in Test := testCompilerOpts(scalaVersion.value), Compile / compile / javacOptions ++= { if (isCI) { //jdk11 is used on CI, we need to use the --release flag to make sure @@ -105,9 +105,12 @@ object CommonSettings { else nonScala2_13CompilerOpts } - val testCompilerOpts: Seq[String] = commonCompilerOpts ++ - //initialization checks: https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html - Vector("-Xcheckinit") + def testCompilerOpts(scalaVersion: String): Seq[String] = { + commonCompilerOpts ++ + //initialization checks: https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html + Vector("-Xcheckinit") ++ + compilerOpts(scalaVersion) + } lazy val testSettings: Seq[Setting[_]] = Seq( //show full stack trace (-oF) of failed tests and duration of tests (-oD) diff --git a/project/Deps.scala b/project/Deps.scala index 83be2af4ad..9c6e541eba 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -283,7 +283,8 @@ object Deps { Test.logback, Test.scalaTest, Test.scalacheck, - Test.newAsync + Test.newAsync, + Test.scalaCollectionCompat ) val bench = List( diff --git a/wallet-test/src/test/scala/org/bitcoins/wallet/TrezorAddressTest.scala b/wallet-test/src/test/scala/org/bitcoins/wallet/TrezorAddressTest.scala index 591ae0c766..0691f817e3 100644 --- a/wallet-test/src/test/scala/org/bitcoins/wallet/TrezorAddressTest.scala +++ b/wallet-test/src/test/scala/org/bitcoins/wallet/TrezorAddressTest.scala @@ -13,7 +13,6 @@ import org.bitcoins.feeprovider.ConstantFeeRateProvider import org.bitcoins.keymanager.bip39.BIP39KeyManager import org.bitcoins.testkit.BitcoinSTestAppConfig import org.bitcoins.testkit.fixtures.EmptyFixture -import org.bitcoins.testkit.keymanager.KeyManagerTestUtil import org.bitcoins.testkit.wallet.BitcoinSWalletTest import org.bitcoins.testkit.wallet.BitcoinSWalletTest.{ MockChainQueryApi,