Put tests for bitcoind-rpc and eclair-rpc into a separate project to … (#341)

* Put tests for bitcoind-rpc and eclair-rpc into a separate project to get rid of circular dependency

* Modify travis yml file to get rid of all testkit stuff

* rename rpc project to bitcoind-rpc project

* Add bitcoind-rpc test cases that got deleted accidentally

* Add more files missing from bitcoind-rpc-test

* Remove circular deps part on CONTRIBUTING.md
This commit is contained in:
Chris Stewart 2019-02-18 09:57:18 -06:00 committed by GitHub
parent 2879d9c25c
commit 0c4556a301
24 changed files with 54 additions and 44 deletions

2
.jvmopts Normal file
View File

@ -0,0 +1,2 @@
-Xmx1024m
-Xms1024m

View File

@ -62,22 +62,6 @@ $ popd
$ rm -rf /tmp/yourproject
```
## Development
### `testkit` and circular dependencies
One issue you might run into when making local changes and compiling/testing is a circular depedency conundrum. Bitcoin-S has multiple submodules, such as `rpc` (interfacing with a Bitcoin Core RPC server), `eclair-rpc` (interfacing with an Eclair RPC server) and `testkit` (utilities for spinning up Bitcoin and Lightning nodes, etc.). `testkit` depends on `rpc` and `eclair-rpc`, and both `rpc` and `eclair-rpc` tests depend on `testkit`. This causes the compiler and build system to have a hard time. We solve this problem by publishing `testkit` as a standalone project in [Bintray](https://bintray.com/beta/#/bitcoin-s/bitcoin-s-core/bitcoin-s-testkit?tab=overview).
Now, what happens when you need to make changes in `testkit`, and have either `rpc` or `eclair-rpc` utilize these changes?
1. Change the value of `version in ThisBuild` in [`version.sbt`](version.sbt) by adding `-SNAPSHOT` to it. If the file previously was `version in ThisBuild := "0.0.1"`, change it to `version in ThisBuild := "0.0.1-SNAPSHOT"`
2. If you have an active sbt shell/session, do `sbt reload`
3. Compile the project: `sbt compile`
4. Publish the freshly compiled project locally: `sbt publishLocal`. This places the newly compiled files into `~/.ivy2/local/org.bitcoins`, where sbt will find them.
5. Change the value of `Deps.V.bitcoinsV` in [`project/Deps.scala`](project/Deps.scala) to the version number you previously changed in `version.sbt`. In our case, `"0.0.1-SNAPSHOT"`.
6. If you have an active sbt shell/session, do `sbt reload` again
7. You should now be good to go, and both `sbt test:compile` and `sbt test` should work without issues.
## Testing
### Property based testing

View File

@ -5,6 +5,8 @@ import com.typesafe.sbt.SbtGit.GitKeys._
cancelable in Global := true
fork in Test := true
lazy val timestamp = new java.util.Date().getTime
lazy val commonCompilerOpts = {
@ -100,9 +102,11 @@ lazy val root = project
core,
coreTest,
zmq,
rpc,
bitcoindRpc,
bitcoindRpcTest,
bench,
eclairRpc,
eclairRpcTest,
testkit,
doc
)
@ -142,26 +146,38 @@ lazy val coreTest = project
.settings(skip in publish := true)
.dependsOn(
core,
testkit,
).enablePlugins()
lazy val zmq = project
.in(file("zmq"))
.settings(commonSettings: _*)
.settings(
name := "bitcoin-s-zmq",
libraryDependencies ++= Deps.bitcoindZmq)
.dependsOn(
core
).enablePlugins()
lazy val rpc = project
.in(file("rpc"))
lazy val bitcoindRpc = project
.in(file("bitcoind-rpc"))
.settings(commonSettings: _*)
.dependsOn(
core
).enablePlugins()
.settings(
name := "bitcoin-s-bitcoind-rpc",
libraryDependencies ++= Deps.bitcoindRpc)
.dependsOn(core)
.enablePlugins()
lazy val bitcoindRpcTest = project
.in(file("bitcoind-rpc-test"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= Deps.bitcoindRpcTest)
.dependsOn(testkit)
.enablePlugins()
lazy val bench = project
.in(file("bench"))
.enablePlugins()
.settings(commonSettings: _*)
.settings(assemblyOption in assembly := (assemblyOption in assembly).value
.copy(includeScala = true))
@ -171,25 +187,34 @@ lazy val bench = project
skip in publish := true
)
.dependsOn(core)
.enablePlugins()
lazy val eclairRpc = project
.in(file("eclair-rpc"))
.enablePlugins()
.settings(commonSettings: _*)
.settings(
name := "bitcoin-s-eclair-rpc",
libraryDependencies ++= Deps.eclairRpc)
.dependsOn(
core,
rpc
)
bitcoindRpc
).enablePlugins()
lazy val eclairRpcTest = project
.in(file("eclair-rpc-test"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= Deps.eclairRpcTest)
.dependsOn(testkit)
.enablePlugins()
lazy val testkit = project
.in(file("testkit"))
.enablePlugins()
.settings(commonSettings: _*)
.dependsOn(
core,
rpc,
bitcoindRpc,
eclairRpc
)
).enablePlugins()
lazy val doc = project

View File

@ -16,8 +16,6 @@ object Deps {
val junitV = "0.11"
val nativeLoaderV = "2.3.2"
val typesafeConfigV = "1.3.3"
val bitcoinsV = "236041-1549541584036-SNAPSHOT"
}
object Compile {
@ -45,8 +43,6 @@ 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 testkit = "org.bitcoins" %% "bitcoin-s-testkit" % V.bitcoinsV % "test" withSources() withJavadoc()
}
val core = List(
@ -70,11 +66,10 @@ object Deps {
Test.junitInterface,
Test.logback,
Test.scalaTest,
Test.spray,
Test.testkit
Test.spray
)
val zmq = List(
val bitcoindZmq = List(
Compile.zeromq,
Compile.slf4j,
Test.logback,
@ -82,18 +77,20 @@ object Deps {
Test.scalaTest
)
val rpc = List(
val bitcoindRpc = List(
Compile.akkaHttp,
Compile.akkaStream,
Compile.playJson,
Compile.slf4j,
Compile.typesafeConfig,
Compile.typesafeConfig
)
val bitcoindRpcTest = List(
Test.akkaHttp,
Test.akkaStream,
Test.logback,
Test.scalaTest,
Test.scalacheck,
Test.testkit
Test.scalacheck
)
val bench = List(
@ -105,12 +102,14 @@ object Deps {
Compile.akkaHttp,
Compile.akkaStream,
Compile.playJson,
Compile.slf4j,
Compile.slf4j
)
val eclairRpcTest = List(
Test.akkaHttp,
Test.logback,
Test.scalaTest,
Test.scalacheck,
Test.testkit
Test.scalacheck
)
val testkit = List(