diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/ConfederationCeremonyJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/ConfederationCeremonyJvmTest.kt index 709e2e80..0f59be2d 100644 --- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/ConfederationCeremonyJvmTest.kt +++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/ConfederationCeremonyJvmTest.kt @@ -335,6 +335,33 @@ class ConfederationCeremonyJvmTest { ceremonies(opened.id).values.forEach { assertEquals(ConfederationCeremonyStage.COMPLETE, it?.stage, it?.failureReason) } } + // ---- pinned before the coordinator goes (docs/confederation-without-coordinator.md, Phase 1) + + @Test + fun `today an opening sent by anyone but the coordinator is refused`() { + val (host, proposalId) = network(listOf(listOf(11, 12, 13), listOf(21, 22, 23), listOf(31, 32, 33))) + val opened = open(host, proposalId) + val impostor = npub(secret(21)) + pump { payload -> if (payload.kind == ConfederationRitualEvents.OPENING) payload.copy(publicKey = impostor) else payload } + ceremonies(opened.id).filterKeys { it != host.person && it != impostor }.values.forEach { + assertEquals(ConfederationCeremonyStage.FAILED, it?.stage) + assertTrue(it!!.failureReason!!.contains("someone other than the proposal's coordinator"), it.failureReason) + } + } + + @Test + fun `today every device waits on the coordinator's broadcast`() { + val (host, proposalId) = network(listOf(listOf(11, 12, 13), listOf(21, 22, 23), listOf(31, 32, 33))) + val opened = open(host, proposalId) + pump() + joinAll(opened.id) + // The broadcast never arrives: it is turned into a kind nobody reads. + pump { payload -> if (payload.kind == ConfederationRitualEvents.BROADCAST) payload.copy(kind = 30386) else payload } + ceremonies(opened.id).filterKeys { it != host.person }.values.forEach { + assertEquals(ConfederationCeremonyStage.DEALING, it?.stage, "every dealing is in, and still nobody moves") + } + } + // ---- Phase 13: the confederation's room ---------------------------------------------- private fun formed(): Pair { diff --git a/docs/confederation-without-coordinator.md b/docs/confederation-without-coordinator.md index 91c154fe..6974e4bd 100644 --- a/docs/confederation-without-coordinator.md +++ b/docs/confederation-without-coordinator.md @@ -495,6 +495,14 @@ This document and its row in [README.md](./README.md). Then, before code: - a ceremony waits on the coordinator's 30383 (Phase 7 flips it); - only the coordinator's device makes the confederation's room (Phase 8 flips it). +**Done.** Two of the four were pinned already: `ConfederationNetworkJvmTest`'s "the coordinator's +device says what forming it would take, and nobody else's says anything" (`outcome` is null on +every other device) and `ConfederationCeremonyJvmTest`'s "a member's key package missing holds the +room back, and nobody else's device makes it". The other two are new tests in +`ConfederationCeremonyJvmTest` rather than a file of their own, since they need its devices: +"today an opening sent by anyone but the coordinator is refused" and "today every device waits on +the coordinator's broadcast". + ### Phase 2: the wire, and the storage `K/nostr/confederation/`: