From e012d2c2f5a8a6c3e50c85b8d50bbd6dff064d1d Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 3 Nov 2015 16:52:27 +0100 Subject: [PATCH] TestUtils: add some formatting toString methods to make test failures easier to read. --- {tests => src}/TestUtils.kt | 9 +++++++++ src/Utils.kt | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) rename {tests => src}/TestUtils.kt (93%) diff --git a/tests/TestUtils.kt b/src/TestUtils.kt similarity index 93% rename from tests/TestUtils.kt rename to src/TestUtils.kt index 202c7c8150..759c85fb20 100644 --- a/tests/TestUtils.kt +++ b/src/TestUtils.kt @@ -7,6 +7,7 @@ class DummyPublicKey(private val s: String) : PublicKey, Comparable { override fun getEncoded() = s.toByteArray() override fun getFormat() = "ASN.1" override fun compareTo(other: PublicKey): Int = BigInteger(encoded).compareTo(BigInteger(other.encoded)) + override fun toString() = "PUBKEY[$s]" } // A few dummy values for testing. @@ -81,6 +82,14 @@ data class TransactionForTest( tx.body() return tx } + + override fun toString(): String { + return """transaction { + inputs: $inStates + outputs: $outStates + args: $args + }""" + } } fun transaction(body: TransactionForTest.() -> Unit): TransactionForTest { diff --git a/src/Utils.kt b/src/Utils.kt index 1c7a7e7414..8855099dae 100644 --- a/src/Utils.kt +++ b/src/Utils.kt @@ -43,6 +43,9 @@ val USD = Currency.getInstance("USD") val GBP = Currency.getInstance("GBP") val CHF = Currency.getInstance("CHF") -val Int.DOLLARS: Amount get() = Amount(this, USD) -val Int.POUNDS: Amount get() = Amount(this, GBP) -val Int.SWISS_FRANCS: Amount get() = Amount(this, CHF) \ No newline at end of file +val Int.DOLLARS: Amount get() = Amount(this * 100, USD) +val Int.POUNDS: Amount get() = Amount(this * 100, GBP) +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) \ No newline at end of file