mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
2020 12 19 enable test compileropts (#2400)
* Fix bug where test compiler opts were not enabled * Fix all exsting compiler warnings in test project * Add scalaCollectionCompat dependency to bitcoindRpcTest so we can use @nowarn annotation on scala 2.12
This commit is contained in:
parent
f6efa8441e
commit
d204056ad8
27 changed files with 95 additions and 87 deletions
|
@ -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 {
|
||||
|
|
|
@ -18,6 +18,7 @@ class BitcoindRpcAppConfigTest extends BitcoinSAsyncTest {
|
|||
override def afterAll(): Unit = {
|
||||
super.afterAll()
|
||||
new Directory(tempDir.toFile).deleteRecursively()
|
||||
()
|
||||
}
|
||||
|
||||
it must "be overridable" in {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -26,6 +26,7 @@ class NodeRpcTest extends BitcoindRpcTest {
|
|||
recoverToSucceededIf[MiscError](client.rescanBlockChain())
|
||||
system.scheduler.scheduleOnce(100.millis) {
|
||||
client.abortRescan()
|
||||
()
|
||||
}
|
||||
rescanFailedF
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 { _ =>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -283,7 +283,8 @@ object Deps {
|
|||
Test.logback,
|
||||
Test.scalaTest,
|
||||
Test.scalacheck,
|
||||
Test.newAsync
|
||||
Test.newAsync,
|
||||
Test.scalaCollectionCompat
|
||||
)
|
||||
|
||||
val bench = List(
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue