Skip to content

Commit

Permalink
Refactor old test cases to use BitcoinSUnitTest (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and Christewart committed Oct 20, 2019
1 parent d141508 commit 089bb2b
Show file tree
Hide file tree
Showing 106 changed files with 210 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.bitcoins.core.number.UInt32
import org.bitcoins.core.protocol.blockchain.Block
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionOutPoint}
import org.bitcoins.core.util.{BitcoinSLogger, CryptoUtil}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits._
import org.bitcoins.testkit.util.BitcoinSUnitTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.config

import org.bitcoins.core.util.BitcoinSUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 6/10/16.
*/
class NetworkParametersTest extends FlatSpec with MustMatchers {
class NetworkParametersTest extends BitcoinSUnitTest {

//test case answers are from this link
//https://en.bitcoin.it/wiki/Protocol_documentation#Common_structures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import org.bitcoins.core.crypto.DoubleSha256Digest
import org.bitcoins.core.protocol.blockchain.{Block, MainNetChainParams}
import org.bitcoins.core.protocol.transaction.{Transaction, WitnessTransaction}
import org.bitcoins.core.util.{BitcoinSUtil, CryptoUtil}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

import scala.util.Try

/**
* Created by chris on 5/24/16.
*/
class MerkleTest extends FlatSpec with MustMatchers {
class MerkleTest extends BitcoinSUnitTest {

"Merkle" must "compute the merkle root for the genesis block" in {
Merkle.computeBlockMerkleRoot(MainNetChainParams.genesisBlock).hex must be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.crypto

import org.bitcoins.core.util.NumberUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 3/23/16.
*/
class DERSignatureUtilTest extends FlatSpec with MustMatchers {
class DERSignatureUtilTest extends BitcoinSUnitTest {

val p2shSignature = ECDigitalSignature(
"304402205b7d2c2f177ae76cfbbf14d589c113b0b35db753d305d5562dd0b61cbf366cfb02202e56f93c4f08a27f986cd424ffc48a462c3202c4902104d4d0ff98ed28f4bf8001")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.bitcoins.core.crypto

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 3/31/16.
*/
class TransactionSignatureCheckerResultTest extends FlatSpec with MustMatchers {
class TransactionSignatureCheckerResultTest extends BitcoinSUnitTest {

"TransactionSignatureCheckerResult" must "have isValid set correctly for the different outcomes of TransactionSignatureCheckerResult" in {
SignatureValidationErrorIncorrectSignatures.isValid must be(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.bitcoins.core.crypto

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 2/29/16.
*/
class TransactionSignatureCheckerTest extends FlatSpec with MustMatchers {}
class TransactionSignatureCheckerTest extends BitcoinSUnitTest {}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.number

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 6/15/16.
*/
class Int32Test extends FlatSpec with MustMatchers {
class Int32Test extends BitcoinSUnitTest {

"Int32" must "create the number zero" in {
val int32 = Int32(ByteVector.low(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.number

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 6/15/16.
*/
class Int64Test extends FlatSpec with MustMatchers {
class Int64Test extends BitcoinSUnitTest {

"Int64" must "represent the nubmer zero" in {
val int64 = Int64(ByteVector.low(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.number

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 6/14/16.
*/
class UInt32Test extends FlatSpec with MustMatchers {
class UInt32Test extends BitcoinSUnitTest {

"UInt32" must "create the number zero as an unsigned 32 bit integer" in {
val zero = UInt32(ByteVector(0x0.toByte))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.number

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 6/15/16.
*/
class UInt64Test extends FlatSpec with MustMatchers {
class UInt64Test extends BitcoinSUnitTest {

"UInt64" must "hold the number 0" in {
val uInt64 = UInt64(ByteVector.low(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.bitcoins.core.number

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

class UInt8Test extends FlatSpec with MustMatchers {
class UInt8Test extends BitcoinSUnitTest {

"UInt8" must "convert a byte to a UInt8 correctly" in {
UInt8.toUInt8(0.toByte) must be(UInt8.zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import org.bitcoins.core.config.TestNet3
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.util.{BitcoinSUtil, CryptoUtil}
import org.bitcoins.testkit.node.NodeTestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import org.bitcoins.core.config.MainNet
import scala.util.Random
import scodec.bits.ByteVector

class NetworkHeaderTest extends FlatSpec with MustMatchers {
class NetworkHeaderTest extends BitcoinSUnitTest {

"MessageHeader" must "must create a message header for a message" in {
val messageHeader = NetworkHeader(TestNet3, NodeTestUtil.versionMessage)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.policy

import org.bitcoins.core.script.flag._
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 5/2/16.
*/
class PolicyTest extends FlatSpec with MustMatchers {
class PolicyTest extends BitcoinSUnitTest {

"Policy" must "determine what the mandatory script verify flags are" in {
Policy.mandatoryScriptVerifyFlags must be(Seq(ScriptVerifyP2SH))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.protocol

import org.bitcoins.core.util.{Base58, TestUtil}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 3/30/16.
*/
class AddressFactoryTest extends FlatSpec with MustMatchers {
class AddressFactoryTest extends BitcoinSUnitTest {

"AddressFactory" must "create an address from a base58 encoded string" in {
Address(TestUtil.bitcoinAddress.get.value) must be(TestUtil.bitcoinAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package org.bitcoins.core.protocol
import org.bitcoins.core.config.{MainNet, RegTest, TestNet3}
import org.bitcoins.core.crypto.Sha256Hash160Digest
import org.bitcoins.core.protocol.script.ScriptPubKey
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

import scala.util.{Failure, Success, Try}

class BitcoinAddressTest extends FlatSpec with MustMatchers {
class BitcoinAddressTest extends BitcoinSUnitTest {

"3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy" must "be a valid bitcoin address" in {
val address = "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.bitcoins.core.protocol

import org.bitcoins.core.config.{MainNet, RegTest, TestNet3}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

import scala.util.Success

class BtcHumanReadablePartTest extends FlatSpec with MustMatchers {
class BtcHumanReadablePartTest extends BitcoinSUnitTest {
import BtcHumanReadablePart._

"HumanReadablePart" must "match the correct hrp with the correct string" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package org.bitcoins.core.protocol
import org.bitcoins.core.number.UInt64
import org.bitcoins.core.protocol.script.ScriptSignature
import org.bitcoins.core.util.{BitcoinSUtil, TestUtil}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 7/26/15.
*/
class CompactSizeUIntTest extends FlatSpec with MustMatchers {
class CompactSizeUIntTest extends BitcoinSUnitTest {

"CompactSizeUInt" must "serialize a VarInt with size 1 correctly" in {
val varInt = CompactSizeUInt(UInt64(139), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.bitcoins.core.crypto.{DoubleSha256Digest, ECPublicKey}
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
import org.bitcoins.core.util.BitcoinSUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 8/9/16.
*/
class MerkleBlockTests extends FlatSpec with MustMatchers {
class MerkleBlockTests extends BitcoinSUnitTest {

"MerkleBlocks" must "create merkle block from a block and a bloom filter" in {
val block = Block(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import org.bitcoins.core.bloom.{BloomFilter, BloomUpdateAll}
import org.bitcoins.core.crypto.DoubleSha256Digest
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.util.{BitcoinSUtil, Leaf, Node}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.BitVector

/**
* Created by chris on 8/9/16.
*/
class PartialMerkleTreeTests extends FlatSpec with MustMatchers {
class PartialMerkleTreeTests extends BitcoinSUnitTest {
"PartialMerkleTree" must "from a list of txs and a bit indicating if the tx matched the filter" in {
//https://github.com/bitcoin/bitcoin/blob/master/src/test/bloom_tests.cpp#L185
val block = Block(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package org.bitcoins.core.protocol.ln
import org.bitcoins.core.config.{MainNet, RegTest, TestNet3}
import org.bitcoins.core.protocol.ln.LnParams._
import org.bitcoins.core.protocol.ln.currency.{LnCurrencyUnits, MilliBitcoins}
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

import scala.util.Try

class LnHumanReadablePartTest extends FlatSpec with MustMatchers {
class LnHumanReadablePartTest extends BitcoinSUnitTest {
val mBtc = MilliBitcoins(1)
val mBtcOpt = Some(mBtc)
it must "match the correct hrp with the correct network" in {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.bitcoins.core.protocol.ln

import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

class ShortChannelIdTest extends FlatSpec with MustMatchers {
class ShortChannelIdTest extends BitcoinSUnitTest {

it must "convert short channel id to and from human readable form" in {
// BOLT example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import org.bitcoins.core.script.crypto.{OP_CHECKSIG, OP_HASH160}
import org.bitcoins.core.script.locktime.OP_CHECKLOCKTIMEVERIFY
import org.bitcoins.core.script.stack.{OP_DROP, OP_DUP}
import org.bitcoins.core.util.TestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by tom on 9/21/16.
*/
class CLTVScriptPubKeyTest extends FlatSpec with MustMatchers {
class CLTVScriptPubKeyTest extends BitcoinSUnitTest {

val expectedAsm: Seq[ScriptToken] =
List(OP_DUP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import org.bitcoins.core.script.crypto.{OP_CHECKSIG, OP_HASH160}
import org.bitcoins.core.script.locktime.OP_CHECKSEQUENCEVERIFY
import org.bitcoins.core.script.stack.{OP_DROP, OP_DUP}
import org.bitcoins.core.util.TestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by tom on 9/21/16.
*/
class CSVScriptPubKeyTest extends FlatSpec with MustMatchers {
class CSVScriptPubKeyTest extends BitcoinSUnitTest {

val expectedAsm: Seq[ScriptToken] =
List(OP_DUP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package org.bitcoins.core.protocol.script

import org.bitcoins.core.crypto.ECPublicKey
import org.bitcoins.core.util.TestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 3/8/16.
*/
class MultiSignatureScriptPubKeyTest extends FlatSpec with MustMatchers {
class MultiSignatureScriptPubKeyTest extends BitcoinSUnitTest {

"MultiSignatureScriptPubKey" must "derive the amount of required signatures from a multisignature script" in {
val multiSigRawScriptPubKeyHex = TestUtil.multiSigScriptPubKeyHex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.bitcoins.core.protocol.script

import org.bitcoins.core.util.TransactionTestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

/**
* Created by chris on 3/8/16.
*/
class MultiSignatureScriptSignatureTest extends FlatSpec with MustMatchers {
class MultiSignatureScriptSignatureTest extends BitcoinSUnitTest {

"MultiSignatureScriptSignature" must "find all of the digital signatures for a multisignature scriptSig" in {
val (spendingTx, inputIndex, _, _) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package org.bitcoins.core.protocol.script

import org.bitcoins.testkit.core.gen.CryptoGenerators
import org.bitcoins.testkit.Implicits._
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest

class P2PKHScriptPubKeyTest extends FlatSpec with MustMatchers {
class P2PKHScriptPubKeyTest extends BitcoinSUnitTest {

"P2PKHScriptPubKey" must "return the pubkeyhash" in {
val hash = CryptoGenerators.sha256Hash160Digest.sampleSome
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package org.bitcoins.core.protocol.script
import org.bitcoins.core.crypto.ECDigitalSignature
import org.bitcoins.core.script.crypto.HashType
import org.bitcoins.core.util.TestUtil
import org.scalatest.{FlatSpec, MustMatchers}
import org.bitcoins.testkit.util.BitcoinSUnitTest
import scodec.bits.ByteVector

/**
* Created by chris on 4/1/16.
*/
class P2PKHScriptSignatureTest extends FlatSpec with MustMatchers {
class P2PKHScriptSignatureTest extends BitcoinSUnitTest {

"P2PKHScriptSignature" must "be able to identify it's own hash type" in {
val p2pkhScriptSig = TestUtil.p2pkhScriptSig match {
Expand Down
Loading

0 comments on commit 089bb2b

Please sign in to comment.