Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 3 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("project-report")
id("com.diffplug.spotless") version "8.4.0"
id("com.github.ben-manes.versions") version "0.54.0"
id("io.freefair.lombok") version "9.2.0"
id("io.freefair.lombok") version "9.4.0"
id("com.gradleup.nmcp").version("1.4.4")
kotlin("jvm") version "2.3.20"
}
Expand Down Expand Up @@ -60,9 +60,8 @@ dependencies {
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.11.3")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
testImplementation("io.kotest:kotest-assertions-core:5.9.1")
testImplementation("io.kotest:kotest-framework-datatest:5.9.1")
testImplementation("io.kotest:kotest-runner-junit5:6.1.11")
testImplementation("io.kotest:kotest-assertions-core:6.1.11")
}

tasks {
Expand Down
18 changes: 9 additions & 9 deletions src/test/kotlin/org/stellar/sdk/KeyPairTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.stellar.sdk

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.datatest.withTests
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import java.util.Base64
Expand Down Expand Up @@ -36,7 +36,7 @@ class KeyPairTest :
"gsYRSEQhTffqA9opPepAENCr2WG6z5iBHHubxxbRzWaHf8FBWcu",
)

withData(
withTests(
nameFn = { "should create keypair from secret seed ${it.first}" },
testKeypairs.toList(),
) { (seed, expectedAccountId) ->
Expand All @@ -56,11 +56,11 @@ class KeyPairTest :
newPair.accountId shouldBe original.accountId
}

withData(nameFn = { "should throw for invalid seed: $it" }, invalidSeeds) { invalidSeed ->
withTests(nameFn = { "should throw for invalid seed: $it" }, invalidSeeds) { invalidSeed ->
shouldThrow<IllegalArgumentException> { KeyPair.fromSecretSeed(invalidSeed) }
}

withData(nameFn = { "should throw for invalid seed char array: $it" }, invalidSeeds) {
withTests(nameFn = { "should throw for invalid seed char array: $it" }, invalidSeeds) {
invalidSeed ->
shouldThrow<IllegalArgumentException> { KeyPair.fromSecretSeed(invalidSeed.toCharArray()) }
}
Expand All @@ -79,15 +79,15 @@ class KeyPairTest :
"gsYRSEQhTffqA9opPepAENCr2WG6z5iBHHubxxbRzWaHf8FBWcu",
)

withData(nameFn = { "should create keypair from account ID $it" }, testKeypairs.values) {
withTests(nameFn = { "should create keypair from account ID $it" }, testKeypairs.values) {
accountId ->
val keypair = KeyPair.fromAccountId(accountId)

keypair.canSign() shouldBe false
keypair.accountId shouldBe accountId
}

withData(nameFn = { "should throw for invalid account ID: $it" }, invalidAccountIds) {
withTests(nameFn = { "should throw for invalid account ID: $it" }, invalidAccountIds) {
invalidAccountId ->
shouldThrow<IllegalArgumentException> { KeyPair.fromAccountId(invalidAccountId) }
}
Expand Down Expand Up @@ -220,7 +220,7 @@ class KeyPairTest :

data class MessageTestCase(val input: List<Byte>, val expectedSigHex: String)

withData(
withTests(
nameFn = { case -> "should sign and verify message: ${case.input}" },
listOf(
MessageTestCase(
Expand All @@ -243,7 +243,7 @@ class KeyPairTest :
messageKeypair.verifyMessage(inputAsByteArray, expectedSig) shouldBe true
}

withData(
withTests(
nameFn = { "should fail message verification with invalid signature: $it" },
listOf(
"540d7eee179f370bf634a49c1fa9fe4a58e3d7990b0207be336c04edfcc539ff8bd0c31bb2c0359b07c9651cb2ae104e4504657b5d17d43c69c7e50e23811b0d",
Expand Down Expand Up @@ -317,7 +317,7 @@ class KeyPairTest :
"SBPAJWWJJMPPOY2R726MFC7XHT4WXMJ2YCML6EB46UJZC5SIHCTLETT4",
)

withData(
withTests(
nameFn = { (index, account, _) ->
"should create keypair from BIP39 seed for account $index: $account"
},
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/org/stellar/sdk/PriceTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.stellar.sdk

import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.datatest.withTests
import io.kotest.matchers.shouldBe

data class PriceTestCase(
Expand All @@ -13,7 +13,7 @@ data class PriceTestCase(
class PriceTest :
FunSpec({
context("Price.fromString()") {
withData(
withTests(
nameFn = {
"should parse '${it.input}' to ${it.expectedNumerator}/${it.expectedDenominator}"
},
Expand Down
18 changes: 9 additions & 9 deletions src/test/kotlin/org/stellar/sdk/StrKeyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.stellar.sdk

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.datatest.withTests
import io.kotest.matchers.shouldBe

class StrKeyTest :
Expand All @@ -17,7 +17,7 @@ class StrKeyTest :
}

context("is valid") {
withData(
withTests(
nameFn = { "should be true for $it" },
"GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB",
"GB7KKHHVYLDIZEKYJPAJUOTBE5E3NJAXPSDZK7O6O44WR3EBRO5HRPVT",
Expand All @@ -33,7 +33,7 @@ class StrKeyTest :
StrKey.isValidEd25519PublicKey(publicKey) shouldBe true
}

withData(
withTests(
nameFn = { "should be false for $it" },
"GA3D5KRYM6CB7OWOOOORR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQHES5", // corrupted payload
"GBPXX0A5N4JYPESHAADMQKBPWZWQDQ64ZV6ZL2S3LAGW4SY7NTCMWIVL", // wrong checksum
Expand Down Expand Up @@ -63,7 +63,7 @@ class StrKeyTest :
}

context("should validate valid seeds") {
withData(
withTests(
nameFn = { "should be true for $it" },
"SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY",
"SCZTUEKSEH2VYZQC6VLOTOM4ZDLMAGV4LUMH4AASZ4ORF27V2X64F2S2",
Expand All @@ -77,7 +77,7 @@ class StrKeyTest :
}

context("should reject invalid seeds") {
withData(
withTests(
nameFn = { "should be false for $it" },
"GBJCHUKZMTFSLOMNC7P4TS4VJJBTCYL3XKSOLXAUJSD56C4LHND5TWUC", // wrong version
"SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDYT", // too long
Expand Down Expand Up @@ -249,7 +249,7 @@ class StrKeyTest :
"PBJCHUKZMTFSLOMNC7P4TS4VJJBTCYL3XKSOLXAUJSD56C4LHND5SAAAAAAQMAAAADDCO"
) shouldBe true
}
withData(
withTests(
nameFn = { "should be false for $it" },
"PA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAQACAQDAQCQMBYIBEFAWDANBYHRAEISCMKBKFQXDAMRUGY4DUPB6IAAAAAAAAPM",
"PA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAOQCAQDAQCQMBYIBEFAWDANBYHRAEISCMKBKFQXDAMRUGY4Z2PQ",
Expand Down Expand Up @@ -339,7 +339,7 @@ class StrKeyTest :

context("should reject all invalid StrKey cases") {
// https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0023.md
withData(
withTests(
nameFn = { "should throw IllegalArgumentException for $it" },
"GAAAAAAAACGC6",
"MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAACJUR",
Expand Down Expand Up @@ -412,7 +412,7 @@ class StrKeyTest :
)

context("round trip consistency") {
withData(
withTests(
nameFn = { "should handle ${it.description}" },
MuxedAccountTestCase(
"ID = 0",
Expand Down Expand Up @@ -473,7 +473,7 @@ class StrKeyTest :
}

context("error handling") {
withData(
withTests(
nameFn = { "should throw for ${it.first}" },
Pair("too short bytes (39)", 39),
Pair("too long bytes (41)", 41),
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/org/stellar/sdk/TOIDTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.stellar.sdk

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.datatest.withTests
import io.kotest.matchers.shouldBe

class TOIDTest :
Expand All @@ -12,7 +12,7 @@ class TOIDTest :
val opFirst = 1L

context("test toInt64 and fromInt64") {
withData(
withTests(
nameFn = { (toid, id) ->
"TOID(${toid.ledgerSequence}, ${toid.transactionOrder}, ${toid.operationIndex}) should be $id"
},
Expand Down
Loading