mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-15 12:20:06 +01:00
Adds Ammonite REPL in test scope (#323)
This commit is contained in:
parent
2cb08b8218
commit
7de78bb0fc
3 changed files with 85 additions and 16 deletions
39
README.md
39
README.md
|
@ -31,6 +31,45 @@
|
|||
|
||||
10. `secp256k1jni` - JNI (Java Native Interface) for [secp256k1](https://github.com/bitcoin-core/secp256k1), a optimized C library for EC operations on curve secp256k1. It has support for a wide range of cryptographic operations used in the Bitcoin protocol. Fore more information please read [`secp256k1jni/README.md`](secp256k1jni/README.md)
|
||||
|
||||
## REPL
|
||||
|
||||
In any given sub project, it's possible to open a REPL session. This session has both main and test sources from Bitcoin-S available, as well as all dependencies for the given sub project. To do this:
|
||||
|
||||
```scala
|
||||
// core project
|
||||
$ sbt coreTest/test:run // we do coreTest instead of core to have all test sources available
|
||||
|
||||
// this works as well
|
||||
$ sbt
|
||||
> project coreTest
|
||||
> amm
|
||||
...
|
||||
Loading...
|
||||
Compiling (synthetic)/ammonite/predef/interpBridge.sc
|
||||
Compiling (synthetic)/ammonite/predef/replBridge.sc
|
||||
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
|
||||
Welcome to the Ammonite Repl 1.6.2
|
||||
(Scala 2.12.7 Java 1.8.0_191)
|
||||
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
|
||||
@ import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
|
||||
import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
|
||||
|
||||
@ MilliSatoshis(100)
|
||||
res1: MilliSatoshis = MilliSatoshisImpl(100)
|
||||
|
||||
|
||||
// Bitcoind RPC project
|
||||
$ sbt bitcoindRpcTest/test:run
|
||||
|
||||
// this works as well
|
||||
$ sbt
|
||||
> project bitcoindRpcTest
|
||||
> amm
|
||||
|
||||
// Similarly for other projects
|
||||
```
|
||||
|
||||
|
||||
## Artifacts
|
||||
|
||||
You need to add the Bitcoin-S Bintray to your resolvers to be able to access published artifacts.
|
||||
|
|
31
build.sbt
31
build.sbt
|
@ -90,9 +90,22 @@ lazy val commonSettings = List(
|
|||
|
||||
//fix for https://github.com/sbt/sbt/issues/3519
|
||||
updateOptions := updateOptions.value.withGigahorse(false),
|
||||
git.formattedShaVersion := git.gitHeadCommit.value.map { sha =>
|
||||
s"${sha.take(6)}-$timestamp-SNAPSHOT"
|
||||
},
|
||||
|
||||
git.formattedShaVersion := git.gitHeadCommit.value.map { sha => s"${sha.take(6)}-${timestamp}-SNAPSHOT" }
|
||||
|
||||
/**
|
||||
* Adding Ammonite REPL to test scope, can access both test and compile
|
||||
* sources. Docs: http://ammonite.io/#Ammonite-REPL
|
||||
* Creates an ad-hoc main file that can be run by doing
|
||||
* test:run (or test:runMain amm if there's multiple main files
|
||||
* in scope)
|
||||
*/
|
||||
Test / sourceGenerators += Def.task {
|
||||
val file = (Test / sourceManaged).value / "amm.scala"
|
||||
IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
|
||||
Seq(file)
|
||||
}.taskValue
|
||||
)
|
||||
|
||||
lazy val root = project
|
||||
|
@ -236,8 +249,20 @@ lazy val doc = project
|
|||
core
|
||||
)
|
||||
|
||||
// Ammonite is invoked through running
|
||||
// a main class it places in test sources
|
||||
// for us. This makes it a bit less awkward
|
||||
// to start the Ammonite shell. Sadly,
|
||||
// prepending the project and then doing
|
||||
// `amm` (e.g. sbt coreTest/amm`) does not
|
||||
// work. For that you either have to do
|
||||
// `sbt coreTest/test:run` or:
|
||||
// sbt
|
||||
// project coreTest
|
||||
// amm
|
||||
addCommandAlias("amm", "test:run")
|
||||
|
||||
publishArtifact in root := false
|
||||
|
||||
previewSite / aggregate := false
|
||||
previewAuto / aggregate := false
|
||||
previewSite / aggregate := false
|
||||
|
|
|
@ -16,6 +16,7 @@ object Deps {
|
|||
val junitV = "0.11"
|
||||
val nativeLoaderV = "2.3.2"
|
||||
val typesafeConfigV = "1.3.3"
|
||||
val ammoniteV = "1.6.2"
|
||||
}
|
||||
|
||||
object Compile {
|
||||
|
@ -43,22 +44,20 @@ object Deps {
|
|||
val spray = "io.spray" %% "spray-json" % V.spray % "test" withSources() withJavadoc()
|
||||
val akkaHttp = "com.typesafe.akka" %% "akka-http-testkit" % V.akkav % "test" withSources() withJavadoc()
|
||||
val akkaStream = "com.typesafe.akka" %% "akka-stream-testkit" % V.akkaStreamv % "test" withSources() withJavadoc()
|
||||
val ammonite = "com.lihaoyi" %% "ammonite" % V.ammoniteV % "test" cross CrossVersion.full
|
||||
}
|
||||
|
||||
val core = List(
|
||||
Compile.bouncycastle,
|
||||
Compile.scodec,
|
||||
Compile.slf4j
|
||||
Compile.slf4j,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val secp256k1jni = List(
|
||||
Compile.nativeLoader,
|
||||
Test.junitInterface
|
||||
)
|
||||
|
||||
val coreGen = List(
|
||||
Compile.slf4j,
|
||||
Test.scalacheck
|
||||
Test.junitInterface,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val coreTest = List(
|
||||
|
@ -66,7 +65,8 @@ object Deps {
|
|||
Test.junitInterface,
|
||||
Test.logback,
|
||||
Test.scalaTest,
|
||||
Test.spray
|
||||
Test.spray,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val bitcoindZmq = List(
|
||||
|
@ -74,7 +74,8 @@ object Deps {
|
|||
Compile.slf4j,
|
||||
Test.logback,
|
||||
Test.scalacheck,
|
||||
Test.scalaTest
|
||||
Test.scalaTest,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val bitcoindRpc = List(
|
||||
|
@ -90,12 +91,14 @@ object Deps {
|
|||
Test.akkaStream,
|
||||
Test.logback,
|
||||
Test.scalaTest,
|
||||
Test.scalacheck
|
||||
Test.scalacheck,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val bench = List(
|
||||
"org.slf4j" % "slf4j-api" % V.slf4j withSources() withJavadoc(),
|
||||
Compile.logback
|
||||
Compile.logback,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val eclairRpc = List(
|
||||
|
@ -109,13 +112,15 @@ object Deps {
|
|||
Test.akkaHttp,
|
||||
Test.logback,
|
||||
Test.scalaTest,
|
||||
Test.scalacheck
|
||||
Test.scalacheck,
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val testkit = List(
|
||||
Compile.slf4j,
|
||||
"org.scalacheck" %% "scalacheck" % V.scalacheck withSources() withJavadoc(),
|
||||
"org.scalatest" %% "scalatest" % V.scalaTest withSources() withJavadoc()
|
||||
"org.scalatest" %% "scalatest" % V.scalaTest withSources() withJavadoc(),
|
||||
Test.ammonite
|
||||
)
|
||||
|
||||
val doc = List(
|
||||
|
|
Loading…
Add table
Reference in a new issue