summaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/commonMain/kotlin/net/taler/lib/common/Amount.kt (renamed from common/src/commonMain/kotlin/net/taler/common/Amount.kt)2
-rw-r--r--common/src/commonMain/kotlin/net/taler/lib/common/TalerUri.kt (renamed from common/src/commonMain/kotlin/net/taler/common/TalerUri.kt)4
-rw-r--r--common/src/commonMain/kotlin/net/taler/lib/common/Time.kt (renamed from common/src/commonMain/kotlin/net/taler/common/Time.kt)9
-rw-r--r--common/src/commonMain/kotlin/net/taler/lib/common/Version.kt (renamed from common/src/commonMain/kotlin/net/taler/common/Version.kt)2
-rw-r--r--common/src/commonTest/kotlin/net/taler/lib/common/AmountTest.kt (renamed from common/src/commonTest/kotlin/net/taler/common/AmountTest.kt)15
-rw-r--r--common/src/commonTest/kotlin/net/taler/lib/common/TalerUriTest.kt (renamed from common/src/commonTest/kotlin/net/taler/common/TalerUriTest.kt)6
-rw-r--r--common/src/commonTest/kotlin/net/taler/lib/common/TestUtils.kt (renamed from common/src/commonTest/kotlin/net/taler/common/TestUtils.kt)16
-rw-r--r--common/src/commonTest/kotlin/net/taler/lib/common/TimeTest.kt (renamed from common/src/commonTest/kotlin/net/taler/common/TimeTest.kt)4
-rw-r--r--common/src/commonTest/kotlin/net/taler/lib/common/VersionTest.kt (renamed from common/src/commonTest/kotlin/net/taler/common/VersionTest.kt)2
-rw-r--r--common/src/jsMain/kotlin/net/taler/common/Time.kt23
-rw-r--r--common/src/jvmMain/kotlin/net/taler/common/Time.kt21
-rw-r--r--common/src/nativeMain/kotlin/net/taler/common/Time.kt23
12 files changed, 30 insertions, 97 deletions
diff --git a/common/src/commonMain/kotlin/net/taler/common/Amount.kt b/common/src/commonMain/kotlin/net/taler/lib/common/Amount.kt
index 84d10c5..213abb3 100644
--- a/common/src/commonMain/kotlin/net/taler/common/Amount.kt
+++ b/common/src/commonMain/kotlin/net/taler/lib/common/Amount.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlinx.serialization.Decoder
import kotlinx.serialization.Encoder
diff --git a/common/src/commonMain/kotlin/net/taler/common/TalerUri.kt b/common/src/commonMain/kotlin/net/taler/lib/common/TalerUri.kt
index 9f121d3..8255dc0 100644
--- a/common/src/commonMain/kotlin/net/taler/common/TalerUri.kt
+++ b/common/src/commonMain/kotlin/net/taler/lib/common/TalerUri.kt
@@ -14,9 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
-internal object TalerUri {
+object TalerUri {
private const val SCHEME = "taler://"
private const val SCHEME_INSECURE = "taler+http://"
diff --git a/common/src/commonMain/kotlin/net/taler/common/Time.kt b/common/src/commonMain/kotlin/net/taler/lib/common/Time.kt
index 37b6606..0e5e07c 100644
--- a/common/src/commonMain/kotlin/net/taler/common/Time.kt
+++ b/common/src/commonMain/kotlin/net/taler/lib/common/Time.kt
@@ -14,8 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
+import com.soywiz.klock.DateTime
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
@@ -24,11 +25,9 @@ import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.JsonTransformingSerializer
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.longOrNull
-import net.taler.common.Duration.Companion.FOREVER
+import net.taler.lib.common.Duration.Companion.FOREVER
import kotlin.math.max
-expect fun nowMillis(): Long
-
@Serializable
data class Timestamp(
@SerialName("t_ms")
@@ -38,7 +37,7 @@ data class Timestamp(
companion object {
const val NEVER: Long = -1
- fun now(): Timestamp = Timestamp(nowMillis())
+ fun now(): Timestamp = Timestamp(DateTime.nowUnixLong())
}
/**
diff --git a/common/src/commonMain/kotlin/net/taler/common/Version.kt b/common/src/commonMain/kotlin/net/taler/lib/common/Version.kt
index 8774115..d3f0ad2 100644
--- a/common/src/commonMain/kotlin/net/taler/common/Version.kt
+++ b/common/src/commonMain/kotlin/net/taler/lib/common/Version.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlin.math.sign
diff --git a/common/src/commonTest/kotlin/net/taler/common/AmountTest.kt b/common/src/commonTest/kotlin/net/taler/lib/common/AmountTest.kt
index e184307..90b0569 100644
--- a/common/src/commonTest/kotlin/net/taler/common/AmountTest.kt
+++ b/common/src/commonTest/kotlin/net/taler/lib/common/AmountTest.kt
@@ -14,14 +14,13 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
-import kotlin.test.fail
class AmountTest {
@@ -219,16 +218,4 @@ class AmountTest {
}
}
- private inline fun <reified T : Throwable> assertThrows(
- msg: String? = null,
- function: () -> Any
- ) {
- try {
- function.invoke()
- fail(msg)
- } catch (e: Exception) {
- assertTrue(e is T)
- }
- }
-
}
diff --git a/common/src/commonTest/kotlin/net/taler/common/TalerUriTest.kt b/common/src/commonTest/kotlin/net/taler/lib/common/TalerUriTest.kt
index f996fa9..ca3430d 100644
--- a/common/src/commonTest/kotlin/net/taler/common/TalerUriTest.kt
+++ b/common/src/commonTest/kotlin/net/taler/lib/common/TalerUriTest.kt
@@ -14,10 +14,10 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
-import net.taler.common.TalerUri.WithdrawUriResult
-import net.taler.common.TalerUri.parseWithdrawUri
+import net.taler.lib.common.TalerUri.WithdrawUriResult
+import net.taler.lib.common.TalerUri.parseWithdrawUri
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull
diff --git a/common/src/commonTest/kotlin/net/taler/common/TestUtils.kt b/common/src/commonTest/kotlin/net/taler/lib/common/TestUtils.kt
index e3a6c17..837de27 100644
--- a/common/src/commonTest/kotlin/net/taler/common/TestUtils.kt
+++ b/common/src/commonTest/kotlin/net/taler/lib/common/TestUtils.kt
@@ -14,9 +14,11 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlin.random.Random
+import kotlin.test.assertTrue
+import kotlin.test.fail
private val charPool: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
fun getRandomString(minLength: Int = 1, maxLength: Int = Random.nextInt(0, 1337)) =
@@ -24,3 +26,15 @@ fun getRandomString(minLength: Int = 1, maxLength: Int = Random.nextInt(0, 1337)
.map { Random.nextInt(0, charPool.size) }
.map(charPool::get)
.joinToString("")
+
+inline fun <reified T : Throwable> assertThrows(
+ msg: String? = null,
+ function: () -> Any
+) {
+ try {
+ function.invoke()
+ fail(msg)
+ } catch (e: Exception) {
+ assertTrue(e is T)
+ }
+}
diff --git a/common/src/commonTest/kotlin/net/taler/common/TimeTest.kt b/common/src/commonTest/kotlin/net/taler/lib/common/TimeTest.kt
index 3ee0a99..647e439 100644
--- a/common/src/commonTest/kotlin/net/taler/common/TimeTest.kt
+++ b/common/src/commonTest/kotlin/net/taler/lib/common/TimeTest.kt
@@ -14,12 +14,12 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.Json.Default.parse
import kotlinx.serialization.json.Json.Default.stringify
-import net.taler.common.Timestamp.Companion.NEVER
+import net.taler.lib.common.Timestamp.Companion.NEVER
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/common/src/commonTest/kotlin/net/taler/common/VersionTest.kt b/common/src/commonTest/kotlin/net/taler/lib/common/VersionTest.kt
index f4f17ea..b10b4bf 100644
--- a/common/src/commonTest/kotlin/net/taler/common/VersionTest.kt
+++ b/common/src/commonTest/kotlin/net/taler/lib/common/VersionTest.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.common
+package net.taler.lib.common
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/common/src/jsMain/kotlin/net/taler/common/Time.kt b/common/src/jsMain/kotlin/net/taler/common/Time.kt
deleted file mode 100644
index b114022..0000000
--- a/common/src/jsMain/kotlin/net/taler/common/Time.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2020 Taler Systems S.A.
- *
- * GNU Taler is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3, or (at your option) any later version.
- *
- * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-package net.taler.common
-
-import kotlin.js.Date
-
-actual fun nowMillis(): Long {
- return Date().getMilliseconds().toLong()
-}
diff --git a/common/src/jvmMain/kotlin/net/taler/common/Time.kt b/common/src/jvmMain/kotlin/net/taler/common/Time.kt
deleted file mode 100644
index 6cd9040..0000000
--- a/common/src/jvmMain/kotlin/net/taler/common/Time.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2020 Taler Systems S.A.
- *
- * GNU Taler is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3, or (at your option) any later version.
- *
- * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-package net.taler.common
-
-actual fun nowMillis(): Long {
- return System.currentTimeMillis()
-}
diff --git a/common/src/nativeMain/kotlin/net/taler/common/Time.kt b/common/src/nativeMain/kotlin/net/taler/common/Time.kt
deleted file mode 100644
index 8a4091a..0000000
--- a/common/src/nativeMain/kotlin/net/taler/common/Time.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2020 Taler Systems S.A.
- *
- * GNU Taler is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3, or (at your option) any later version.
- *
- * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-package net.taler.common
-
-import kotlin.system.getTimeMillis
-
-actual fun nowMillis(): Long {
- return getTimeMillis()
-}