mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-25 00:59:03 +01:00
Remove logging from testkit core (#2813)
* Remove logging from testkit core * Fixup deps
This commit is contained in:
parent
07514e2348
commit
c6c4e83e9e
25 changed files with 29 additions and 70 deletions
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.asyncutil
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.asyncutil.AsyncUtil.scheduler
|
||||
import org.bitcoins.core.api.asyncutil.AsyncUtilApi
|
||||
|
||||
|
@ -8,7 +7,7 @@ import java.util.concurrent.{Executors, TimeUnit}
|
|||
import scala.concurrent._
|
||||
import scala.concurrent.duration.{DurationInt, FiniteDuration}
|
||||
|
||||
abstract class AsyncUtil extends AsyncUtilApi with Logging {
|
||||
abstract class AsyncUtil extends AsyncUtilApi {
|
||||
import AsyncUtil.DEFAULT_MAX_TRIES
|
||||
|
||||
private def retryRunnable(
|
||||
|
|
|
@ -85,8 +85,7 @@ lazy val asyncUtils = crossProject(JVMPlatform, JSPlatform)
|
|||
.crossType(CrossType.Pure)
|
||||
.in(file("async-utils"))
|
||||
.settings(CommonSettings.prodSettings: _*)
|
||||
.settings(name := "bitcoin-s-async-utils",
|
||||
libraryDependencies ++= Deps.asyncUtils)
|
||||
.settings(name := "bitcoin-s-async-utils")
|
||||
.jvmSettings(CommonSettings.jvmSettings: _*)
|
||||
.jsSettings(commonJsSettings: _*)
|
||||
.dependsOn(core)
|
||||
|
|
|
@ -3,15 +3,13 @@ package org.bitcoins.core.crypto
|
|||
import org.bitcoins.core.script.PreExecutionScriptProgram
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.script.result._
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.TransactionGenerators
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
/** Created by chris on 7/25/16.
|
||||
*/
|
||||
class TransactionSignatureCreatorSpec
|
||||
extends Properties("TransactionSignatureCreatorSpec")
|
||||
with Logging {
|
||||
extends Properties("TransactionSignatureCreatorSpec") {
|
||||
|
||||
property("Must generate a valid signature for a p2pk transaction") =
|
||||
Prop.forAll(TransactionGenerators.signedP2PKTransaction) {
|
||||
|
@ -108,7 +106,6 @@ class TransactionSignatureCreatorSpec
|
|||
case (wtxSigComponent, _) =>
|
||||
val program = PreExecutionScriptProgram(wtxSigComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
if (result != ScriptOk) logger.warn("Result: " + result)
|
||||
result == ScriptOk
|
||||
}
|
||||
|
||||
|
@ -118,7 +115,6 @@ class TransactionSignatureCreatorSpec
|
|||
case (wtxSigComponent, _) =>
|
||||
val program = PreExecutionScriptProgram(wtxSigComponent)
|
||||
val result = ScriptInterpreter.run(program)
|
||||
if (result != ScriptOk) logger.warn("Result: " + result)
|
||||
Seq(ScriptErrorPushSize, ScriptOk).contains(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.core.number
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.scalacheck.{Gen, Prop, Properties}
|
||||
|
||||
|
@ -8,7 +7,7 @@ import scala.util.Try
|
|||
|
||||
/** Created by chris on 6/16/16.
|
||||
*/
|
||||
class UInt32Spec extends Properties("UInt32") with Logging {
|
||||
class UInt32Spec extends Properties("UInt32") {
|
||||
|
||||
property("serialization symmetry") = {
|
||||
Prop.forAll(NumberGenerator.uInt32s) { uInt32: UInt32 =>
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.bitcoins.core.number
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.scalacheck.{Gen, Prop, Properties}
|
||||
|
||||
import scala.util.Try
|
||||
|
||||
class UInt8Spec extends Properties("UInt8Spec") with Logging {
|
||||
class UInt8Spec extends Properties("UInt8Spec") {
|
||||
|
||||
property("convert uint8 -> byte -> uint8") = {
|
||||
Prop.forAll(NumberGenerator.uInt8) { case u8: UInt8 =>
|
||||
|
@ -39,12 +38,7 @@ class UInt8Spec extends Properties("UInt8Spec") with Logging {
|
|||
val r = u8 >> shift
|
||||
val expected =
|
||||
if (shift > 31) UInt8.zero else UInt8((u8.toLong >> shift).toShort)
|
||||
if (r != expected) {
|
||||
logger.warn("expected: " + expected)
|
||||
logger.warn("r: " + r)
|
||||
}
|
||||
r == expected
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ class NetworkPayloadTest extends BitcoinSJvmTest {
|
|||
"NetworkMessage" must "create a payload object from it's network header and the payload bytes" in {
|
||||
val rawNetworkMessage = P2PMessageTestUtil.rawNetworkMessage
|
||||
val header = NetworkHeader(rawNetworkMessage.take(48))
|
||||
logger.debug("Header: " + header)
|
||||
val payloadHex = rawNetworkMessage.slice(48, rawNetworkMessage.length)
|
||||
val payload = NetworkPayload(header, payloadHex)
|
||||
payload.isInstanceOf[VersionMessage] must be(true)
|
||||
|
|
|
@ -14,7 +14,6 @@ class BlockTest extends BitcoinSJvmTest {
|
|||
val _ = block // call-by-name
|
||||
val t1 = System.currentTimeMillis()
|
||||
val time = t1 - t0
|
||||
logger.info("Elapsed time: " + time + "ms")
|
||||
time
|
||||
}
|
||||
|
||||
|
@ -47,7 +46,6 @@ class BlockTest extends BitcoinSJvmTest {
|
|||
it must "have serialization symmetry" in {
|
||||
forAllParallel(BlockchainElementsGenerator.block) { block =>
|
||||
val result = Block(block.hex) == block
|
||||
if (!result) logger.warn("block.hex: " + block.hex)
|
||||
assert(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,6 @@ class ChainParamsTest extends BitcoinSUnitTest {
|
|||
RegTestNetChainParams.genesisBlock.hex must be(expectedHex)
|
||||
}
|
||||
it must "generate the correct blockheader hash for the genesis block on regtest" in {
|
||||
logger.debug("Regtest genesis block: " + RegTestNetChainParams.genesisBlock)
|
||||
RegTestNetChainParams.genesisBlock.blockHeader.hash.hex must be(
|
||||
BytesUtil.flipEndianness(
|
||||
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"))
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.bitcoins.core.protocol.script
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.ScriptGenerators
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
/** Created by chris on 6/22/16.
|
||||
*/
|
||||
class P2PKScriptSignatureSpec extends Properties("P2PKSpec") with Logging {
|
||||
class P2PKScriptSignatureSpec extends Properties("P2PKSpec") {
|
||||
|
||||
property("Serialization symmetry") =
|
||||
Prop.forAll(ScriptGenerators.p2pkScriptSignature) { p2pkScriptSig =>
|
||||
|
|
|
@ -2,9 +2,8 @@ package org.bitcoins.core.protocol.script
|
|||
|
||||
import org.bitcoins.testkitcore.gen.{ScriptGenerators, WitnessGenerators}
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
import grizzled.slf4j.Logging
|
||||
|
||||
class ScriptWitnessSpec extends Properties("ScriptWitnessSpec") with Logging {
|
||||
class ScriptWitnessSpec extends Properties("ScriptWitnessSpec") {
|
||||
|
||||
property("serialization symmetry") = {
|
||||
Prop.forAll(WitnessGenerators.scriptWitness) { scriptWit =>
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package org.bitcoins.core.protocol.transaction
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.TransactionGenerators
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
/** Created by chris on 6/24/16.
|
||||
*/
|
||||
class TransactionInputSpec
|
||||
extends Properties("TransactionInputSpec")
|
||||
with Logging {
|
||||
class TransactionInputSpec extends Properties("TransactionInputSpec") {
|
||||
|
||||
property("Serialization symmetry") = {
|
||||
Prop.forAllNoShrink(TransactionGenerators.input) { input =>
|
||||
|
|
|
@ -28,10 +28,6 @@ class TransactionTest extends BitcoinSUnitTest {
|
|||
it must "have serialization symmetry" in {
|
||||
forAll(TransactionGenerators.transaction) { tx =>
|
||||
val result = Transaction(tx.hex) == tx
|
||||
if (!result) {
|
||||
logger.error(s"tx: $tx")
|
||||
logger.error("Incorrect tx hex: " + tx.hex)
|
||||
}
|
||||
assert(result)
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +320,6 @@ class TransactionTest extends BitcoinSUnitTest {
|
|||
val program = PreExecutionScriptProgram(txSigComponent)
|
||||
ScriptInterpreter.run(program) == ScriptOk
|
||||
} else {
|
||||
logger.error("Transaction does not pass CheckTransaction()")
|
||||
isValidTx
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package org.bitcoins.core.script.crypto
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
class HashTypeSpec extends Properties("HashTypeSpec") with Logging {
|
||||
class HashTypeSpec extends Properties("HashTypeSpec") {
|
||||
|
||||
property("serialization symmetry") = {
|
||||
Prop.forAll(NumberGenerator.int32s) { i32 =>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.core.serializers.p2p.messages
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.number.{UInt32, UInt64}
|
||||
import org.bitcoins.core.protocol.CompactSizeUInt
|
||||
import org.bitcoins.core.util.BytesUtil
|
||||
|
@ -9,7 +8,7 @@ import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
|||
|
||||
/** Created by chris on 7/5/16.
|
||||
*/
|
||||
class RawHeadersMessageSerializerTest extends BitcoinSUnitTest with Logging {
|
||||
class RawHeadersMessageSerializerTest extends BitcoinSUnitTest {
|
||||
|
||||
//from this example
|
||||
//https://bitcoin.org/en/developer-reference#headers
|
||||
|
@ -45,7 +44,6 @@ class RawHeadersMessageSerializerTest extends BitcoinSUnitTest with Logging {
|
|||
"020100000043497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000bac8b0fa927c0ac8234287e33c5f74d38d354820e24756ad709d7038fc5f31f020e7494dffff001d03e4b672000100000006128e87be8b1b4dea47a7247d5528d2702c96826c7a648497e773b800000000e241352e3bec0a95a6217e10c3abb54adfa05abb12c126695595580fb92e222032e7494dffff001d00d2353400"
|
||||
val headersMsg = RawHeadersMessageSerializer.read(hex)
|
||||
val first = headersMsg.headers.head
|
||||
logger.debug("Headers: " + headersMsg.headers)
|
||||
first.previousBlockHash.hex must be(
|
||||
BytesUtil.flipEndianness(
|
||||
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"))
|
||||
|
@ -55,7 +53,6 @@ class RawHeadersMessageSerializerTest extends BitcoinSUnitTest with Logging {
|
|||
first.merkleRootHash.hex must be(
|
||||
BytesUtil.flipEndianness(
|
||||
"f0315ffc38709d70ad5647e22048358dd3745f3ce3874223c80a7c92fab0c8ba"))
|
||||
logger.debug("Second header: " + headersMsg.headers(1))
|
||||
val second = headersMsg.headers(1)
|
||||
second.previousBlockHash.hex must be(
|
||||
BytesUtil.flipEndianness(
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.bitcoins.core.util
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.testkitcore.util.BitcoinSJvmTest
|
||||
import org.scalatest.compatible.Assertion
|
||||
|
||||
import scala.concurrent._
|
||||
|
||||
class FutureUtilTest extends BitcoinSJvmTest with Logging {
|
||||
class FutureUtilTest extends BitcoinSJvmTest {
|
||||
it must "execute futures sequentially in the correct order" in {
|
||||
|
||||
val assertionP = Promise[Assertion]()
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.bitcoins.core.util
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.number.UInt8
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
/** Created by chris on 6/20/16.
|
||||
*/
|
||||
class NumberUtilSpec extends Properties("NumberUtilSpec") with Logging {
|
||||
class NumberUtilSpec extends Properties("NumberUtilSpec") {
|
||||
|
||||
property("Serialization symmetry for BigInt") =
|
||||
Prop.forAll(NumberGenerator.bigInts) { bigInt: BigInt =>
|
||||
|
|
|
@ -16,7 +16,6 @@ class BouncyCastleSecp256k1Test extends BitcoinSUnitTest {
|
|||
CryptoContext.default match {
|
||||
case CryptoContext.LibSecp256k1 => super.withFixture(test)
|
||||
case CryptoContext.BouncyCastle | CryptoContext.BCrypto =>
|
||||
logger.warn(s"Test ${test.name} skipped as Secp256k1 is not available.")
|
||||
Succeeded
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,7 +310,9 @@ object Deps {
|
|||
val bitcoindRpc = List(
|
||||
Compile.akkaHttp,
|
||||
Compile.akkaStream,
|
||||
Compile.typesafeConfig
|
||||
Compile.typesafeConfig,
|
||||
Compile.slf4j,
|
||||
Compile.grizzledSlf4j
|
||||
)
|
||||
|
||||
def bitcoindRpcTest = Def.setting {
|
||||
|
@ -383,7 +385,8 @@ object Deps {
|
|||
Compile.akkaHttp,
|
||||
Compile.akkaStream,
|
||||
Compile.playJson,
|
||||
Compile.slf4j
|
||||
Compile.slf4j,
|
||||
Compile.grizzledSlf4j
|
||||
)
|
||||
|
||||
def eclairRpcTest = Def.setting {
|
||||
|
@ -416,7 +419,9 @@ object Deps {
|
|||
Compile.logback,
|
||||
Compile.slick,
|
||||
Compile.slickHikari,
|
||||
Compile.sqlite
|
||||
Compile.sqlite,
|
||||
Compile.slf4j,
|
||||
Compile.grizzledSlf4j
|
||||
)
|
||||
|
||||
val nodeTest = Def.setting {
|
||||
|
@ -510,9 +515,4 @@ object Deps {
|
|||
Compile.slf4j,
|
||||
Compile.grizzledSlf4j
|
||||
)
|
||||
|
||||
val asyncUtils = List(
|
||||
Compile.slf4j,
|
||||
Compile.grizzledSlf4j
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.testkitcore.gen
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.consensus.Consensus
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits}
|
||||
|
@ -35,7 +34,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
|
|||
import scala.concurrent.duration.DurationInt
|
||||
|
||||
//TODO: Need to provide generators for [[NonStandardScriptSignature]] and [[NonStandardScriptPubKey]]
|
||||
sealed abstract class ScriptGenerators extends Logging {
|
||||
sealed abstract class ScriptGenerators {
|
||||
val timeout = 30.seconds
|
||||
val defaultMaxDepth: Int = 2
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.testkitcore.gen
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.currency._
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
|
@ -15,7 +14,7 @@ import org.scalacheck.Gen
|
|||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
object TransactionGenerators extends Logging {
|
||||
object TransactionGenerators {
|
||||
|
||||
/** Responsible for generating [[org.bitcoins.core.protocol.transaction.TransactionOutPoint TransactionOutPoint]] */
|
||||
def outPoint: Gen[TransactionOutPoint] =
|
||||
|
|
|
@ -9,11 +9,10 @@ import org.bitcoins.core.protocol.transaction._
|
|||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.ECPrivateKey
|
||||
import org.scalacheck.Gen
|
||||
import grizzled.slf4j.Logging
|
||||
|
||||
/** Created by chris on 11/28/16.
|
||||
*/
|
||||
sealed abstract class WitnessGenerators extends Logging {
|
||||
sealed abstract class WitnessGenerators {
|
||||
|
||||
/** Generates a random [[org.bitcoins.core.protocol.script.ScriptWitness]] */
|
||||
def scriptWitness: Gen[ScriptWitness] = {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.testkitcore.util
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.asyncutil.AsyncUtil
|
||||
import org.bitcoins.core.config.{NetworkParameters, RegTest}
|
||||
import org.bitcoins.core.protocol.blockchain.ChainParams
|
||||
|
@ -25,8 +24,7 @@ trait BaseAsyncTest
|
|||
with BeforeAndAfterAll
|
||||
with Matchers
|
||||
with ScalaCheckPropertyChecks
|
||||
with AsyncTimeLimitedTests
|
||||
with Logging { this: AsyncTestSuite =>
|
||||
with AsyncTimeLimitedTests { this: AsyncTestSuite =>
|
||||
|
||||
implicit def np: NetworkParameters = RegTest
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.testkitcore.util
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.scalacheck.Shrink
|
||||
import org.scalactic.anyvals.PosInt
|
||||
import org.scalatest.concurrent.TimeLimitedTests
|
||||
|
@ -16,8 +15,7 @@ abstract class BitcoinSUnitTest
|
|||
extends AnyFlatSpec
|
||||
with Matchers
|
||||
with ScalaCheckPropertyChecks
|
||||
with TimeLimitedTests
|
||||
with Logging {
|
||||
with TimeLimitedTests {
|
||||
|
||||
override val timeLimit: Span = 120.seconds
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bitcoins.testkitcore.util
|
||||
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.crypto.ECPrivateKeyUtil
|
||||
import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits}
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
|
@ -11,7 +10,7 @@ import org.bitcoins.crypto.{DoubleSha256Digest, ECPublicKey}
|
|||
|
||||
/** Created by chris on 2/12/16.
|
||||
*/
|
||||
trait TransactionTestUtil extends Logging {
|
||||
trait TransactionTestUtil {
|
||||
|
||||
/** Raw multisignature script pub key output
|
||||
* @return
|
||||
|
@ -124,7 +123,6 @@ trait TransactionTestUtil extends Logging {
|
|||
TransactionOutput) = {
|
||||
val spendingTx = TestUtil.simpleTransaction
|
||||
val creditingTx = TestUtil.parentSimpleTransaction
|
||||
logger.info("Crediting transaction: " + creditingTx)
|
||||
val creditingOutput = TestUtil.parentSimpleTransaction.outputs(
|
||||
spendingTx.inputs.head.previousOutput.vout.toInt)
|
||||
//make sure the outpoint index and the outpoint txid are correct
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.bitcoins.testkit.util
|
|||
import akka.actor.ActorSystem
|
||||
import akka.testkit.TestKit
|
||||
import akka.util.Timeout
|
||||
import grizzled.slf4j.Logging
|
||||
import org.bitcoins.core.config.NetworkParameters
|
||||
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
|
||||
import org.bitcoins.testkitcore.util.BaseAsyncTest
|
||||
|
@ -14,7 +15,8 @@ import scala.concurrent.ExecutionContext
|
|||
/** A bitcoin-s async test trait, that uses akka's actor system
|
||||
* execution context to run the scalatest test suites
|
||||
*/
|
||||
trait BitcoinSAkkaAsyncTest extends BaseAsyncTest { this: AsyncTestSuite =>
|
||||
trait BitcoinSAkkaAsyncTest extends BaseAsyncTest with Logging {
|
||||
this: AsyncTestSuite =>
|
||||
implicit lazy val akkaTimeout = Timeout(duration)
|
||||
|
||||
implicit val system: ActorSystem = {
|
||||
|
|
Loading…
Add table
Reference in a new issue