mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-13 11:35:40 +01:00
Merge 4acc15ac62
into 2dd140ad59
This commit is contained in:
commit
6a2d088b87
13 changed files with 129 additions and 71 deletions
2
.github/workflows/Mac_2.13_RPC_Tests.yml
vendored
2
.github/workflows/Mac_2.13_RPC_Tests.yml
vendored
|
@ -32,4 +32,4 @@ jobs:
|
|||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-rpc-tests-cache
|
||||
- name: run tests
|
||||
run: sbt coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls lndRpcTest/test esploraTest/test
|
||||
run: sbt coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls lndRpcTest/test eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls esploraTest/test
|
||||
|
|
|
@ -2,11 +2,11 @@ package org.bitcoins.commons.config
|
|||
|
||||
import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions}
|
||||
import org.bitcoins.commons.util.BitcoinSLogger
|
||||
import org.bitcoins.core.config._
|
||||
import org.bitcoins.core.config.*
|
||||
import org.bitcoins.core.protocol.blockchain.BitcoinChainParams
|
||||
import org.bitcoins.core.util.StartStopAsync
|
||||
import org.bitcoins.core.util.{EnvUtil, StartStopAsync}
|
||||
|
||||
import java.nio.file._
|
||||
import java.nio.file.*
|
||||
import scala.concurrent.Future
|
||||
import scala.jdk.CollectionConverters.CollectionHasAsScala
|
||||
import scala.util.Properties
|
||||
|
@ -236,8 +236,37 @@ object AppConfig extends BitcoinSLogger {
|
|||
* TODO: use different directories on Windows and Mac, should probably mimic
|
||||
* what Bitcoin Core does
|
||||
*/
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_DATADIR: Path =
|
||||
Paths.get(Properties.userHome, ".bitcoin-s")
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_DATADIR: Path = {
|
||||
val base = Paths.get(Properties.userHome, ".bitcoin-s")
|
||||
if (EnvUtil.isLinux) {
|
||||
base
|
||||
} else if (EnvUtil.isMac) {
|
||||
// migration code to use proper location on mac
|
||||
val full = Paths
|
||||
.get(Properties.userHome)
|
||||
.resolve("Library")
|
||||
.resolve("Application Support")
|
||||
.resolve("bitcoin-s")
|
||||
if (Files.exists(full)) {
|
||||
full
|
||||
} else {
|
||||
if (Files.exists(base)) {
|
||||
// just use old directory for now
|
||||
// we will eventually migrate this in the future
|
||||
base
|
||||
} else {
|
||||
// fresh install, so use the proper spot
|
||||
full
|
||||
}
|
||||
}
|
||||
} else if (EnvUtil.isWindows) {
|
||||
// windows
|
||||
base
|
||||
} else {
|
||||
sys.error(s"Unsupported os=${EnvUtil.osName}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_CONF_FILE: String =
|
||||
"bitcoin-s.conf"
|
||||
|
|
|
@ -41,7 +41,7 @@ TaskKeys.downloadBitcoind := {
|
|||
}
|
||||
|
||||
implicit val ec = scala.concurrent.ExecutionContext.global
|
||||
val downloads = versions.map { version =>
|
||||
val downloads = Future.traverse(versions) { version =>
|
||||
val (platform, suffix) = getPlatformAndSuffix(version)
|
||||
val archiveLocation = binaryDir resolve s"$version.$suffix"
|
||||
val location =
|
||||
|
@ -124,11 +124,16 @@ TaskKeys.downloadBitcoind := {
|
|||
val success = hash.equalsIgnoreCase(expectedHash(version))
|
||||
if (success) {
|
||||
logger.info(s"Download complete and verified, unzipping result")
|
||||
|
||||
val extractCommand =
|
||||
s"tar -xzf $archiveLocation --directory $binaryDir"
|
||||
logger.info(s"Extracting archive with command: $extractCommand")
|
||||
extractCommand.!!
|
||||
val cmds = Vector(
|
||||
"tar",
|
||||
"-xzf",
|
||||
archiveLocation.toString,
|
||||
"--directory",
|
||||
binaryDir.toString
|
||||
)
|
||||
//val extractCommand = s"""tar -xzf \"$archiveLocation\" --directory \"$binaryDir\""""
|
||||
logger.info(s"Extracting archive with command: $cmds")
|
||||
cmds.!!
|
||||
} else {
|
||||
Files.deleteIfExists(expectedEndLocation)
|
||||
logger.error(
|
||||
|
@ -146,5 +151,5 @@ TaskKeys.downloadBitcoind := {
|
|||
}
|
||||
|
||||
//timeout if we cannot download in 5 minutes
|
||||
Await.result(Future.sequence(downloads), 5.minutes)
|
||||
Await.result(downloads, 2.minutes)
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ trait Client
|
|||
logger.debug(
|
||||
s"starting bitcoind with datadir ${local.datadir} and binary path $binaryPath"
|
||||
)
|
||||
|
||||
println(s"cmd=$cmd")
|
||||
cmd
|
||||
|
||||
}
|
||||
|
|
|
@ -72,10 +72,15 @@ TaskKeys.downloadCLightning := {
|
|||
val success = hash.equalsIgnoreCase(expectedHash)
|
||||
if (hash.equalsIgnoreCase(expectedHash)) {
|
||||
logger.info(s"Download complete and verified, unzipping result")
|
||||
|
||||
val extractCommand = s"tar -xf $archiveLocation --directory $versionDir"
|
||||
logger.info(s"Extracting archive with command: $extractCommand")
|
||||
extractCommand.!!
|
||||
val cmds = Vector(
|
||||
"tar",
|
||||
"-xf",
|
||||
archiveLocation.toString,
|
||||
"--directory",
|
||||
versionDir.toString
|
||||
)
|
||||
logger.info(s"Extracting archive with command: $cmds")
|
||||
cmds.!!
|
||||
} else {
|
||||
logger.error(
|
||||
s"Downloaded invalid version of c-lightning, got $hash, expected $expectedHash")
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.bitcoins.core.util
|
|||
import scala.util.Properties
|
||||
|
||||
object EnvUtil {
|
||||
private val osName = System.getProperty("os.name")
|
||||
lazy val osName: String = System.getProperty("os.name")
|
||||
|
||||
lazy val isLinux: Boolean = osName.startsWith("Linux")
|
||||
|
||||
|
|
|
@ -52,10 +52,14 @@ TaskKeys.downloadEclair := {
|
|||
val success = hash.equalsIgnoreCase(expectedHash)
|
||||
if (success) {
|
||||
logger.info(s"Download complete and verified, unzipping result")
|
||||
|
||||
val extractCommand = s"unzip $archiveLocation -d $versionDir"
|
||||
logger.info(s"Extracting archive with command: $extractCommand")
|
||||
extractCommand.!!
|
||||
val cmds = Vector(
|
||||
"unzip",
|
||||
archiveLocation.toString,
|
||||
"-d",
|
||||
versionDir.toString
|
||||
)
|
||||
logger.info(s"Extracting archive with command: $cmds")
|
||||
cmds.!!
|
||||
} else {
|
||||
Files.deleteIfExists(versionDir)
|
||||
logger.error(
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.pekko.http.scaladsl.model.{
|
|||
import org.apache.pekko.stream.scaladsl.{Flow, Sink, Source}
|
||||
import org.apache.pekko.util.ByteString
|
||||
import org.bitcoins.asyncutil.AsyncUtil
|
||||
import org.bitcoins.commons.jsonmodels.eclair._
|
||||
import org.bitcoins.commons.serializers.JsonReaders._
|
||||
import org.bitcoins.commons.jsonmodels.eclair.*
|
||||
import org.bitcoins.commons.serializers.JsonReaders.*
|
||||
import org.bitcoins.commons.util.NativeProcessFactory
|
||||
import org.bitcoins.core.currency.{CurrencyUnit, Satoshis}
|
||||
import org.bitcoins.core.protocol.ln.channel.{
|
||||
|
@ -38,14 +38,14 @@ import org.bitcoins.core.protocol.ln.routing.{ChannelRoute, NodeRoute, Route}
|
|||
import org.bitcoins.core.protocol.ln.{LnInvoice, LnParams, PaymentPreimage}
|
||||
import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||
import org.bitcoins.core.protocol.{Address, BitcoinAddress}
|
||||
import org.bitcoins.core.util.{BytesUtil, StartStopAsync}
|
||||
import org.bitcoins.core.util.{BytesUtil, EnvUtil, StartStopAsync}
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerByte
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, Sha256Digest}
|
||||
import org.bitcoins.eclair.rpc.api._
|
||||
import org.bitcoins.eclair.rpc.api.*
|
||||
import org.bitcoins.eclair.rpc.config.EclairInstance
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion
|
||||
import org.bitcoins.tor.Socks5ClientTransport
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.json.*
|
||||
|
||||
import java.io.File
|
||||
import java.net.InetSocketAddress
|
||||
|
@ -823,7 +823,7 @@ class EclairRpcClient(
|
|||
// default to provided binary
|
||||
case (Some(binary), _) =>
|
||||
if (binary.exists) {
|
||||
binary.toPath.toAbsolutePath.toString
|
||||
binary.getAbsolutePath
|
||||
} else {
|
||||
throw new NoSuchFileException(
|
||||
s"Given binary ($binary) does not exist!"
|
||||
|
@ -833,7 +833,7 @@ class EclairRpcClient(
|
|||
val eclairBinDir =
|
||||
s"eclair-node-${EclairRpcClient.version}-${EclairRpcClient.commit}${File.separator}bin${File.separator}"
|
||||
val eclairV =
|
||||
if (sys.props("os.name").toLowerCase.contains("windows"))
|
||||
if (EnvUtil.isWindows)
|
||||
eclairBinDir + "eclair-node.bat"
|
||||
else
|
||||
eclairBinDir + "eclair-node.sh"
|
||||
|
@ -866,6 +866,8 @@ class EclairRpcClient(
|
|||
case Some(logback) => base.appended(logback)
|
||||
case None => base
|
||||
}
|
||||
|
||||
println(s"cmd=$cmd")
|
||||
cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -87,10 +87,15 @@ TaskKeys.downloadLnd := {
|
|||
val success = hash.equalsIgnoreCase(expectedHash)
|
||||
if (success) {
|
||||
logger.info(s"Download complete and verified, unzipping result")
|
||||
|
||||
val extractCommand = s"tar -xzf $archiveLocation --directory $binaryDir"
|
||||
logger.info(s"Extracting archive with command: $extractCommand")
|
||||
extractCommand.!!
|
||||
val cmds = Vector(
|
||||
"tar",
|
||||
"-xzf",
|
||||
archiveLocation.toString,
|
||||
"--directory",
|
||||
binaryDir.toString
|
||||
)
|
||||
logger.info(s"Extracting archive with command: $cmds")
|
||||
cmds.!!
|
||||
} else {
|
||||
Files.deleteIfExists(versionDir)
|
||||
logger.error(
|
||||
|
|
|
@ -2,28 +2,15 @@
|
|||
import com.typesafe.sbt.SbtNativePackager.Docker
|
||||
import com.typesafe.sbt.SbtNativePackager.autoImport.packageName
|
||||
|
||||
import java.nio.file.Paths
|
||||
import com.typesafe.sbt.packager.Keys.{
|
||||
daemonUser,
|
||||
daemonUserUid,
|
||||
dockerAlias,
|
||||
dockerAliases,
|
||||
dockerCommands,
|
||||
dockerExposedVolumes,
|
||||
dockerRepository,
|
||||
dockerUpdateLatest,
|
||||
maintainer
|
||||
}
|
||||
import java.nio.file.{Files, Paths}
|
||||
import com.typesafe.sbt.packager.Keys.{daemonUser, daemonUserUid, dockerAlias, dockerAliases, dockerCommands, dockerExposedVolumes, dockerRepository, dockerUpdateLatest, maintainer}
|
||||
import com.typesafe.sbt.packager.archetypes.jlink.JlinkPlugin.autoImport.JlinkIgnore
|
||||
import com.typesafe.sbt.packager.docker.{Cmd, DockerChmodType}
|
||||
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.{
|
||||
dockerAdditionalPermissions,
|
||||
dockerBaseImage
|
||||
}
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.{dockerAdditionalPermissions, dockerBaseImage}
|
||||
import sbt.*
|
||||
import sbt.Keys.*
|
||||
import sbtprotoc.ProtocPlugin.autoImport.PB
|
||||
import sbtassembly.AssemblyKeys._
|
||||
import sbtassembly.AssemblyKeys.*
|
||||
import sbtdynver.DynVer
|
||||
|
||||
import scala.sys.process.Process
|
||||
|
@ -243,8 +230,38 @@ object CommonSettings {
|
|||
)
|
||||
}
|
||||
|
||||
lazy val binariesPath =
|
||||
Paths.get(Properties.userHome, ".bitcoin-s", "binaries")
|
||||
lazy val binariesPath = {
|
||||
val base = Paths.get(Properties.userHome, ".bitcoin-s", "binaries")
|
||||
if (EnvUtil.isLinux) {
|
||||
base
|
||||
} else if (EnvUtil.isMac) {
|
||||
// migration code to use proper location on mac
|
||||
val full = Paths
|
||||
.get(Properties.userHome)
|
||||
.resolve("Library")
|
||||
.resolve("Application Support")
|
||||
.resolve("bitcoin-s")
|
||||
.resolve("binaries")
|
||||
if (Files.exists(full)) {
|
||||
full
|
||||
} else {
|
||||
if (Files.exists(base)) {
|
||||
// just use old directory for now
|
||||
// we will eventually migrate this in the future
|
||||
base
|
||||
} else {
|
||||
// fresh install, so use the proper spot
|
||||
Files.createDirectories(full)
|
||||
full
|
||||
}
|
||||
}
|
||||
} else if (EnvUtil.isWindows) {
|
||||
// windows
|
||||
base
|
||||
} else {
|
||||
sys.error(s"Unsupported os=${EnvUtil.osName}")
|
||||
}
|
||||
}
|
||||
|
||||
lazy val cryptoJlinkIgnore = {
|
||||
Vector(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import scala.util.Properties
|
||||
|
||||
object EnvUtil {
|
||||
private val osName = System.getProperty("os.name")
|
||||
val osName = System.getProperty("os.name")
|
||||
|
||||
lazy val isLinux: Boolean = osName.startsWith("Linux")
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="OFF">
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
package org.bitcoins.testkit.util
|
||||
|
||||
import java.nio.file.{Path, Paths}
|
||||
import org.bitcoins.commons.config.AppConfig
|
||||
|
||||
import scala.util.Properties
|
||||
import java.nio.file.{Path}
|
||||
|
||||
object TestkitBinaries {
|
||||
|
||||
private val base: Path = Paths.get(".bitcoin-s", "binaries")
|
||||
private val base: Path = AppConfig.DEFAULT_BITCOIN_S_DATADIR
|
||||
.resolve("binaries")
|
||||
|
||||
/** The base directory where binaries needed in tests are located.
|
||||
*/
|
||||
lazy val baseBinaryDirectory: Path = {
|
||||
val home = Paths.get(Properties.userHome)
|
||||
fromRoot(home)
|
||||
}
|
||||
|
||||
/** Gives you an arbitrary root path, and then tacks on .bitcoin-s/binaries/
|
||||
* onto the end of it
|
||||
*/
|
||||
def fromRoot(path: Path): Path = {
|
||||
path.resolve(base)
|
||||
}
|
||||
lazy val baseBinaryDirectory: Path = base
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue