Test new, print, and free Config works
This commit is contained in:
40
jvm/build.gradle
Normal file
40
jvm/build.gradle
Normal file
@@ -0,0 +1,40 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' // version '1.3.71'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
test {
|
||||
systemProperty "java.library.path", file("${buildDir}/jniLibs/x86_64_linux").absolutePath
|
||||
environment "LD_LIBRARY_PATH", file("${buildDir}/jniLibs/x86_64_linux").absolutePath
|
||||
// testLogging {
|
||||
// events "PASSED", "SKIPPED", "FAILED", "STANDARD_OUT", "STANDARD_ERROR"
|
||||
// }
|
||||
}
|
||||
|
||||
task buildRust(type: Exec) {
|
||||
workingDir '../'
|
||||
commandLine './build.sh'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation platform('org.jetbrains.kotlin:kotlin-bom')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
|
||||
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+"
|
||||
implementation "net.java.dev.jna:jna:5.8.0"
|
||||
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test'
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'org.bitcoindevkit.bdkjni'
|
||||
artifactId = 'bdk-jvm-debug'
|
||||
version = '0.2.1-dev'
|
||||
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
43
jvm/src/test/java/org/bitcoindevkit/bdkjni/LibTest.kt
Normal file
43
jvm/src/test/java/org/bitcoindevkit/bdkjni/LibTest.kt
Normal file
@@ -0,0 +1,43 @@
|
||||
package org.bitcoindevkit.bdkjni
|
||||
|
||||
import com.sun.jna.Native
|
||||
import com.sun.jna.NativeLong
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Library test, which will execute on linux host.
|
||||
*
|
||||
*/
|
||||
class LibTest {
|
||||
|
||||
private val lib: Lib = Native.load("bdk_ffi", Lib::class.java)
|
||||
|
||||
@Test
|
||||
fun print_string() {
|
||||
lib.print_string("hello print string")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun concat_print_free_string() {
|
||||
val concat = lib.concat_string("hello", "concat")
|
||||
lib.print_string(concat)
|
||||
lib.free_string(concat)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun print_free_config() {
|
||||
val config = Config_t()
|
||||
config.name = "test"
|
||||
config.count = NativeLong(101)
|
||||
lib.print_config(config)
|
||||
lib.free_config(config)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun new_print_free_config() {
|
||||
println("Long max value = ${Long.MAX_VALUE}")
|
||||
val config = lib.new_config("test test", NativeLong(Long.MAX_VALUE))
|
||||
lib.print_config(config)
|
||||
lib.free_config(config)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user