Skip to content

Commit 594f27e

Browse files
committed
Update test project
1 parent 0741284 commit 594f27e

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

tests-publication/build.gradle.kts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
* Copyright (c) 2023-2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
6-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.*
7-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsExtension
8-
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.*
5+
import org.jetbrains.kotlin.gradle.*
96

107
plugins {
11-
kotlin("multiplatform") version "1.9.22"
8+
kotlin("multiplatform") version "2.0.20"
129
}
1310

1411
kotlin {
@@ -57,12 +54,12 @@ kotlin {
5754
}
5855
commonTest.dependencies {
5956
implementation(kotlin("test"))
60-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
57+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
6158
}
6259
jsMain.dependencies {
6360
implementation(cryptographyLibs.provider.webcrypto)
6461
}
65-
named("wasmJsMain").dependencies {
62+
wasmJsMain.dependencies {
6663
implementation(cryptographyLibs.provider.webcrypto)
6764
}
6865
jvmMain.dependencies {
@@ -73,14 +70,3 @@ kotlin {
7370
}
7471
}
7572
}
76-
77-
// node version with WASM support
78-
plugins.withType<NodeJsRootPlugin> {
79-
kotlinNodeJsExtension.apply {
80-
nodeVersion = "21.0.0-v8-canary202310177990572111"
81-
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
82-
}
83-
tasks.withType<KotlinNpmInstallTask>().configureEach {
84-
args.add("--ignore-engines")
85-
}
86-
}

tests-publication/src/commonTest/kotlin/JustTest.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,22 @@
33
*/
44

55
import dev.whyoleg.cryptography.*
6-
import dev.whyoleg.cryptography.algorithms.digest.*
6+
import dev.whyoleg.cryptography.algorithms.*
77
import kotlinx.coroutines.test.*
88
import kotlin.test.*
99

1010
class JustTest {
1111

12+
@OptIn(ExperimentalStdlibApi::class)
1213
@Test
1314
fun test() = runTest {
1415
val digest =
1516
CryptographyProvider.Default
1617
.get(SHA256)
1718
.hasher()
1819
.hash("Hello World".encodeToByteArray())
19-
.let(::printHexBinary)
20+
.toHexString()
2021

2122
assertEquals("a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e", digest)
2223
}
2324
}
24-
25-
private const val hexCode = "0123456789ABCDEF"
26-
internal fun printHexBinary(data: ByteArray): String {
27-
val r = StringBuilder(data.size * 2)
28-
for (b in data) {
29-
r.append(hexCode[b.toInt() shr 4 and 0xF])
30-
r.append(hexCode[b.toInt() and 0xF])
31-
}
32-
return r.toString().lowercase()
33-
}

0 commit comments

Comments
 (0)