refactor(geode): test fixtures + collectUntilEose helper, move to testFixtures sourceSet
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.
This commit is contained in:
@@ -4,6 +4,7 @@ plugins {
|
||||
alias(libs.plugins.jetbrainsKotlinJvm)
|
||||
alias(libs.plugins.serialization)
|
||||
application
|
||||
`java-test-fixtures`
|
||||
}
|
||||
|
||||
application {
|
||||
@@ -25,6 +26,15 @@ sourceSets {
|
||||
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 {
|
||||
@@ -63,6 +73,13 @@ dependencies {
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user