mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 18:02:54 +01:00
Tunes scoverage (#303)
This commit is contained in:
parent
8180a22377
commit
2b7212905a
@ -18,9 +18,21 @@ sealed abstract class NetworkParameters {
|
||||
chainParams.base58Prefix(Base58Type.ScriptAddress)
|
||||
def privateKey: ByteVector = chainParams.base58Prefix(Base58Type.SecretKey)
|
||||
|
||||
/**
|
||||
* @see [[https://github.com/bitcoin/bitcoin/blob/84d0fdce11709c8e26b9c450d47727ab36641437/src/chainparams.cpp Bitcoin Core]]
|
||||
* `chainparams.cpp nDefaultPort`
|
||||
*/
|
||||
def port: Int
|
||||
|
||||
/**
|
||||
* @see [[https://github.com/bitcoin/bitcoin/blob/bccb4d29a8080bf1ecda1fc235415a11d903a680/src/chainparamsbase.cpp Bitcoin Core]]
|
||||
* `chainparamsbase.cpp`
|
||||
*/
|
||||
def rpcPort: Int
|
||||
|
||||
// $COVERAGE-OFF$
|
||||
def name: String = chainParams.networkId
|
||||
// $COVERAGE-ON$
|
||||
|
||||
/** The seeds used to bootstrap the network */
|
||||
def dnsSeeds: Seq[String]
|
||||
@ -43,13 +55,26 @@ sealed abstract class BitcoinNetwork extends NetworkParameters {
|
||||
override def chainParams: BitcoinChainParams
|
||||
}
|
||||
|
||||
// $COVERAGE-OFF$
|
||||
sealed abstract class MainNet extends BitcoinNetwork {
|
||||
override def chainParams = MainNetChainParams
|
||||
override def chainParams: MainNetChainParams.type = MainNetChainParams
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def port = 8333
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def rpcPort = 8332
|
||||
//mainnet doesn't need to be specified like testnet or regtest
|
||||
override def name = ""
|
||||
override def dnsSeeds =
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def dnsSeeds: Seq[String] =
|
||||
Seq("seed.bitcoin.sipa.be",
|
||||
"dnsseed.bluematt.me",
|
||||
"dnsseed.bitcoin.dashjr.org",
|
||||
@ -57,6 +82,9 @@ sealed abstract class MainNet extends BitcoinNetwork {
|
||||
"bitseed.xf2.org",
|
||||
"seed.bitcoin.jonasschnelli.ch")
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def magicBytes = ByteVector(0xf9, 0xbe, 0xb4, 0xd9)
|
||||
|
||||
override def difficultyChangeThreshold: Int = 2016
|
||||
@ -65,13 +93,28 @@ sealed abstract class MainNet extends BitcoinNetwork {
|
||||
object MainNet extends MainNet
|
||||
|
||||
sealed abstract class TestNet3 extends BitcoinNetwork {
|
||||
override def chainParams = TestNetChainParams
|
||||
override def chainParams: TestNetChainParams.type = TestNetChainParams
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def port = 18333
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def rpcPort = 18332
|
||||
override def dnsSeeds =
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def dnsSeeds: Seq[String] =
|
||||
Seq("testnet-seed.bitcoin.petertodd.org",
|
||||
"testnet-seed.bluematt.me",
|
||||
"testnet-seed.bitcoin.schildbach.de")
|
||||
/*
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def magicBytes = ByteVector(0x0b, 0x11, 0x09, 0x07)
|
||||
|
||||
override def difficultyChangeThreshold: Int = 2016
|
||||
@ -80,21 +123,38 @@ sealed abstract class TestNet3 extends BitcoinNetwork {
|
||||
object TestNet3 extends TestNet3
|
||||
|
||||
sealed abstract class RegTest extends BitcoinNetwork {
|
||||
override def chainParams = RegTestNetChainParams
|
||||
override def chainParams: RegTestNetChainParams.type = RegTestNetChainParams
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def port = 18444
|
||||
override def rpcPort = TestNet3.rpcPort
|
||||
override def dnsSeeds = Nil
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def rpcPort = 18443
|
||||
|
||||
/**
|
||||
* There's no DNS seeds on regtest
|
||||
*/
|
||||
override def dnsSeeds: Nil.type = Nil
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
override def magicBytes = ByteVector(0xfa, 0xbf, 0xb5, 0xda)
|
||||
override def difficultyChangeThreshold: Int = 2016
|
||||
}
|
||||
|
||||
object RegTest extends RegTest
|
||||
// $COVERAGE-ON$
|
||||
|
||||
object Networks {
|
||||
val knownNetworks: Seq[NetworkParameters] = Seq(MainNet, TestNet3, RegTest)
|
||||
val secretKeyBytes = knownNetworks.map(_.privateKey)
|
||||
val p2pkhNetworkBytes = knownNetworks.map(_.p2pkhNetworkByte)
|
||||
val p2shNetworkBytes = knownNetworks.map(_.p2shNetworkByte)
|
||||
val secretKeyBytes: Seq[ByteVector] = knownNetworks.map(_.privateKey)
|
||||
val p2pkhNetworkBytes: Seq[ByteVector] = knownNetworks.map(_.p2pkhNetworkByte)
|
||||
val p2shNetworkBytes: Seq[ByteVector] = knownNetworks.map(_.p2shNetworkByte)
|
||||
|
||||
def bytesToNetwork: Map[ByteVector, NetworkParameters] = Map(
|
||||
MainNet.p2shNetworkByte -> MainNet,
|
||||
|
@ -30,7 +30,9 @@ sealed abstract class Sha1Digest extends HashDigest {
|
||||
|
||||
object Sha1Digest extends Factory[Sha1Digest] {
|
||||
private case class Sha1DigestImpl(bytes: ByteVector) extends Sha1Digest {
|
||||
// $COVERAGE-OFF$
|
||||
override def toString = s"Sha1DigestImpl($hex)"
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
override def fromBytes(bytes: ByteVector): Sha1Digest = Sha1DigestImpl(bytes)
|
||||
}
|
||||
@ -45,8 +47,10 @@ sealed abstract class Sha256Digest extends HashDigest {
|
||||
object Sha256Digest extends Factory[Sha256Digest] {
|
||||
private case class Sha256DigestImpl(bytes: ByteVector) extends Sha256Digest {
|
||||
require(bytes.length == 32,
|
||||
// $COVERAGE-OFF$
|
||||
"Sha256Digest must be 32 bytes in size, got: " + bytes.length)
|
||||
override def toString = s"Sha256DigestImpl($hex)"
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
override def fromBytes(bytes: ByteVector): Sha256Digest =
|
||||
Sha256DigestImpl(bytes)
|
||||
@ -63,8 +67,10 @@ object DoubleSha256Digest extends Factory[DoubleSha256Digest] {
|
||||
private case class DoubleSha256DigestImpl(bytes: ByteVector)
|
||||
extends DoubleSha256Digest {
|
||||
require(bytes.length == 32,
|
||||
// $COVERAGE-OFF$
|
||||
"DoubleSha256Digest must always be 32 bytes, got: " + bytes.length)
|
||||
override def toString = s"DoubleSha256DigestImpl($hex)"
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
override def fromBytes(bytes: ByteVector): DoubleSha256Digest =
|
||||
DoubleSha256DigestImpl(bytes)
|
||||
@ -82,8 +88,10 @@ object RipeMd160Digest extends Factory[RipeMd160Digest] {
|
||||
private case class RipeMd160DigestImpl(bytes: ByteVector)
|
||||
extends RipeMd160Digest {
|
||||
require(bytes.length == 20,
|
||||
// $COVERAGE-OFF$
|
||||
"RIPEMD160Digest must always be 20 bytes, got: " + bytes.length)
|
||||
override def toString = s"RipeMd160DigestImpl($hex)"
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
override def fromBytes(bytes: ByteVector): RipeMd160Digest =
|
||||
RipeMd160DigestImpl(bytes)
|
||||
@ -100,8 +108,10 @@ object Sha256Hash160Digest extends Factory[Sha256Hash160Digest] {
|
||||
private case class Sha256Hash160DigestImpl(bytes: ByteVector)
|
||||
extends Sha256Hash160Digest {
|
||||
require(bytes.length == 20,
|
||||
// $COVERAGE-OFF$
|
||||
"Sha256Hash160Digest must always be 20 bytes, got: " + bytes.length)
|
||||
override def toString = s"Sha256Hash160DigestImpl($hex)"
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
override def fromBytes(bytes: ByteVector): Sha256Hash160Digest =
|
||||
Sha256Hash160DigestImpl(bytes)
|
||||
|
Loading…
Reference in New Issue
Block a user