Skip to content

Commit

Permalink
fix(scouting): error when providing config (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP authored Sep 19, 2024
1 parent 247955b commit dbc6d2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ internal class JNIScout(private val ptr: Long) {
callback.run(Hello(WhatAmI.fromInt(whatAmI2), ZenohID(id), locators))
}
val binaryWhatAmI: Int = whatAmI.map { it.value }.reduce { acc, it -> acc or it }
val ptr = scoutViaJNI(binaryWhatAmI, scoutCallback, config?.jniConfig?.ptr)
val ptr = scoutViaJNI(binaryWhatAmI, scoutCallback, config?.jniConfig?.ptr ?: 0)
Scout(receiver, JNIScout(ptr))
}

@Throws(Exception::class)
private external fun scoutViaJNI(
whatAmI: Int,
callback: JNIScoutCallback,
configPtr: Long?,
configPtr: Long,
): Long

@Throws(Exception::class)
Expand Down
17 changes: 6 additions & 11 deletions zenoh-kotlin/src/commonTest/kotlin/io/zenoh/ScoutTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ class ScoutTest {

@Test
fun `scouting detects session test`() {

val config = Config.fromJson("""
{
"mode": "peer",
"connect": {
"endpoints": ["tcp/localhost:7450"]
},
}
""".trimIndent()).getOrThrow()

val session = Session.open(config).getOrThrow()
val session = Session.open(Config.default()).getOrThrow()

var hello: Hello? = null
Zenoh.scout(callback = {
Expand All @@ -51,4 +41,9 @@ class ScoutTest {
assertNotNull(hello)
session.close()
}

@Test
fun `scouting loads config successfully test`() {
Zenoh.scout({}, config = Config.default()).getOrThrow()
}
}

0 comments on commit dbc6d2b

Please sign in to comment.