Modern Apps git

← Modern-Apps.git

library-e2ee-p2p: run PQC tests hermetically, no silent pass (#tests)

Commit
5e5665e394c89627a9f501ab3dedb523cee6260c
Author
Vayun Mathur <[email protected]>
When
2026-11-15 17:18 UTC (20 days ago)
Parents
f35c434
PqcTest (3 tests) and the two identity tests in
E2eeHkdfIdentityTest silently returned when the Rust PQC library
was not loadable, so CI counted them as passes while exercising
no ML-KEM/ML-DSA or identity code at all.

The host library is built for JVM tests via cargoBuildHost
(libe2ee_pqc, wired by wireRustHostLibsForUnitTests like every
other Rust module), so unavailability is a build failure. The
guards now assert it, with that message.

Verified: :library:e2ee-p2p:testDebugUnitTest green, 14 tests,
0 skipped / 0 silent passes.

Diff

library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/E2eeHkdfIdentityTest.kt
diff --git a/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/E2eeHkdfIdentityTest.kt b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/E2eeHkdfIdentityTest.ktindex 897ea0374b..d1a94fdd3f 100644--- a/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/E2eeHkdfIdentityTest.kt+++ b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/E2eeHkdfIdentityTest.kt@@ -100,9 +100,10 @@ class E2eeHkdfIdentityTest {      @Test     fun identityLoadOrCreatePersistsAndReloads() = runBlocking {-        // Native-gated like PqcTest: skip the keygen paths when the Rust lib is absent.+        // Native like PqcTest: the host lib is built for JVM tests, so an+        // unavailable lib is a build failure, not a silent pass.         val nativeAvailable = runCatching { Pqc.generateKem() }.isSuccess-        if (!nativeAvailable) return@runBlocking+        assertTrue(nativeAvailable, "host e2ee_pqc lib unavailable: cargoBuildHost must produce it for JVM tests")         val store = MemStore()         val first = PqcIdentity.loadOrCreate(store)         assertTrue(store.map.keys.containsAll(setOf("pqcKemPub", "pqcKemPriv", "pqcDsaPub", "pqcDsaPriv")))@@ -124,7 +125,7 @@ class E2eeHkdfIdentityTest {     @Test     fun identityIncompleteStoreRegenerates() = runBlocking {         val nativeAvailable = runCatching { Pqc.generateKem() }.isSuccess-        if (!nativeAvailable) return@runBlocking+        assertTrue(nativeAvailable, "host e2ee_pqc lib unavailable: cargoBuildHost must produce it for JVM tests")         val store = MemStore()         // Only half an identity persisted: treated as absent, not as a broken identity.         store.map["pqcKemPub"] = byteArrayOf(1, 2, 3)
library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/PqcTest.kt
diff --git a/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/PqcTest.kt b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/PqcTest.ktindex fe56c0bb2a..c92135238e 100644--- a/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/PqcTest.kt+++ b/library/e2ee-p2p/src/test/java/com/vayunmathur/e2ee/PqcTest.kt@@ -18,13 +18,14 @@ class PqcTest {     @BeforeTest     fun checkNative() {         nativeAvailable = runCatching { Pqc.generateKem() }.isSuccess-        // Skipped when native lib not loadable on this host — was Assume.assumeTrue before.-        if (!nativeAvailable) return+        // The host lib is built for JVM tests (cargoBuildHost, like every other+        // Rust module): unavailable here is a build failure, not a skip.+        assertTrue(nativeAvailable, "host e2ee_pqc lib unavailable: cargoBuildHost must produce it for JVM tests")     }      @Test     fun ml_kem_encrypt_decrypt_roundtrip() {-        if (!nativeAvailable) return+        assertTrue(nativeAvailable)         val (kemPub, kemPriv) = Pqc.generateKem()         val (dsaPub, _) = Pqc.generateDsa()         val bundle = Pqc.bundle(kemPub, dsaPub)@@ -35,7 +36,7 @@ class PqcTest {      @Test     fun ml_dsa_sign_verify() {-        if (!nativeAvailable) return+        assertTrue(nativeAvailable)         val (kemPub, _) = Pqc.generateKem()         val (dsaPub, dsaPriv) = Pqc.generateDsa()         val bundle = Pqc.bundle(kemPub, dsaPub)@@ -51,7 +52,7 @@ class PqcTest {      @Test     fun security_code_matches_both_sides() {-        if (!nativeAvailable) return+        assertTrue(nativeAvailable)         val a = Pqc.bundle(Pqc.generateKem().first, Pqc.generateDsa().first)         val b = Pqc.bundle(Pqc.generateKem().first, Pqc.generateDsa().first)         assertTrue(Pqc.securityCode(a, b) == Pqc.securityCode(b, a)) // order-independent