diff --git a/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala b/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala index 86933efeef..b5637267c1 100644 --- a/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala +++ b/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala @@ -33,18 +33,14 @@ import org.bitcoins.node.Node import org.bitcoins.wallet.MockWalletApi import org.bitcoins.wallet.models._ import org.scalamock.scalatest.MockFactory -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.wordspec.AnyWordSpec import scodec.bits.ByteVector import ujson.Value.InvalidData import ujson._ import scala.concurrent.Future -class RoutesSpec - extends WordSpec - with Matchers - with ScalatestRouteTest - with MockFactory { +class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory { // the genesis address val testAddressStr = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" @@ -80,9 +76,9 @@ class RoutesSpec Arr(Arr(Str(psbt1.base64), Str(psbt2.base64))))) Get() ~> route ~> check { - contentType shouldEqual `application/json` + contentType == `application/json` responseAs[ - String] shouldEqual s"""{"result":"${expected.base64}","error":null}""" + String] == s"""{"result":"${expected.base64}","error":null}""" } val joinRoute = @@ -91,9 +87,9 @@ class RoutesSpec Arr(Arr(Str(psbt1.base64), Str(psbt2.base64))))) Get() ~> joinRoute ~> check { - contentType shouldEqual `application/json` + contentType == `application/json` responseAs[ - String] shouldEqual s"""{"result":"${expected.base64}","error":null}""" + String] == s"""{"result":"${expected.base64}","error":null}""" } } @@ -108,9 +104,9 @@ class RoutesSpec ServerCommand("finalizepsbt", Arr(Str(psbt.hex)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` + contentType == `application/json` responseAs[ - String] shouldEqual s"""{"result":"${expected.base64}","error":null}""" + String] == s"""{"result":"${expected.base64}","error":null}""" } } @@ -126,9 +122,8 @@ class RoutesSpec ServerCommand("extractfrompsbt", Arr(Str(psbt.hex)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual s"""{"result":"${expected.hex}","error":null}""" + contentType == `application/json` + responseAs[String] == s"""{"result":"${expected.hex}","error":null}""" } } @@ -144,9 +139,9 @@ class RoutesSpec ServerCommand("converttopsbt", Arr(Str(tx.hex)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` + contentType == `application/json` responseAs[ - String] shouldEqual s"""{"result":"${expected.base64}","error":null}""" + String] == s"""{"result":"${expected.base64}","error":null}""" } } @@ -160,8 +155,8 @@ class RoutesSpec chainRoutes.handleCommand(ServerCommand("getblockcount", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":1234567890,"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":1234567890,"error":null}""" } } @@ -174,8 +169,8 @@ class RoutesSpec chainRoutes.handleCommand(ServerCommand("getfiltercount", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":1234567890,"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":1234567890,"error":null}""" } } @@ -188,8 +183,8 @@ class RoutesSpec chainRoutes.handleCommand(ServerCommand("getfilterheadercount", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":1234567890,"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":1234567890,"error":null}""" } } @@ -202,8 +197,8 @@ class RoutesSpec chainRoutes.handleCommand(ServerCommand("getbestblockhash", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" } } @@ -217,9 +212,8 @@ class RoutesSpec ServerCommand("getbalance", Arr(Bool(false)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"50.00000000 BTC","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"50.00000000 BTC","error":null}""" } } @@ -232,9 +226,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getbalance", Arr(Bool(true)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"5000000000 sats","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"5000000000 sats","error":null}""" } } @@ -248,9 +241,8 @@ class RoutesSpec ServerCommand("getconfirmedbalance", Arr(Bool(false)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"50.00000000 BTC","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"50.00000000 BTC","error":null}""" } } @@ -264,9 +256,8 @@ class RoutesSpec ServerCommand("getconfirmedbalance", Arr(Bool(true)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"5000000000 sats","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"5000000000 sats","error":null}""" } } @@ -280,9 +271,8 @@ class RoutesSpec ServerCommand("getunconfirmedbalance", Arr(Bool(false)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"50.00000000 BTC","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"50.00000000 BTC","error":null}""" } } @@ -296,9 +286,8 @@ class RoutesSpec ServerCommand("getunconfirmedbalance", Arr(Bool(true)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual """{"result":"5000000000 sats","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"5000000000 sats","error":null}""" } } @@ -311,8 +300,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("isempty", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":true,"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":true,"error":null}""" } } @@ -336,8 +325,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getutxos", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000ffffffff -1 sats\n","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000ffffffff -1 sats\n","error":null}""" } } @@ -358,8 +347,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getaddresses", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":["""" + testAddressStr + """"],"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":["""" + testAddressStr + """"],"error":null}""" } } @@ -380,8 +369,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getspentaddresses", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":["""" + testAddressStr + """"],"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":["""" + testAddressStr + """"],"error":null}""" } } @@ -404,8 +393,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getfundedaddresses", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual + contentType == `application/json` + responseAs[String] == s"""{"result":["$testAddressStr ${Satoshis.zero}"],"error":null}""".stripMargin } } @@ -427,8 +416,8 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getunusedaddresses", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":["""" + testAddressStr + """"],"error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":["""" + testAddressStr + """"],"error":null}""" } } @@ -451,8 +440,9 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getaccounts", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":["""" + xpub.toString + """"],"error":null}""" + contentType == `application/json` + responseAs[ + String] == """{"result":["""" + xpub.toString + """"],"error":null}""" } } @@ -465,8 +455,9 @@ class RoutesSpec walletRoutes.handleCommand(ServerCommand("getnewaddress", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"""" + testAddressStr + """","error":null}""" + contentType == `application/json` + responseAs[ + String] == """{"result":"""" + testAddressStr + """","error":null}""" } } @@ -485,9 +476,8 @@ class RoutesSpec ServerCommand("sendrawtransaction", Arr(Str(tx.hex)))) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[ - String] shouldEqual s"""{"result":"${tx.txIdBE.hex}","error":null}""" + contentType == `application/json` + responseAs[String] == s"""{"result":"${tx.txIdBE.hex}","error":null}""" } } @@ -509,8 +499,8 @@ class RoutesSpec Arr(Str(testAddressStr), Num(100), Num(4)))) Post() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" } // negative cases @@ -519,7 +509,7 @@ class RoutesSpec ServerCommand("sendtoaddress", Arr(Null, Null, Null))) Post() ~> route1 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Str"))) } @@ -528,7 +518,7 @@ class RoutesSpec ServerCommand("sendtoaddress", Arr("Null", Null, Null))) Post() ~> route2 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("Null", "Expected a valid address"))) } @@ -537,7 +527,7 @@ class RoutesSpec ServerCommand("sendtoaddress", Arr(Str(testAddressStr), Null, Null))) Post() ~> route3 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Num"))) } @@ -547,7 +537,7 @@ class RoutesSpec Arr(Str(testAddressStr), Str("abc"), Null))) Post() ~> route4 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("abc", "Expected ujson.Num"))) } @@ -578,8 +568,8 @@ class RoutesSpec Arr(Arr(), Str(testAddressStr), Num(100), Num(4)))) Post() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" } // negative cases @@ -588,7 +578,7 @@ class RoutesSpec ServerCommand("sendfromoutpoints", Arr(Arr(), Null, Null, Null))) Post() ~> route1 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Str"))) } @@ -597,7 +587,7 @@ class RoutesSpec ServerCommand("sendfromoutpoints", Arr(Arr(), "Null", Null, Null))) Post() ~> route2 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("Null", "Expected a valid address"))) } @@ -607,7 +597,7 @@ class RoutesSpec Arr(Arr(), Str(testAddressStr), Null, Null))) Post() ~> route3 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Num"))) } @@ -617,7 +607,7 @@ class RoutesSpec Arr(Arr(), Str(testAddressStr), Str("abc"), Null))) Post() ~> route4 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("abc", "Expected ujson.Num"))) } @@ -627,7 +617,7 @@ class RoutesSpec Arr(Null, Str(testAddressStr), Num(100), Num(4)))) Post() ~> route5 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Arr"))) } @@ -660,8 +650,8 @@ class RoutesSpec Str("AccumulateSmallestViable")))) Post() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" } // negative cases @@ -670,7 +660,7 @@ class RoutesSpec ServerCommand("sendwithalgo", Arr(Null, Null, Null, Null))) Post() ~> route1 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Str"))) } @@ -679,7 +669,7 @@ class RoutesSpec ServerCommand("sendwithalgo", Arr("Null", Null, Null, Null))) Post() ~> route2 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("Null", "Expected a valid address"))) } @@ -689,7 +679,7 @@ class RoutesSpec Arr(Str(testAddressStr), Null, Null, Null))) Post() ~> route3 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Num"))) } @@ -699,7 +689,7 @@ class RoutesSpec Arr(Str(testAddressStr), Str("abc"), Null, Null))) Post() ~> route4 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData("abc", "Expected ujson.Num"))) } @@ -709,7 +699,7 @@ class RoutesSpec Arr(Str(testAddressStr), Num(100), Num(4), Null))) Post() ~> route5 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Null, "Expected ujson.Str"))) } @@ -733,8 +723,8 @@ class RoutesSpec ServerCommand("opreturncommit", Arr(message, Bool(false), Num(4)))) Post() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"0000000000000000000000000000000000000000000000000000000000000000","error":null}""" } } @@ -743,8 +733,9 @@ class RoutesSpec nodeRoutes.handleCommand(ServerCommand("getpeers", Arr())) Get() ~> route ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"TODO implement getpeers","error":null}""" + contentType == `application/json` + responseAs[ + String] == """{"result":"TODO implement getpeers","error":null}""" } } @@ -771,8 +762,8 @@ class RoutesSpec ServerCommand("rescan", Arr(Arr(), Null, Null, true, true))) Post() ~> route1 ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"scheduled","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"scheduled","error":null}""" } (mockWalletApi.isEmpty: () => Future[Boolean]) @@ -798,8 +789,8 @@ class RoutesSpec Arr(Arr(), Str("2018-10-27T12:34:56Z"), Null, true, true))) Post() ~> route2 ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"scheduled","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"scheduled","error":null}""" } (mockWalletApi.isEmpty: () => Future[Boolean]) @@ -820,8 +811,8 @@ class RoutesSpec Arr(Null, Null, Str(DoubleSha256DigestBE.empty.hex), true, true))) Post() ~> route3 ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"scheduled","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"scheduled","error":null}""" } (mockWalletApi.isEmpty: () => Future[Boolean]) @@ -841,8 +832,8 @@ class RoutesSpec Arr(Arr(), Str("12345"), Num(67890), true, true))) Post() ~> route4 ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"scheduled","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"scheduled","error":null}""" } // negative cases @@ -853,9 +844,8 @@ class RoutesSpec Arr(Null, Str("abcd"), Str("efgh"), true, true))) Post() ~> route5 ~> check { - rejection shouldEqual ValidationRejection( - "failure", - Some(InvalidBlockStamp("abcd"))) + rejection == ValidationRejection("failure", + Some(InvalidBlockStamp("abcd"))) } val route6 = @@ -865,7 +855,7 @@ class RoutesSpec Arr(Arr(55), Null, Str("2018-10-27T12:34:56"), true, true))) Post() ~> route6 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidBlockStamp("2018-10-27T12:34:56"))) } @@ -875,7 +865,7 @@ class RoutesSpec ServerCommand("rescan", Arr(Null, Num(-1), Null, true, false))) Post() ~> route7 ~> check { - rejection shouldEqual ValidationRejection( + rejection == ValidationRejection( "failure", Some(InvalidData(Num(-1), "Expected a positive integer"))) } @@ -897,8 +887,8 @@ class RoutesSpec Arr(Arr(55), Arr(), Arr(), Bool(true), Bool(true)))) Post() ~> route8 ~> check { - contentType shouldEqual `application/json` - responseAs[String] shouldEqual """{"result":"scheduled","error":null}""" + contentType == `application/json` + responseAs[String] == """{"result":"scheduled","error":null}""" } } diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureCreatorTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureCreatorTest.scala index 6201ee897c..7b3780ec32 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureCreatorTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureCreatorTest.scala @@ -9,15 +9,12 @@ import org.bitcoins.core.script.PreExecutionScriptProgram import org.bitcoins.core.script.crypto.HashType import org.bitcoins.core.script.interpreter.ScriptInterpreter import org.bitcoins.core.script.result.ScriptOk -import org.bitcoins.core.util.BitcoinSLogger import org.bitcoins.crypto.{ ECDigitalSignature, ECPrivateKey, EmptyDigitalSignature } import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TransactionTestUtil} -import org.scalatest.concurrent.ScalaFutures -import org.scalatest.{FlatSpec, MustMatchers} import scodec.bits.ByteVector import scala.concurrent.Future diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureSerializerTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureSerializerTest.scala index aef5358048..a0a5956b0e 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureSerializerTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/TransactionSignatureSerializerTest.scala @@ -1,7 +1,7 @@ package org.bitcoins.core.crypto import org.bitcoins.core.currency.{Bitcoins, CurrencyUnits, Satoshis} -import org.bitcoins.core.number.{Int32, Int64, UInt32} +import org.bitcoins.core.number.{Int32, UInt32} import org.bitcoins.core.policy.Policy import org.bitcoins.core.protocol.script._ import org.bitcoins.core.protocol.transaction._ @@ -9,15 +9,14 @@ import org.bitcoins.core.script.crypto._ import org.bitcoins.core.serializers.script.ScriptParser import org.bitcoins.core.util._ import org.bitcoins.crypto.DoubleSha256Digest -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.BitcoinSAsyncTest import scala.util.Try /** * Created by chris on 2/19/16. */ -class TransactionSignatureSerializerTest extends FlatSpec with MustMatchers { - private def logger = BitcoinSLogger.logger +class TransactionSignatureSerializerTest extends BitcoinSAsyncTest { "TransactionSignatureSerializer" must "correctly serialize an input that is being checked where another input in the same tx is using SIGHASH_ANYONECANPAY" in { //this is from a test case inside of tx_valid.json diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/script/P2SHScriptSignatureTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/script/P2SHScriptSignatureTest.scala index 25c09ce57e..8504b2372f 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/script/P2SHScriptSignatureTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/script/P2SHScriptSignatureTest.scala @@ -7,14 +7,12 @@ import org.bitcoins.core.script.constant.{ } import org.bitcoins.core.util.BitcoinSLogger import org.bitcoins.crypto.ECPublicKey -import org.bitcoins.testkit.util.TestUtil -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TestUtil} /** * Created by chris on 3/8/16. */ -class P2SHScriptSignatureTest extends FlatSpec with MustMatchers { - private def logger = BitcoinSLogger.logger +class P2SHScriptSignatureTest extends BitcoinSAsyncTest { "P2SHScriptSignature" must "find the public keys embedded inside of the redeemScript" in { val rawP2SHScriptSig = TestUtil.rawP2shInputScript2Of2 diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/script/ScriptSignatureTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/script/ScriptSignatureTest.scala index ffcbc892c6..4447fa2980 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/script/ScriptSignatureTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/script/ScriptSignatureTest.scala @@ -6,7 +6,6 @@ import org.bitcoins.core.number.Int32 import org.bitcoins.core.policy.Policy import org.bitcoins.core.protocol.script.testprotocol.SignatureHashTestCase import org.bitcoins.core.protocol.transaction.{ - BaseTransaction, NonWitnessTransaction, Transaction, TransactionOutput, @@ -16,8 +15,7 @@ import org.bitcoins.core.script.crypto.{HashType, SIGHASH_ALL} import org.bitcoins.core.serializers.script.RawScriptSignatureParser import org.bitcoins.core.util.{BitcoinSLogger, BytesUtil} import org.bitcoins.crypto.{DoubleSha256Digest, ECDigitalSignature} -import org.bitcoins.testkit.util.TestUtil -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TestUtil} import scodec.bits.ByteVector import spray.json._ @@ -26,8 +24,7 @@ import scala.io.Source /** * Created by chris on 2/17/16. */ -class ScriptSignatureTest extends FlatSpec with MustMatchers { - private val logger = BitcoinSLogger.logger +class ScriptSignatureTest extends BitcoinSAsyncTest { "ScriptSignature" must "find the digital signature for the transaction inside of a p2pkh script signature" in { val scriptSig = ScriptSignature(TestUtil.rawScriptSig) @@ -145,7 +142,7 @@ class ScriptSignatureTest extends FlatSpec with MustMatchers { val testCases: Seq[SignatureHashTestCase] = lines.parseJson.convertTo[Seq[SignatureHashTestCase]] - for { + val allTests = for { testCase <- testCases } yield { Transaction(testCase.transaction.hex) must be(testCase.transaction) @@ -166,8 +163,9 @@ class ScriptSignatureTest extends FlatSpec with MustMatchers { TransactionSignatureSerializer.hashForSignature(txSigComponent, testCase.hashType) val flipHash = BytesUtil.flipEndianness(testCase.hash.hex) - hashForSig must be(DoubleSha256Digest(flipHash)) + hashForSig == DoubleSha256Digest(flipHash) } + assert(allTests.forall(x => x)) } } diff --git a/core-test/src/test/scala/org/bitcoins/core/script/control/ControlOperationsInterpreterTest.scala b/core-test/src/test/scala/org/bitcoins/core/script/control/ControlOperationsInterpreterTest.scala index 6fab7557bb..e449aa6fe4 100644 --- a/core-test/src/test/scala/org/bitcoins/core/script/control/ControlOperationsInterpreterTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/script/control/ControlOperationsInterpreterTest.scala @@ -15,15 +15,16 @@ import org.bitcoins.core.script.result.{ } import org.bitcoins.core.serializers.script.ScriptParser import org.bitcoins.core.util._ -import org.bitcoins.testkit.util.TestUtil -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TestUtil} + +import scala.concurrent.Future /** * Created by chris on 1/6/16. */ -class ControlOperationsInterpreterTest extends FlatSpec with MustMatchers { - private def logger = BitcoinSLogger.logger - val COI = ControlOperationsInterpreter +class ControlOperationsInterpreterTest extends BitcoinSAsyncTest { + + val COI: ControlOperationsInterpreter = ControlOperationsInterpreter "ControlOperationsInterpreter" must "have OP_VERIFY evaluate to true with '1' on the stack" in { val stack = List(OP_TRUE) val script = List(OP_VERIFY) @@ -44,6 +45,7 @@ class ControlOperationsInterpreterTest extends FlatSpec with MustMatchers { TestUtil.testProgramExecutionInProgress.updateStackAndScript(stack, script) val result = COI.opVerify(program) + result.stackTopIsTrue must be(true) } it must "have OP_VERIFY evaluate to false with '0' on the stack" in { @@ -70,13 +72,15 @@ class ControlOperationsInterpreterTest extends FlatSpec with MustMatchers { } it must "fail for verify when there is nothing on the script stack" in { - intercept[IllegalArgumentException] { - val stack = List(ScriptConstant("1")) - val script = List() - val program = - TestUtil.testProgramExecutionInProgress.updateStackAndScript(stack, - script) - val result = COI.opVerify(program) + recoverToSucceededIf[IllegalArgumentException] { + Future { + val stack = List(ScriptConstant("1")) + val script = List() + val program = + TestUtil.testProgramExecutionInProgress.updateStackAndScript(stack, + script) + COI.opVerify(program) + } } } diff --git a/core-test/src/test/scala/org/bitcoins/core/script/crypto/CryptoInterpreterTest.scala b/core-test/src/test/scala/org/bitcoins/core/script/crypto/CryptoInterpreterTest.scala index 613a16f00d..3450ee7193 100644 --- a/core-test/src/test/scala/org/bitcoins/core/script/crypto/CryptoInterpreterTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/script/crypto/CryptoInterpreterTest.scala @@ -7,23 +7,17 @@ import org.bitcoins.core.protocol.script.ScriptSignature import org.bitcoins.core.protocol.transaction._ import org.bitcoins.core.script._ import org.bitcoins.core.script.constant._ -import org.bitcoins.core.script.flag.{ - ScriptFlagFactory, - ScriptVerifyDerSig, - ScriptVerifyNullDummy -} +import org.bitcoins.core.script.flag.{ScriptVerifyDerSig, ScriptVerifyNullDummy} import org.bitcoins.core.script.result._ import org.bitcoins.core.util.{BitcoinSLogger, ScriptProgramTestUtil} -import org.bitcoins.testkit.util.TestUtil -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TestUtil} import scala.util.Try /** * Created by chris on 1/6/16. */ -class CryptoInterpreterTest extends FlatSpec with MustMatchers { - private def logger = BitcoinSLogger.logger +class CryptoInterpreterTest extends BitcoinSAsyncTest { val stack = List(ScriptConstant( "02218AD6CDC632E7AE7D04472374311CEBBBBF0AB540D2D08C3400BB844C654231".toLowerCase)) diff --git a/core-test/src/test/scala/org/bitcoins/core/serializers/transaction/RawTransactionInputParserTest.scala b/core-test/src/test/scala/org/bitcoins/core/serializers/transaction/RawTransactionInputParserTest.scala index 39ead9e0b1..d81d9e75a0 100644 --- a/core-test/src/test/scala/org/bitcoins/core/serializers/transaction/RawTransactionInputParserTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/serializers/transaction/RawTransactionInputParserTest.scala @@ -6,15 +6,13 @@ import org.bitcoins.core.protocol.transaction.{ TransactionInput } import org.bitcoins.core.util.{BitcoinSLogger, BytesUtil} -import org.bitcoins.testkit.util.TestUtil -import org.scalatest.{FlatSpec, MustMatchers} +import org.bitcoins.testkit.util.{BitcoinSAsyncTest, TestUtil} import scodec.bits.ByteVector /** * Created by chris on 1/13/16. */ -class RawTransactionInputParserTest extends FlatSpec with MustMatchers { - private val logger = BitcoinSLogger.logger +class RawTransactionInputParserTest extends BitcoinSAsyncTest { //txid cad1082e674a7bd3bc9ab1bc7804ba8a57523607c876b8eb2cbe645f2b1803d6 val rawTxInput = diff --git a/core-test/src/test/scala/org/bitcoins/core/util/FutureUtilTest.scala b/core-test/src/test/scala/org/bitcoins/core/util/FutureUtilTest.scala index 07904f94a8..2ea716cbd5 100644 --- a/core-test/src/test/scala/org/bitcoins/core/util/FutureUtilTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/util/FutureUtilTest.scala @@ -1,13 +1,12 @@ package org.bitcoins.core.util -import org.bitcoins.testkit.util.BitcoinSUnitTest -import scala.concurrent.duration._ -import scala.concurrent._ -import org.scalatest.compatible.Assertion -import org.scalatest.AsyncFlatSpec import akka.actor.ActorSystem +import org.bitcoins.testkit.util.BitcoinSAsyncTest +import org.scalatest.compatible.Assertion -class FutureUtilTest extends AsyncFlatSpec with BitcoinSLogger { +import scala.concurrent._ + +class FutureUtilTest extends BitcoinSAsyncTest with BitcoinSLogger { it must "execute futures sequentially in the correct order" in { val actorSystem = ActorSystem() diff --git a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/network/NodeUriTest.scala b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/network/NodeUriTest.scala index 0641415ae3..1f174b2d82 100644 --- a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/network/NodeUriTest.scala +++ b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/network/NodeUriTest.scala @@ -1,9 +1,9 @@ package org.bitcoins.eclair.network import org.bitcoins.eclair.rpc.network.NodeUri -import org.scalatest.FlatSpec +import org.bitcoins.testkit.util.BitcoinSAsyncTest -class NodeUriTest extends FlatSpec { +class NodeUriTest extends BitcoinSAsyncTest { behavior of "NodeUri" diff --git a/project/Deps.scala b/project/Deps.scala index f06596ea9d..5f8ef0ccf0 100644 --- a/project/Deps.scala +++ b/project/Deps.scala @@ -6,7 +6,7 @@ object Deps { val bouncyCastle = "1.65.01" val logback = "1.2.3" val scalacheck = "1.14.3" - val scalaTest = "3.1.2" + val scalaTest = "3.2.0" val scalaTestPlus = "3.2.0.0" //super annoying... https://oss.sonatype.org/content/groups/public/org/scalatestplus/ val slf4j = "1.7.30" diff --git a/zmq/src/test/scala/org/bitcoins/zmq/ZMQSubscriberTest.scala b/zmq/src/test/scala/org/bitcoins/zmq/ZMQSubscriberTest.scala index b6bd408ebd..ee82fe971d 100644 --- a/zmq/src/test/scala/org/bitcoins/zmq/ZMQSubscriberTest.scala +++ b/zmq/src/test/scala/org/bitcoins/zmq/ZMQSubscriberTest.scala @@ -3,14 +3,14 @@ package org.bitcoins.zmq import java.net.InetSocketAddress import org.bitcoins.core.util.BytesUtil -import org.scalatest.{AsyncFlatSpec, MustMatchers} +import org.scalatest.flatspec.AsyncFlatSpec import org.slf4j.LoggerFactory import org.zeromq.{ZFrame, ZMQ, ZMsg} import scodec.bits.ByteVector import scala.concurrent.Promise -class ZMQSubscriberTest extends AsyncFlatSpec with MustMatchers { +class ZMQSubscriberTest extends AsyncFlatSpec { private val logger = LoggerFactory.getLogger(this.getClass().toString) behavior of "ZMQSubscriber"