TestUtils: add some formatting toString methods to make test failures easier to read.

This commit is contained in:
Mike Hearn 2015-11-03 16:52:27 +01:00
parent 0c6c2df483
commit e012d2c2f5
2 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,7 @@ class DummyPublicKey(private val s: String) : PublicKey, Comparable<PublicKey> {
override fun getEncoded() = s.toByteArray() override fun getEncoded() = s.toByteArray()
override fun getFormat() = "ASN.1" override fun getFormat() = "ASN.1"
override fun compareTo(other: PublicKey): Int = BigInteger(encoded).compareTo(BigInteger(other.encoded)) override fun compareTo(other: PublicKey): Int = BigInteger(encoded).compareTo(BigInteger(other.encoded))
override fun toString() = "PUBKEY[$s]"
} }
// A few dummy values for testing. // A few dummy values for testing.
@ -81,6 +82,14 @@ data class TransactionForTest(
tx.body() tx.body()
return tx return tx
} }
override fun toString(): String {
return """transaction {
inputs: $inStates
outputs: $outStates
args: $args
}"""
}
} }
fun transaction(body: TransactionForTest.() -> Unit): TransactionForTest { fun transaction(body: TransactionForTest.() -> Unit): TransactionForTest {

View File

@ -43,6 +43,9 @@ val USD = Currency.getInstance("USD")
val GBP = Currency.getInstance("GBP") val GBP = Currency.getInstance("GBP")
val CHF = Currency.getInstance("CHF") val CHF = Currency.getInstance("CHF")
val Int.DOLLARS: Amount get() = Amount(this, USD) val Int.DOLLARS: Amount get() = Amount(this * 100, USD)
val Int.POUNDS: Amount get() = Amount(this, GBP) val Int.POUNDS: Amount get() = Amount(this * 100, GBP)
val Int.SWISS_FRANCS: Amount get() = Amount(this, CHF) val Int.SWISS_FRANCS: Amount get() = Amount(this * 100, CHF)
val Double.DOLLARS: Amount get() = Amount((this * 100).toInt(), USD)
val Double.POUNDS: Amount get() = Amount((this * 100).toInt(), USD)
val Double.SWISS_FRANCS: Amount get() = Amount((this * 100).toInt(), USD)