summaryrefslogtreecommitdiff
path: root/wallet/src/commonTest
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-08-14 17:33:22 -0300
committerTorsten Grote <t@grobox.de>2020-08-14 17:33:22 -0300
commita307a498dc8a42df129e8eaff591e9144ed96298 (patch)
treea55182b4793b673e433d0e431e9d971d45c9a6a7 /wallet/src/commonTest
parent2ac13b19a5c7fc3531447333fe1772a78ca35795 (diff)
downloadwallet-kotlin-a307a498dc8a42df129e8eaff591e9144ed96298.tar.gz
wallet-kotlin-a307a498dc8a42df129e8eaff591e9144ed96298.tar.bz2
wallet-kotlin-a307a498dc8a42df129e8eaff591e9144ed96298.zip
Make the wallet lib actually use the common lib
Diffstat (limited to 'wallet/src/commonTest')
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/AmountTest.kt64
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/Base32CrockfordTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt)2
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/DbTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/DbTest.kt)17
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/PaytoUriTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/PaytoUriTest.kt)2
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/TestUtils.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TestUtils.kt)2
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/TimestampTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TimestampTest.kt)3
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/WalletApiTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/WalletApiTest.kt)3
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/DepositTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/DepositTest.kt)10
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/EllipticCurveTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/EllipticCurveTest.kt)4
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/KdfTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/KdfTest.kt)8
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RecoupTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RecoupTest.kt)14
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RefreshPlanchetTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RefreshPlanchetTest.kt)4
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha256Test.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha256Test.kt)3
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha512Test.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha512Test.kt)4
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/SignatureTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/SignatureTest.kt)18
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/DenominationTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/DenominationTest.kt)20
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/Denominations.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/Denominations.kt)10
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/KeysTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/KeysTest.kt)12
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/UpdateTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/UpdateTest.kt)4
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/WireTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/WireTest.kt)12
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/lib/wallet/operations/WithdrawTest.kt (renamed from wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/operations/WithdrawTest.kt)32
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/AmountTest.kt276
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TalerUriTest.kt65
-rw-r--r--wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/VersionTest.kt57
24 files changed, 157 insertions, 489 deletions
diff --git a/wallet/src/commonTest/kotlin/net/taler/lib/wallet/AmountTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/AmountTest.kt
new file mode 100644
index 0000000..ccee992
--- /dev/null
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/AmountTest.kt
@@ -0,0 +1,64 @@
+/*
+ * 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.lib.wallet
+
+import net.taler.lib.common.Amount
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class AmountTest {
+
+ @Test
+ fun testToByteArray() {
+ val vectors = listOf(
+ Pair("ceicWVf9GhJ:3902026702525079.40496378", "006XSQV3G899E0K9XKX66SB9CDBNCSHS8XM4M00"),
+ Pair("asYDLuK2A:3800267550024600.02072907", "006R0MNXBVHSG00ZM55P2WTS8H67AJSJ8400000"),
+ Pair("pV1m:1347558259914570.09786232", "002CK66VCNVMM04NADW70NHHDM0000000000000"),
+ Pair("geO82l:553744321840253.41004983", "000ZF855K627T0KHNYVPESAF70S6R0000000000"),
+ Pair("B9bWK7WPEO:3663912678613976.12122563", "006G8KS5P9HXG05RZ71M4EB2AX5KENTG8N7G000"),
+ Pair("X:1537372109907438.77850768", "002QCETPFYJYW153X285G000000000000000000"),
+ Pair("5:4271492725553118.39728399", "007JSSK6J4VXW0JY6M7KA000000000000000000"),
+ Pair("OSdV:801656289790342.08256189", "001DJ6H6CA4RC03XZAYMYMV4AR0000000000000"),
+ Pair("Y6:2908617536334646.94126271", "0055AQTB19NKC1CW82ZNJDG0000000000000000"),
+ Pair("kSHoOZj:2610656582865206.00292046", "004MCR6T828KC004EK76PMT8DX7NMTG00000000"),
+ Pair("GkhLXrlGES:4246330707533398.83874252", "007HC0Z9DFF5C17ZT764ETV89HC74V278N9G000"),
+ Pair("CNS09:738124490298524.71259462", "0019YMG01DA9R11ZAN346KJK60WG00000000000"),
+ Pair("sw0b1tKXZym:2132978464977419.28199478", "003S7VNZPZS0P0DE98V76XSGC8RQ8JTRB9WPT00"),
+ Pair("fC:1275322307696988.17178522", "0028FSGX3ZCNR0863YD6CGR0000000000000000"),
+ Pair("cRai6j:166032749022734.69444771", "0009E0C30V70W113MJHP6MK1D4V6M0000000000"),
+ Pair("KOADwTb3:3932974019564218.48282023", "006ZJ16ZB39BM0Q0Q6KMPKT18HVN8RHK0000000"),
+ Pair("9Fi9wcLgDe:1268366772151214.97268853", "002834N6WRHTW1EC6HTKJHK975VP6K378HJG000"),
+ Pair("SDN:3370670470236379.88943272", "005ZK6V0124DP1AD5AM56H2E000000000000000"),
+ Pair("zGCP5V:4010014441349620.76121145", "0073Y5HYA8GZ8149GGWQMHT3A0TNC0000000000"),
+ Pair("VsW1JjBLn:2037070181191907.99717275", "003KSD2WH18E61FHJ2DNCWTQ6556MGJCDR00000"),
+ Pair("A:1806895799429502.00887758", "0036PQ5P8NMQW00DHF742000000000000000000"),
+ Pair("njA8:4015261148004966.43708687", "00747PYPD116C0MTY47PWTJ1700000000000000"),
+ Pair("Bwq:3562876074139250.28829179", "006AGTNTRWF740DQWQXM4XVH000000000000000"),
+ Pair("8e75v8:3716241006992995.95213823", "006K7SP93WF661DCV3ZKGS9Q6NV3G0000000000"),
+ Pair("XrnbQTTn:3887603772953949.94721267", "006WZGA9X8ANT1D5AKSNGWKEC98N8N3E0000000"),
+ Pair("MIN:0.00000001", "0000000000000000000MTJAE000000000000000"),
+ Pair("MAX:4503599627370496.99999999", "00800000000001FNW3ZMTGAR000000000000000")
+ )
+ for (v in vectors) {
+ val amount = Amount.fromJSONString(v.first)
+ val encodedBytes =
+ Base32Crockford.encode(amount.toByteArray())
+ assertEquals(v.second, encodedBytes)
+ }
+ }
+
+}
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/Base32CrockfordTest.kt
index 565a395..0f16971 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/Base32CrockfordTest.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
import kotlin.test.Ignore
import kotlin.test.Test
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/DbTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/DbTest.kt
index ab4770d..cdd0484 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/DbTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/DbTest.kt
@@ -14,15 +14,16 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
-import net.taler.wallet.kotlin.exchange.Denominations.denomination10
-import net.taler.wallet.kotlin.exchange.Denominations.denomination5
-import net.taler.wallet.kotlin.exchange.DenominationStatus.Unverified
-import net.taler.wallet.kotlin.exchange.DenominationStatus.VerifiedGood
-import net.taler.wallet.kotlin.exchange.ExchangeRecord
-import net.taler.wallet.kotlin.exchange.ExchangeUpdateReason.Initial
-import net.taler.wallet.kotlin.exchange.ExchangeUpdateStatus.FetchKeys
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.exchange.DenominationStatus.Unverified
+import net.taler.lib.wallet.exchange.DenominationStatus.VerifiedGood
+import net.taler.lib.wallet.exchange.Denominations.denomination10
+import net.taler.lib.wallet.exchange.Denominations.denomination5
+import net.taler.lib.wallet.exchange.ExchangeRecord
+import net.taler.lib.wallet.exchange.ExchangeUpdateReason.Initial
+import net.taler.lib.wallet.exchange.ExchangeUpdateStatus.FetchKeys
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/PaytoUriTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/PaytoUriTest.kt
index 4f080e3..cf3780a 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/PaytoUriTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/PaytoUriTest.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TestUtils.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/TestUtils.kt
index 0ece68e..14c3076 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TestUtils.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/TestUtils.kt
@@ -14,7 +14,7 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
import io.ktor.client.HttpClient
import io.ktor.client.engine.mock.MockEngine
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TimestampTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/TimestampTest.kt
index 1a12549..b0f3b32 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TimestampTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/TimestampTest.kt
@@ -14,8 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
+import net.taler.lib.common.Timestamp
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/WalletApiTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/WalletApiTest.kt
index 7971be5..511eb79 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/WalletApiTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/WalletApiTest.kt
@@ -14,8 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin
+package net.taler.lib.wallet
+import net.taler.lib.common.Amount
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/DepositTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/DepositTest.kt
index 399b754..e3017a3 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/DepositTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/DepositTest.kt
@@ -14,12 +14,12 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.crypto.Deposit.CoinDepositPermission
-import net.taler.wallet.kotlin.crypto.Deposit.DepositInfo
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.crypto.Deposit.CoinDepositPermission
+import net.taler.lib.wallet.crypto.Deposit.DepositInfo
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/EllipticCurveTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/EllipticCurveTest.kt
index 4e83b47..10fbcc1 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/EllipticCurveTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/EllipticCurveTest.kt
@@ -14,9 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Base32Crockford
+import net.taler.lib.wallet.Base32Crockford
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/KdfTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/KdfTest.kt
index 974f9aa..291930d 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/KdfTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/KdfTest.kt
@@ -14,11 +14,11 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Base32Crockford
-import net.taler.wallet.kotlin.crypto.Kdf.HMAC_SHA256_BLOCK_SIZE
-import net.taler.wallet.kotlin.crypto.Kdf.HMAC_SHA512_BLOCK_SIZE
+import net.taler.lib.wallet.Base32Crockford
+import net.taler.lib.wallet.crypto.Kdf.HMAC_SHA256_BLOCK_SIZE
+import net.taler.lib.wallet.crypto.Kdf.HMAC_SHA512_BLOCK_SIZE
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RecoupTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RecoupTest.kt
index ea74e3c..035b7d7 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RecoupTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RecoupTest.kt
@@ -14,14 +14,14 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.CoinRecord
-import net.taler.wallet.kotlin.CoinSourceType.REFRESH
-import net.taler.wallet.kotlin.CoinSourceType.WITHDRAW
-import net.taler.wallet.kotlin.CoinStatus.FRESH
-import net.taler.wallet.kotlin.crypto.Recoup.Request
+import net.taler.lib.common.Amount
+import net.taler.lib.wallet.CoinRecord
+import net.taler.lib.wallet.CoinSourceType.REFRESH
+import net.taler.lib.wallet.CoinSourceType.WITHDRAW
+import net.taler.lib.wallet.CoinStatus.FRESH
+import net.taler.lib.wallet.crypto.Recoup.Request
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RefreshPlanchetTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RefreshPlanchetTest.kt
index 51eb5c6..a56d191 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/RefreshPlanchetTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/RefreshPlanchetTest.kt
@@ -14,9 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Base32Crockford
+import net.taler.lib.wallet.Base32Crockford
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha256Test.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha256Test.kt
index 3209e05..a71734a 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha256Test.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha256Test.kt
@@ -14,9 +14,8 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Base32Crockford
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha512Test.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha512Test.kt
index 24be282..59fd730 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/Sha512Test.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/Sha512Test.kt
@@ -14,9 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Base32Crockford
+import net.taler.lib.wallet.Base32Crockford
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/SignatureTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/SignatureTest.kt
index 1306c14..b3228b9 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/crypto/SignatureTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/crypto/SignatureTest.kt
@@ -14,16 +14,16 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.crypto
+package net.taler.lib.wallet.crypto
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Base32Crockford
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.crypto.Signature.PurposeBuilder
-import net.taler.wallet.kotlin.exchange.DenominationRecord
-import net.taler.wallet.kotlin.exchange.DenominationStatus.Unverified
-import net.taler.wallet.kotlin.exchange.DenominationStatus.VerifiedBad
-import net.taler.wallet.kotlin.exchange.WireFee
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.Base32Crockford
+import net.taler.lib.wallet.crypto.Signature.PurposeBuilder
+import net.taler.lib.wallet.exchange.DenominationRecord
+import net.taler.lib.wallet.exchange.DenominationStatus.Unverified
+import net.taler.lib.wallet.exchange.DenominationStatus.VerifiedBad
+import net.taler.lib.wallet.exchange.WireFee
import kotlin.random.Random
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/DenominationTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/DenominationTest.kt
index f48c97d..c52638b 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/DenominationTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/DenominationTest.kt
@@ -14,17 +14,17 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.exchange
+package net.taler.lib.wallet.exchange
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.Timestamp.Companion.NEVER
-import net.taler.wallet.kotlin.exchange.DenominationStatus.VerifiedBad
-import net.taler.wallet.kotlin.exchange.DenominationStatus.VerifiedGood
-import net.taler.wallet.kotlin.exchange.Denominations.denomination1
-import net.taler.wallet.kotlin.exchange.Denominations.denomination10
-import net.taler.wallet.kotlin.exchange.Denominations.denomination2
-import net.taler.wallet.kotlin.exchange.Denominations.denomination5
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.common.Timestamp.Companion.NEVER
+import net.taler.lib.wallet.exchange.DenominationStatus.VerifiedBad
+import net.taler.lib.wallet.exchange.DenominationStatus.VerifiedGood
+import net.taler.lib.wallet.exchange.Denominations.denomination1
+import net.taler.lib.wallet.exchange.Denominations.denomination10
+import net.taler.lib.wallet.exchange.Denominations.denomination2
+import net.taler.lib.wallet.exchange.Denominations.denomination5
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/Denominations.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/Denominations.kt
index 8cfd7fe..10a2772 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/Denominations.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/Denominations.kt
@@ -14,12 +14,12 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.exchange
+package net.taler.lib.wallet.exchange
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.exchange.DenominationStatus.Unverified
-import net.taler.wallet.kotlin.exchange.DenominationStatus.VerifiedGood
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.exchange.DenominationStatus.Unverified
+import net.taler.lib.wallet.exchange.DenominationStatus.VerifiedGood
object Denominations {
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/KeysTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/KeysTest.kt
index a6b0c98..a40c7cd 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/KeysTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/KeysTest.kt
@@ -14,13 +14,13 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.exchange
+package net.taler.lib.wallet.exchange
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.getMockHttpClient
-import net.taler.wallet.kotlin.giveJsonResponse
-import net.taler.wallet.kotlin.runCoroutine
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.getMockHttpClient
+import net.taler.lib.wallet.giveJsonResponse
+import net.taler.lib.wallet.runCoroutine
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/UpdateTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/UpdateTest.kt
index 271dc09..15e6d80 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/UpdateTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/UpdateTest.kt
@@ -14,9 +14,9 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.exchange
+package net.taler.lib.wallet.exchange
-import net.taler.wallet.kotlin.runCoroutine
+import net.taler.lib.wallet.runCoroutine
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertTrue
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/WireTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/WireTest.kt
index d09b44b..16671a9 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/exchange/WireTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/exchange/WireTest.kt
@@ -14,13 +14,13 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.exchange
+package net.taler.lib.wallet.exchange
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.Timestamp
-import net.taler.wallet.kotlin.getMockHttpClient
-import net.taler.wallet.kotlin.giveJsonResponse
-import net.taler.wallet.kotlin.runCoroutine
+import net.taler.lib.common.Amount
+import net.taler.lib.common.Timestamp
+import net.taler.lib.wallet.getMockHttpClient
+import net.taler.lib.wallet.giveJsonResponse
+import net.taler.lib.wallet.runCoroutine
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/operations/WithdrawTest.kt b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/operations/WithdrawTest.kt
index 541f24f..634a9dd 100644
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/operations/WithdrawTest.kt
+++ b/wallet/src/commonTest/kotlin/net/taler/lib/wallet/operations/WithdrawTest.kt
@@ -14,23 +14,23 @@
* GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-package net.taler.wallet.kotlin.operations
+package net.taler.lib.wallet.operations
-import net.taler.wallet.kotlin.Amount
-import net.taler.wallet.kotlin.exchange.DenominationSelectionInfo
-import net.taler.wallet.kotlin.exchange.Denominations.denomination0d01
-import net.taler.wallet.kotlin.exchange.Denominations.denomination0d1
-import net.taler.wallet.kotlin.exchange.Denominations.denomination1
-import net.taler.wallet.kotlin.exchange.Denominations.denomination10
-import net.taler.wallet.kotlin.exchange.Denominations.denomination2
-import net.taler.wallet.kotlin.exchange.Denominations.denomination4
-import net.taler.wallet.kotlin.exchange.Denominations.denomination5
-import net.taler.wallet.kotlin.exchange.Denominations.denomination8
-import net.taler.wallet.kotlin.exchange.SelectedDenomination
-import net.taler.wallet.kotlin.getMockHttpClient
-import net.taler.wallet.kotlin.giveJsonResponse
-import net.taler.wallet.kotlin.operations.Withdraw.BankDetails
-import net.taler.wallet.kotlin.runCoroutine
+import net.taler.lib.common.Amount
+import net.taler.lib.wallet.exchange.DenominationSelectionInfo
+import net.taler.lib.wallet.exchange.Denominations.denomination0d01
+import net.taler.lib.wallet.exchange.Denominations.denomination0d1
+import net.taler.lib.wallet.exchange.Denominations.denomination1
+import net.taler.lib.wallet.exchange.Denominations.denomination10
+import net.taler.lib.wallet.exchange.Denominations.denomination2
+import net.taler.lib.wallet.exchange.Denominations.denomination4
+import net.taler.lib.wallet.exchange.Denominations.denomination5
+import net.taler.lib.wallet.exchange.Denominations.denomination8
+import net.taler.lib.wallet.exchange.SelectedDenomination
+import net.taler.lib.wallet.getMockHttpClient
+import net.taler.lib.wallet.giveJsonResponse
+import net.taler.lib.wallet.operations.Withdraw.BankDetails
+import net.taler.lib.wallet.runCoroutine
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/AmountTest.kt b/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/AmountTest.kt
deleted file mode 100644
index 08ee618..0000000
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/AmountTest.kt
+++ /dev/null
@@ -1,276 +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.wallet.kotlin
-
-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 {
-
- companion object {
- private val charPool: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
- fun getRandomString(minLength: Int = 1, maxLength: Int = Random.nextInt(0, 1337)) = (minLength..maxLength)
- .map { Random.nextInt(0, charPool.size) }
- .map(charPool::get)
- .joinToString("")
-
- fun getRandomAmount() = getRandomAmount(getRandomString(1, Random.nextInt(1, 12)))
-
- fun getRandomAmount(currency: String): Amount {
- val value = Random.nextLong(0, Amount.MAX_VALUE)
- val fraction = Random.nextInt(0, Amount.MAX_FRACTION)
- return Amount(currency, value, fraction)
- }
- }
-
- @Test
- fun testFromJSONString() {
- var str = "TESTKUDOS:23.42"
- var amount = Amount.fromJSONString(str)
- assertEquals(str, amount.toJSONString())
- assertEquals("TESTKUDOS", amount.currency)
- assertEquals(23, amount.value)
- assertEquals((0.42 * 1e8).toInt(), amount.fraction)
- assertEquals("23.42 TESTKUDOS", amount.toString())
-
- str = "EUR:500000000.00000001"
- amount = Amount.fromJSONString(str)
- assertEquals(str, amount.toJSONString())
- assertEquals("EUR", amount.currency)
- assertEquals(500000000, amount.value)
- assertEquals(1, amount.fraction)
- assertEquals("500000000.00000001 EUR", amount.toString())
-
- str = "EUR:1500000000.00000003"
- amount = Amount.fromJSONString(str)
- assertEquals(str, amount.toJSONString())
- assertEquals("EUR", amount.currency)
- assertEquals(1500000000, amount.value)
- assertEquals(3, amount.fraction)
- assertEquals("1500000000.00000003 EUR", amount.toString())
- }
-
- @Test
- fun testFromJSONStringAcceptsMaxValuesRejectsAbove() {
- val maxValue = 4503599627370496
- val str = "TESTKUDOS123:$maxValue.99999999"
- val amount = Amount.fromJSONString(str)
- assertEquals(str, amount.toJSONString())
- assertEquals("TESTKUDOS123", amount.currency)
- assertEquals(maxValue, amount.value)
- assertEquals("$maxValue.99999999 TESTKUDOS123", amount.toString())
-
- // longer currency not accepted
- assertThrows<AmountParserException>("longer currency was accepted") {
- Amount.fromJSONString("TESTKUDOS1234:$maxValue.99999999")
- }
-
- // max value + 1 not accepted
- assertThrows<AmountParserException>("max value + 1 was accepted") {
- Amount.fromJSONString("TESTKUDOS123:${maxValue + 1}.99999999")
- }
-
- // max fraction + 1 not accepted
- assertThrows<AmountParserException>("max fraction + 1 was accepted") {
- Amount.fromJSONString("TESTKUDOS123:$maxValue.999999990")
- }
- }
-
- @Test
- fun testFromJSONStringRejections() {
- assertThrows<AmountParserException> {
- Amount.fromJSONString("TESTKUDOS:0,5")
- }
- assertThrows<AmountParserException> {
- Amount.fromJSONString("+TESTKUDOS:0.5")
- }
- assertThrows<AmountParserException> {
- Amount.fromJSONString("0.5")
- }
- assertThrows<AmountParserException> {
- Amount.fromJSONString(":0.5")
- }
- assertThrows<AmountParserException> {
- Amount.fromJSONString("EUR::0.5")
- }
- assertThrows<AmountParserException> {
- Amount.fromJSONString("EUR:.5")
- }
- }
-
- @Test
- fun testAddition() {
- assertEquals(
- Amount.fromJSONString("EUR:2"),
- Amount.fromJSONString("EUR:1") + Amount.fromJSONString("EUR:1")
- )
- assertEquals(
- Amount.fromJSONString("EUR:3"),
- Amount.fromJSONString("EUR:1.5") + Amount.fromJSONString("EUR:1.5")
- )
- assertEquals(
- Amount.fromJSONString("EUR:500000000.00000002"),
- Amount.fromJSONString("EUR:500000000.00000001") + Amount.fromJSONString("EUR:0.00000001")
- )
- assertThrows<AmountOverflowException>("addition didn't overflow") {
- Amount.fromJSONString("EUR:4503599627370496.99999999") + Amount.fromJSONString("EUR:0.00000001")
- }
- assertThrows<AmountOverflowException>("addition didn't overflow") {
- Amount.fromJSONString("EUR:4000000000000000") + Amount.fromJSONString("EUR:4000000000000000")
- }
- }
-
- @Test
- fun testTimes() {
- assertEquals(
- Amount.fromJSONString("EUR:2"),
- Amount.fromJSONString("EUR:2") * 1
- )
- assertEquals(
- Amount.fromJSONString("EUR:2"),
- Amount.fromJSONString("EUR:1") * 2
- )
- assertEquals(
- Amount.fromJSONString("EUR:4.5"),
- Amount.fromJSONString("EUR:1.5") * 3
- )
- assertEquals(Amount.fromJSONString("EUR:0"), Amount.fromJSONString("EUR:1.11") * 0)
- assertEquals(Amount.fromJSONString("EUR:1.11"), Amount.fromJSONString("EUR:1.11") * 1)
- assertEquals(Amount.fromJSONString("EUR:2.22"), Amount.fromJSONString("EUR:1.11") * 2)
- assertEquals(Amount.fromJSONString("EUR:3.33"), Amount.fromJSONString("EUR:1.11") * 3)
- assertEquals(Amount.fromJSONString("EUR:4.44"), Amount.fromJSONString("EUR:1.11") * 4)
- assertEquals(Amount.fromJSONString("EUR:5.55"), Amount.fromJSONString("EUR:1.11") * 5)
- assertEquals(
- Amount.fromJSONString("EUR:1500000000.00000003"),
- Amount.fromJSONString("EUR:500000000.00000001") * 3
- )
- assertThrows<AmountOverflowException>("times didn't overflow") {
- Amount.fromJSONString("EUR:4000000000000000") * 2
- }
- }
-
- @Test
- fun testSubtraction() {
- assertEquals(
- Amount.fromJSONString("EUR:0"),
- Amount.fromJSONString("EUR:1") - Amount.fromJSONString("EUR:1")
- )
- assertEquals(
- Amount.fromJSONString("EUR:1.5"),
- Amount.fromJSONString("EUR:3") - Amount.fromJSONString("EUR:1.5")
- )
- assertEquals(
- Amount.fromJSONString("EUR:500000000.00000001"),
- Amount.fromJSONString("EUR:500000000.00000002") - Amount.fromJSONString("EUR:0.00000001")
- )
- assertThrows<AmountOverflowException>("subtraction didn't underflow") {
- Amount.fromJSONString("EUR:23.42") - Amount.fromJSONString("EUR:42.23")
- }
- assertThrows<AmountOverflowException>("subtraction didn't underflow") {
- Amount.fromJSONString("EUR:0.5") - Amount.fromJSONString("EUR:0.50000001")
- }
- }
-
- @Test
- fun testIsZero() {
- assertTrue(Amount.zero("EUR").isZero())
- assertTrue(Amount.fromJSONString("EUR:0").isZero())
- assertTrue(Amount.fromJSONString("EUR:0.0").isZero())
- assertTrue(Amount.fromJSONString("EUR:0.00000").isZero())
- assertTrue((Amount.fromJSONString("EUR:1.001") - Amount.fromJSONString("EUR:1.001")).isZero())
-
- assertFalse(Amount.fromJSONString("EUR:0.00000001").isZero())
- assertFalse(Amount.fromJSONString("EUR:1.0").isZero())
- assertFalse(Amount.fromJSONString("EUR:0001.0").isZero())
- }
-
- @Test
- fun testComparision() {
- assertTrue(Amount.fromJSONString("EUR:0") <= Amount.fromJSONString("EUR:0"))
- assertTrue(Amount.fromJSONString("EUR:0") <= Amount.fromJSONString("EUR:0.00000001"))
- assertTrue(Amount.fromJSONString("EUR:0") < Amount.fromJSONString("EUR:0.00000001"))
- assertTrue(Amount.fromJSONString("EUR:0") < Amount.fromJSONString("EUR:1"))
- assertEquals(Amount.fromJSONString("EUR:0"), Amount.fromJSONString("EUR:0"))
- assertEquals(Amount.fromJSONString("EUR:42"), Amount.fromJSONString("EUR:42"))
- assertEquals(Amount.fromJSONString("EUR:42.00000001"), Amount.fromJSONString("EUR:42.00000001"))
- assertTrue(Amount.fromJSONString("EUR:42.00000001") >= Amount.fromJSONString("EUR:42.00000001"))
- assertTrue(Amount.fromJSONString("EUR:42.00000002") >= Amount.fromJSONString("EUR:42.00000001"))
- assertTrue(Amount.fromJSONString("EUR:42.00000002") > Amount.fromJSONString("EUR:42.00000001"))
- assertTrue(Amount.fromJSONString("EUR:0.00000002") > Amount.fromJSONString("EUR:0.00000001"))
- assertTrue(Amount.fromJSONString("EUR:0.00000001") > Amount.fromJSONString("EUR:0"))
- assertTrue(Amount.fromJSONString("EUR:2") > Amount.fromJSONString("EUR:1"))
-
- assertThrows<IllegalStateException>("could compare amounts with different currencies") {
- Amount.fromJSONString("EUR:0.5") < Amount.fromJSONString("USD:0.50000001")
- }
- }
-
- @Test
- fun testToByteArray() {
- val vectors = listOf(
- Pair("ceicWVf9GhJ:3902026702525079.40496378", "006XSQV3G899E0K9XKX66SB9CDBNCSHS8XM4M00"),
- Pair("asYDLuK2A:3800267550024600.02072907", "006R0MNXBVHSG00ZM55P2WTS8H67AJSJ8400000"),
- Pair("pV1m:1347558259914570.09786232", "002CK66VCNVMM04NADW70NHHDM0000000000000"),
- Pair("geO82l:553744321840253.41004983", "000ZF855K627T0KHNYVPESAF70S6R0000000000"),
- Pair("B9bWK7WPEO:3663912678613976.12122563", "006G8KS5P9HXG05RZ71M4EB2AX5KENTG8N7G000"),
- Pair("X:1537372109907438.77850768", "002QCETPFYJYW153X285G000000000000000000"),
- Pair("5:4271492725553118.39728399", "007JSSK6J4VXW0JY6M7KA000000000000000000"),
- Pair("OSdV:801656289790342.08256189", "001DJ6H6CA4RC03XZAYMYMV4AR0000000000000"),
- Pair("Y6:2908617536334646.94126271", "0055AQTB19NKC1CW82ZNJDG0000000000000000"),
- Pair("kSHoOZj:2610656582865206.00292046", "004MCR6T828KC004EK76PMT8DX7NMTG00000000"),
- Pair("GkhLXrlGES:4246330707533398.83874252", "007HC0Z9DFF5C17ZT764ETV89HC74V278N9G000"),
- Pair("CNS09:738124490298524.71259462", "0019YMG01DA9R11ZAN346KJK60WG00000000000"),
- Pair("sw0b1tKXZym:2132978464977419.28199478", "003S7VNZPZS0P0DE98V76XSGC8RQ8JTRB9WPT00"),
- Pair("fC:1275322307696988.17178522", "0028FSGX3ZCNR0863YD6CGR0000000000000000"),
- Pair("cRai6j:166032749022734.69444771", "0009E0C30V70W113MJHP6MK1D4V6M0000000000"),
- Pair("KOADwTb3:3932974019564218.48282023", "006ZJ16ZB39BM0Q0Q6KMPKT18HVN8RHK0000000"),
- Pair("9Fi9wcLgDe:1268366772151214.97268853", "002834N6WRHTW1EC6HTKJHK975VP6K378HJG000"),
- Pair("SDN:3370670470236379.88943272", "005ZK6V0124DP1AD5AM56H2E000000000000000"),
- Pair("zGCP5V:4010014441349620.76121145", "0073Y5HYA8GZ8149GGWQMHT3A0TNC0000000000"),
- Pair("VsW1JjBLn:2037070181191907.99717275", "003KSD2WH18E61FHJ2DNCWTQ6556MGJCDR00000"),
- Pair("A:1806895799429502.00887758", "0036PQ5P8NMQW00DHF742000000000000000000"),
- Pair("njA8:4015261148004966.43708687", "00747PYPD116C0MTY47PWTJ1700000000000000"),
- Pair("Bwq:3562876074139250.28829179", "006AGTNTRWF740DQWQXM4XVH000000000000000"),
- Pair("8e75v8:3716241006992995.95213823", "006K7SP93WF661DCV3ZKGS9Q6NV3G0000000000"),
- Pair("XrnbQTTn:3887603772953949.94721267", "006WZGA9X8ANT1D5AKSNGWKEC98N8N3E0000000"),
- Pair("MIN:0.00000001", "0000000000000000000MTJAE000000000000000"),
- Pair("MAX:4503599627370496.99999999", "00800000000001FNW3ZMTGAR000000000000000")
- )
- for (v in vectors) {
- val amount = Amount.fromJSONString(v.first)
- val encodedBytes = Base32Crockford.encode(amount.toByteArray())
- assertEquals(v.second, encodedBytes)
- }
- }
-
- 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/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TalerUriTest.kt b/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TalerUriTest.kt
deleted file mode 100644
index cfcc8bd..0000000
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/TalerUriTest.kt
+++ /dev/null
@@ -1,65 +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.wallet.kotlin
-
-import net.taler.wallet.kotlin.TalerUri.WithdrawUriResult
-import net.taler.wallet.kotlin.TalerUri.parseWithdrawUri
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertNull
-
-class TalerUriTest {
-
- @Test
- fun testParseWithdrawUri() {
- // correct parsing
- var uri = "taler://withdraw/bank.example.com/12345"
- var expected = WithdrawUriResult("https://bank.example.com/", "12345")
- assertEquals(expected, parseWithdrawUri(uri))
-
- // correct parsing with insecure http
- uri = "taler+http://withdraw/bank.example.org/foo"
- expected = WithdrawUriResult("http://bank.example.org/", "foo")
- assertEquals(expected, parseWithdrawUri(uri))
-
- // correct parsing with long path
- uri = "taler://withdraw/bank.example.com/foo/bar/23/42/1337/1234567890"
- expected = WithdrawUriResult("https://bank.example.com/foo/bar/23/42/1337", "1234567890")
- assertEquals(expected, parseWithdrawUri(uri))
-
- // rejects incorrect scheme
- uri = "talerx://withdraw/bank.example.com/12345"
- assertNull(parseWithdrawUri(uri))
-
- // rejects incorrect authority
- uri = "taler://withdrawx/bank.example.com/12345"
- assertNull(parseWithdrawUri(uri))
-
- // rejects incorrect authority with insecure http
- uri = "taler+http://withdrawx/bank.example.com/12345"
- assertNull(parseWithdrawUri(uri))
-
- // rejects empty withdrawalId
- uri = "taler://withdraw/bank.example.com//"
- assertNull(parseWithdrawUri(uri))
-
- // rejects empty path and withdrawalId
- uri = "taler://withdraw/bank.example.com////"
- assertNull(parseWithdrawUri(uri))
- }
-
-}
diff --git a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/VersionTest.kt b/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/VersionTest.kt
deleted file mode 100644
index d445ebc..0000000
--- a/wallet/src/commonTest/kotlin/net/taler/wallet/kotlin/VersionTest.kt
+++ /dev/null
@@ -1,57 +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.wallet.kotlin
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertNull
-
-class VersionTest {
-
- @Test
- fun testComparision() {
- assertNull(compareVersions("0:0:0", ""))
- assertNull(compareVersions("", "0:0:0"))
- assertNull(compareVersions("foo", "0:0:0"))
- assertNull(compareVersions("0:0:0", "foo"))
- assertEquals(
- VersionMatchResult(true, 0),
- compareVersions("0:0:0", "0:0:0")
- )
- assertEquals(
- VersionMatchResult(true, -1),
- compareVersions("0:0:0", "1:0:1")
- )
- assertEquals(
- VersionMatchResult(true, -1),
- compareVersions("0:0:0", "1:5:1")
- )
- assertEquals(
- VersionMatchResult(false, -1),
- compareVersions("0:0:0", "1:5:0")
- )
- assertEquals(
- VersionMatchResult(false, 1),
- compareVersions("1:0:0", "0:5:0")
- )
- assertEquals(
- VersionMatchResult(true, 0),
- compareVersions("1:0:1", "1:5:1")
- )
- }
-
-}