Skip to content

Commit

Permalink
Add excluded in CI connected tests to JVM library
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Oct 27, 2023
1 parent 13c751c commit 3fd02c5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test-jvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
- name: "Run JVM tests"
run: |
cd bdk-jvm
./gradlew test
./gradlew test -P excludeConnectedTests
12 changes: 12 additions & 0 deletions bdk-jvm/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ java {
withJavadocJar()
}

// This block ensures that the tests that require access to a blockchain are not
// run if the -P excludeConnectedTests flag is passed to gradle.
// This ensures our CI runs are not fickle by not requiring access to testnet.
// This is a workaround until we have a proper regtest setup for the CI.
// Note that the command in the CI is ./gradlew test -P excludeConnectedTests
tasks.test {
if (project.hasProperty("excludeConnectedTests")) {
exclude("**/ConnectedWalletTest.class")
exclude("**/ConnectedTxBuilderTest.class")
}
}

testing {
suites {
val test by getting(JvmTestSuite::class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.bitcoindevkit

import org.junit.Test

class ConnectedTxBuilderTest {
@Test
fun testTxBuilder() {
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET)
val wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET)
val esploraClient = EsploraClient("https://mempool.space/testnet/api")
val update = esploraClient.scan(wallet, 10uL, 1uL)
wallet.applyUpdate(update)
println("Balance: ${wallet.getBalance().total()}")

assert(wallet.getBalance().total() > 0uL)

val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)
val psbt: PartiallySignedTransaction = TxBuilder()
.addRecipient(recipient.scriptPubkey(), 4200uL)
.feeRate(2.0f)
.finish(wallet)

println(psbt.serialize())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.bitcoindevkit

import org.junit.Test

class ConnectedWalletTest {
@Test
fun testSyncedBalance() {
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET)
val wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET)
val esploraClient = EsploraClient("https://mempool.space/testnet/api")
// val esploraClient = EsploraClient("https://blockstream.info/testnet/api")
val update = esploraClient.scan(wallet, 10uL, 1uL)
wallet.applyUpdate(update)
println("Balance: ${wallet.getBalance().total()}")
}
}

0 comments on commit 3fd02c5

Please sign in to comment.