Skip to content

Commit

Permalink
tests: add e2e tests, minor updates
Browse files Browse the repository at this point in the history
- updated endpoints
- unpack response with the `.expected` method
- this commit improves the robustness of the sdk by adding
e2e tests for the various classes
  • Loading branch information
astinz committed Dec 11, 2024
1 parent 825d303 commit c70f78c
Show file tree
Hide file tree
Showing 12 changed files with 4,453 additions and 5 deletions.
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kotlin = "2.0.21"
ktor = "3.0.1"
junit = "5.10.1"
graphql-multiplatform = "0.1.0-beta07"
logback-classic = "1.5.6"

[libraries]
bcs = { module = "xyz.mcxross.bcs:bcs", version = "0.1.2" }
Expand All @@ -25,6 +26,7 @@ ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.9.0" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version = "2.0.21" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback-classic" }

[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }
Expand Down
5 changes: 3 additions & 2 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,19 @@ kotlin {
dependsOn(androidJvmMain)
dependencies {
implementation(libs.ktor.client.cio)
implementation(libs.logback.classic)
}
}
linuxMain.dependencies { implementation(libs.ktor.client.curl) }
mingwMain.dependencies { implementation(libs.ktor.client.winhttp) }
}
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
java.toolchain.languageVersion.set(JavaLanguageVersion.of(20))

graphql {
client {
endpoint = "https://sui-mainnet.mystenlabs.com/graphql"
schemaFile = file("src/commonMain/resources/schema.graphql")
packageName = "xyz.mcxross.ksui.generated"
}
}
Expand Down
6 changes: 6 additions & 0 deletions lib/src/commonMain/kotlin/xyz/mcxross/ksui/model/Option.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ sealed class Option<out T> {
@Serializable data class Some<T>(val value: T) : Option<T>()

@Serializable object None : Option<Nothing>()

fun expect(message: String): T =
when (this) {
is Some -> value
is None -> throw NoSuchElementException(message)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ val NetworkToIndexerAPI =
"mainnet" to "https://sui-mainnet.mystenlabs.com/graphql",
"testnet" to "https://sui-testnet.mystenlabs.com/graphql",
"devnet" to "https://sui-devnet.mystenlabs.com/graphql",
"local" to "http://127.0.0.1:8090/v1/graphql",
"local" to "http://0.0.0.0:9125/graphql",
)

val NetworkToNodeAPI =
mapOf(
"mainnet" to "https://fullnode.mainnet.sui.io:443",
"testnet" to "https://fullnode.testnet.sui.io:443",
"devnet" to "https://fullnode.devnet.sui.io:443",
"local" to "http://0.0.0.0:9000",
"local" to "http://0.0.0.0:9124",
)

val NetworkToFaucetAPI =
mapOf(
"mainnet" to "https://faucet.mainnet.sui.io/gas",
"testnet" to "https://faucet.testnet.sui.io/gas",
"devnet" to "https://faucet.devnet.sui.io/gas",
"local" to "http://127.0.0.1:5003/gas",
"local" to "http://0.0.0.0:9123/gas",
)

val NetworkToChainId = mapOf("mainnet" to 1, "testnet" to 2, "randomnet" to 70)
Expand Down
Loading

0 comments on commit c70f78c

Please sign in to comment.