mirror of
https://github.com/corda/corda.git
synced 2025-01-30 08:04:16 +00:00
Give nicer backtraces in tests by just throwing AssertionError directly, document the test DSL
This commit is contained in:
parent
983003a562
commit
ce3d339c62
@ -1,6 +1,5 @@
|
|||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
import kotlin.test.assertTrue
|
|
||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
|
|
||||||
class DummyPublicKey(private val s: String) : PublicKey, Comparable<PublicKey> {
|
class DummyPublicKey(private val s: String) : PublicKey, Comparable<PublicKey> {
|
||||||
@ -23,7 +22,26 @@ val keyToCorpMap: Map<PublicKey, Institution> = mapOf(
|
|||||||
MINI_CORP_KEY to MINI_CORP
|
MINI_CORP_KEY to MINI_CORP
|
||||||
)
|
)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// DSL for building pseudo-transactions (not the same as the wire protocol) for testing purposes.
|
// DSL for building pseudo-transactions (not the same as the wire protocol) for testing purposes.
|
||||||
|
//
|
||||||
|
// Define a transaction like this:
|
||||||
|
//
|
||||||
|
// transaction {
|
||||||
|
// input { someExpression }
|
||||||
|
// output { someExpression }
|
||||||
|
// arg { someExpression }
|
||||||
|
//
|
||||||
|
// transaction {
|
||||||
|
// ... same thing but works with a copy of the parent, can add inputs/outputs/args just within this scope.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// contract.accepts() -> should pass
|
||||||
|
// contract `fails requirement` "some substring of the error message"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TODO: Make it impossible to forget to test either a failure or an accept for each transaction{} block
|
||||||
|
|
||||||
// Corresponds to the args to Contract.verify
|
// Corresponds to the args to Contract.verify
|
||||||
data class TransactionForTest(
|
data class TransactionForTest(
|
||||||
@ -43,7 +61,7 @@ data class TransactionForTest(
|
|||||||
if (m == null)
|
if (m == null)
|
||||||
fail("Threw exception without a message")
|
fail("Threw exception without a message")
|
||||||
else
|
else
|
||||||
assertTrue(m.contains(msg), "Error was actually: $m")
|
if (!m.contains(msg)) throw AssertionError("Error was actually: $m")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user