-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Apple crash when creating seed with empty string passphrase (#146)
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apollo/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.iohk.atala.prism.apollo.derivation | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.fail | ||
|
||
class MnemonicTests { | ||
@Test | ||
fun testCreatingSeedWithEmptyPassphrase() { | ||
val words = listOf( | ||
"bicycle", | ||
"monster", | ||
"swap", | ||
"cave", | ||
"bulk", | ||
"fossil", | ||
"nominee", | ||
"crisp", | ||
"tail", | ||
"parent", | ||
"fossil", | ||
"eyebrow", | ||
"fold", | ||
"manage", | ||
"custom", | ||
"burst", | ||
"flight", | ||
"lawn", | ||
"survey", | ||
"snake", | ||
"brown", | ||
"bridge", | ||
"hard", | ||
"perfect" | ||
) | ||
val passphrase = "" | ||
|
||
assertDoesNotThrow { | ||
MnemonicHelper.Companion.createSeed(words, passphrase) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Asserts that the given executable does not throw an exception. | ||
* | ||
* @param block The executable function to be tested. | ||
* @throws AssertionError if the executable throws any exception. | ||
*/ | ||
inline fun assertDoesNotThrow(block: () -> Unit) { | ||
try { | ||
block() | ||
} catch (e: Exception) { | ||
fail("Expected no exception to be thrown, but got ${e.stackTraceToString()}") | ||
} | ||
} |