refactor(quartz): swap FsEventStore clock ctor param for protected now()

The clock injection existed only for NIP-40 expiration tests. A public
constructor parameter that ~every caller ignores is API clutter, so
move it to a subclass seam:

- FsEventStore is now `open class`; no more `clock: () -> Long` param.
- `protected open fun now(): Long = TimeUtils.now()` is the override
  point. Production always takes the default; tests subclass.
- FsExpirationTest gains a private `ClockedStore(root, source)` that
  overrides `now()`. Semantics unchanged, all 113 fs tests still green.

Public `FsEventStore` ctor is now `(root, indexingStrategy, relay)` —
no behavioural-drift surface that callers have to learn.
This commit is contained in:
Claude
2026-04-25 02:58:08 +00:00
parent d4d2fa4676
commit 265943907a
3 changed files with 29 additions and 12 deletions
@@ -40,13 +40,24 @@ class FsExpirationTest {
private lateinit var root: Path
private var clockNow: Long = 1_000_000
private lateinit var store: FsEventStore
/**
* Test subclass overriding the `now()` seam so we can drive NIP-40
* expiration at exact timestamps — no wall-clock sleeps, no flakes.
*/
private class ClockedStore(
root: Path,
private val source: () -> Long,
) : FsEventStore(root) {
override fun now(): Long = source()
}
private lateinit var store: ClockedStore
@BeforeTest
fun setup() {
Secp256k1Instance
root = Files.createTempDirectory("fs-exp-")
store = FsEventStore(root, clock = { clockNow })
store = ClockedStore(root) { clockNow }
}
@AfterTest