diff --git a/src/test/kotlin/core/testutils/TestUtils.kt b/src/test/kotlin/core/testutils/TestUtils.kt index 88531b6c65..4f8fee651f 100644 --- a/src/test/kotlin/core/testutils/TestUtils.kt +++ b/src/test/kotlin/core/testutils/TestUtils.kt @@ -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 rootCauseExceptions(body: () -> R) : R { + try { + return body() + } catch(e: Exception) { + throw Throwables.getRootCause(e) + } +} + object TestUtils { val keypair = generateKeyPair() val keypair2 = generateKeyPair()