From 9681f97502f6bd42b4be5a57db25d05ba4a3c711 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 19 Nov 2015 13:09:46 +0100 Subject: [PATCH] Minor: add a unit test to verify that duplicated inputs are forbidden (conflict) and delete the TODO for it. --- src/core/Transactions.kt | 4 ---- tests/core/TransactionGroupTests.kt | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/core/Transactions.kt b/src/core/Transactions.kt index b063331708..c604b61627 100644 --- a/src/core/Transactions.kt +++ b/src/core/Transactions.kt @@ -165,10 +165,6 @@ data class TimestampedWireTransaction( * A LedgerTransaction wraps the data needed to calculate one or more successor states from a set of input states. * It is the first step after extraction from a WireTransaction. The signatures at this point have been lined up * with the commands from the wire, and verified/looked up. - * - * Not used yet. - * - * TODO: When converting LedgerTransaction into TransactionForVerification, make sure to check for duped inputs. */ data class LedgerTransaction( /** The input states which will be consumed/invalidated by the execution of this transaction. */ diff --git a/tests/core/TransactionGroupTests.kt b/tests/core/TransactionGroupTests.kt index d2d737ad02..7fda18443c 100644 --- a/tests/core/TransactionGroupTests.kt +++ b/tests/core/TransactionGroupTests.kt @@ -97,4 +97,25 @@ class TransactionGroupTests { } assertEquals(e.hash, ref.txhash) } + + @Test + fun duplicatedInputs() { + // Check that a transaction cannot refer to the same input more than once. + transactionGroup { + roots { + transaction(A_THOUSAND_POUNDS label "£1000") + } + + transaction { + input("£1000") + input("£1000") + output { A_THOUSAND_POUNDS.copy(amount = A_THOUSAND_POUNDS.amount * 2) } + arg(MINI_CORP_KEY) { Cash.Commands.Move } + } + + assertFailsWith(TransactionConflictException::class) { + verify() + } + } + } } \ No newline at end of file