fixed tests. better atomic operations

This commit is contained in:
sergeych committed 2023-12-05 00:57:16 +03:00
1 parent ce8cfe8e3d
commit b86c7a853e
6 files changed
+51 -13

No files matched your search

+6 -6
View File
@@ -11,7 +11,7 @@ class KeysTest {
@Test
fun testCreationAndMap() = runTest {
initCrypto()
val (stk,pbk) = SigningKey.Secret.pair()
val (stk,pbk) = SigningKey.pair()
val x = mapOf( stk to "STK!", pbk to "PBK!")
assertEquals("STK!", x[stk])
@@ -27,17 +27,17 @@ class KeysTest {
data1[0] = 0x01u
assertFalse(s.verify(data1))
val p2 = SigningKey.Secret.pair()
val p3 = SigningKey.Secret.pair()
val p2 = SigningKey.pair()
val p3 = SigningKey.pair()
val ms = SignedBox(data, s1) + p2.signing
val ms = SignedBox(data, s1) + p2.secretKey
// non tampered:
val ms1 = unpack<SignedBox>(pack(ms))
assertContentEquals(data, ms1.message)
assertTrue(pbk in ms1)
assertTrue(p2.aPublic in ms1)
assertTrue(p3.aPublic !in ms1)
assertTrue(p2.publicKey in ms1)
assertTrue(p3.publicKey !in ms1)
assertThrows<IllegalSignatureException> {
unpack<SignedBox>(pack(ms).also { it[3] = 1u })