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:
+13
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user