mirror of
https://github.com/corda/corda.git
synced 2025-01-18 18:56:28 +00:00
Minor: add a unit testing utility to unwrap exceptions to their root cause.
This commit is contained in:
parent
c24d991a7e
commit
0064f7c254
@ -10,6 +10,7 @@
|
||||
|
||||
package core.testutils
|
||||
|
||||
import com.google.common.base.Throwables
|
||||
import contracts.*
|
||||
import core.*
|
||||
import core.crypto.*
|
||||
@ -23,6 +24,15 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.test.fail
|
||||
|
||||
/** If an exception is thrown by the body, rethrows the root cause exception. */
|
||||
inline fun <R> rootCauseExceptions(body: () -> R) : R {
|
||||
try {
|
||||
return body()
|
||||
} catch(e: Exception) {
|
||||
throw Throwables.getRootCause(e)
|
||||
}
|
||||
}
|
||||
|
||||
object TestUtils {
|
||||
val keypair = generateKeyPair()
|
||||
val keypair2 = generateKeyPair()
|
||||
|
Loading…
Reference in New Issue
Block a user