Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypto-ffi/bindings/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "2.3.10"
coroutines = "1.7.3"
kotlinx-datetime = "0.6.1"
kotlinx-datetime = "0.7.1"
jna = "5.17.0"
assertj = "3.24.2"
espresso = "3.6.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wire.crypto

import java.nio.ByteBuffer
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.time.Instant

class TimestampTest {
Comment thread
typfel marked this conversation as resolved.
Outdated
@Test
fun timestampPreservesNanosecondsAcrossFfiConversion() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant to check the new Instant type and nanosecond precision, but it mostly tests the generated converter. I'll remove it

val instant = Instant.fromEpochSeconds(1_700_000_000, 123_456_789)
val timestamp: Timestamp = instant
val buffer = ByteBuffer.allocate(FfiConverterTypeTimestamp.allocationSize(timestamp).toInt())

FfiConverterTypeTimestamp.write(timestamp, buffer)
buffer.flip()
val restored: Instant = FfiConverterTypeTimestamp.read(buffer)

assertEquals(instant, restored)
}
}
6 changes: 3 additions & 3 deletions crypto-ffi/uniffi-android.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ android_cleaner = true

[bindings.kotlin.custom_types.KotlinInstant]
imports = [
"kotlinx.datetime.Instant",
"kotlinx.datetime.toKotlinInstant",
"kotlinx.datetime.toJavaInstant",
"kotlin.time.Instant",
"kotlin.time.toKotlinInstant",
"kotlin.time.toJavaInstant",
]
type_name = "Instant"
lift = "{}.toKotlinInstant()"
Expand Down
6 changes: 3 additions & 3 deletions crypto-ffi/uniffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ cdylib_name = "core_crypto_ffi"

[bindings.kotlin.custom_types.Timestamp]
imports = [
"kotlinx.datetime.Instant",
"kotlinx.datetime.toKotlinInstant",
"kotlinx.datetime.toJavaInstant",
"kotlin.time.Instant",
"kotlin.time.toKotlinInstant",
"kotlin.time.toJavaInstant",
]
type_name = "Instant"
lift = "{}.toKotlinInstant()"
Expand Down
Loading