c19bd4e92e
The in-process relay was usable but every consumer test paid a 10–15
line tax for scope/client setup, manual cleanup inside the test body
(leaks on assertion failure), hardcoded "ws://127.0.0.1:7770/" magic
strings, and an inline collectUntilEose pattern reinvented per file.
Net: ~250 LOC removed, every test gets correct @After cleanup, and
the synthetic event builders no longer ship in geode's production jar.
- Move geode.fixtures (synthetic event builders) and the new
geode.testing package from src/main to a new src/testFixtures
source set via the java-test-fixtures plugin. Production geode jar
no longer includes them; consumers wire them with
testImplementation(testFixtures(project(":geode"))).
- Add geode.testing.RelayClientTest open class — owns hub, scope,
client, defaultRelay, defaultRelayUrl with @After-driven cleanup.
- Add geode.testing.collectUntilEose / collectUntilEoseMulti
NostrClient extensions with a shared subId counter and timeout knob.
Replaces hand-rolled subscriber loops in 4+ files.
- Add RelayHub.DEFAULT_URL constant so tests stop typing
"ws://127.0.0.1:7770/" inline.
- Migrate the 8 quartz NostrClient*Test files + geode's
Nip01ComplianceTest to extend RelayClientTest and (where REQ/EOSE
is the pattern) call collectUntilEose. Delete the redundant
BaseNostrClientTest wrapper.
88 lines
2.9 KiB
Kotlin
88 lines
2.9 KiB
Kotlin
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
alias(libs.plugins.jetbrainsKotlinJvm)
|
|
alias(libs.plugins.serialization)
|
|
application
|
|
`java-test-fixtures`
|
|
}
|
|
|
|
application {
|
|
mainClass.set("com.vitorpamplona.geode.MainKt")
|
|
applicationName = "geode"
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(21)
|
|
compilerOptions {
|
|
jvmTarget.set(JvmTarget.JVM_21)
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
kotlin.srcDir("src/main/kotlin")
|
|
}
|
|
test {
|
|
kotlin.srcDir("src/test/kotlin")
|
|
}
|
|
// The `java-test-fixtures` plugin auto-creates a `testFixtures`
|
|
// source set; we just point it at our Kotlin layout so the
|
|
// `geode.fixtures` (synthetic events) and `geode.testing`
|
|
// (RelayClientTest, collectUntilEose) packages don't ship in
|
|
// production jars but are still usable by every consumer's test
|
|
// source via `testImplementation(testFixtures(project(":geode")))`.
|
|
named("testFixtures") {
|
|
kotlin.srcDir("src/testFixtures/kotlin")
|
|
}
|
|
}
|
|
|
|
tasks.withType<Test>().configureEach {
|
|
// Forward `-DrunLoadBenchmark=true` to the test JVM so the
|
|
// perf.LoadBenchmark tests opt in. Off by default — load tests
|
|
// are noisy and slow.
|
|
systemProperty("runLoadBenchmark", System.getProperty("runLoadBenchmark") ?: "false")
|
|
// Show println output from test JVM so the benchmark numbers are
|
|
// actually visible without grepping the report XML.
|
|
testLogging {
|
|
showStandardStreams =
|
|
(System.getProperty("runLoadBenchmark") == "true")
|
|
events("standard_out")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
api(project(":quartz"))
|
|
|
|
implementation(libs.kotlinx.coroutines.core)
|
|
implementation(libs.jackson.module.kotlin)
|
|
implementation(libs.kotlinx.serialization.json)
|
|
|
|
// Bundled SQLite driver — Relay's default in-memory EventStore creates
|
|
// an in-memory DB at runtime.
|
|
implementation(libs.androidx.sqlite.bundled.jvm)
|
|
|
|
// Ktor server engine + WebSocket plugin so Relay can serve real ws://
|
|
// traffic. CIO is the coroutine-based engine — lighter than Netty.
|
|
api(libs.ktor.server.core)
|
|
api(libs.ktor.server.cio)
|
|
api(libs.ktor.server.websockets)
|
|
|
|
// TOML parsing for the operator config file. Mirrors the section
|
|
// layout of nostr-rs-relay's config.toml so existing operators can
|
|
// port their configs nearly verbatim.
|
|
implementation(libs.fourkoma)
|
|
|
|
// testFixtures: code in src/testFixtures/kotlin (RelayClientTest +
|
|
// synthetic event builders). Not shipped in the production jar but
|
|
// exposed to consumers via testImplementation(testFixtures(...)).
|
|
testFixturesApi(project(":quartz"))
|
|
testFixturesApi(libs.junit)
|
|
testFixturesImplementation(libs.kotlinx.coroutines.core)
|
|
|
|
testImplementation(libs.kotlin.test)
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
testImplementation(libs.secp256k1.kmp.jni.jvm)
|
|
testImplementation(libs.okhttp)
|
|
}
|