Move kotlin tests to fest-fixtures submodule

This commit is contained in:
Steve Myers
2021-10-17 13:56:28 -07:00
parent 0b500d8e05
commit f556f611b0
5 changed files with 67 additions and 18 deletions

View File

@@ -4,6 +4,11 @@ plugins {
id 'maven-publish'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
test {
testLogging {
events "PASSED", "SKIPPED", "FAILED", "STANDARD_OUT", "STANDARD_ERROR"
@@ -18,7 +23,7 @@ dependencies {
api "org.slf4j:slf4j-api:1.7.30"
testImplementation "ch.qos.logback:logback-classic:1.2.3"
testImplementation "ch.qos.logback:logback-core:1.2.3"
//testImplementation(project(':test-fixtures'))
testImplementation(project(':test-fixtures'))
}
publishing {
@@ -32,8 +37,3 @@ publishing {
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@@ -0,0 +1,16 @@
package org.bitcoindevkit.bdk
import java.nio.file.Files
/**
* Library test, which will execute on linux host.
*
*/
class JvmLibTest : LibTest() {
override fun getTestDataDir(): String {
return Files.createTempDirectory("bdk-test").toString()
//return Paths.get(System.getProperty("java.io.tmpdir"), "bdk-test").toString()
}
}

View File

@@ -1,64 +0,0 @@
package uniffi.bdk
import uniffi.bdk.OfflineWallet
import org.junit.Assert.*
import org.junit.Test
class LogProgress: BdkProgress {
override fun update(progress: Float, message: String? ) {
println("progress: $progress, message: $message")
}
}
/**
* Library tests which will execute for jvm and android modules.
*/
class LibTest {
val desc =
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
@Test
fun memoryWalletNewAddress() {
val config = DatabaseConfig.Memory("")
val wallet = OfflineWallet(desc, Network.REGTEST, config)
val address = wallet.getNewAddress()
assertNotNull(address)
assertEquals(address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
}
@Test(expected=BdkException.Descriptor::class)
fun invalidDescriptorExceptionIsThrown() {
val config = DatabaseConfig.Memory("")
OfflineWallet("invalid-descriptor", Network.REGTEST, config)
}
@Test
fun sledWalletNewAddress() {
val config = DatabaseConfig.Sled(SledDbConfiguration("/tmp/testdb", "testdb"))
val wallet = OfflineWallet(desc, Network.REGTEST, config)
val address = wallet.getNewAddress()
assertNotNull(address)
assertEquals(address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
}
@Test
fun onlineWalletInMemory() {
val db = DatabaseConfig.Memory("")
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 100u))
val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
assertNotNull(wallet)
val network = wallet.getNetwork()
assertEquals(network, Network.TESTNET)
}
@Test
fun onlineWalletSyncGetBalance() {
val db = DatabaseConfig.Memory("")
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 100u))
val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
wallet.sync(LogProgress(), null)
val balance = wallet.getBalance()
assertTrue(balance > 0u)
}
}