Minor: add a unit test to verify that duplicated inputs are forbidden (conflict) and delete the TODO for it.

This commit is contained in:
Mike Hearn 2015-11-19 13:09:46 +01:00
parent 7f13b8ab4a
commit 9681f97502
2 changed files with 21 additions and 4 deletions

View File

@ -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. */

View File

@ -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()
}
}
}
}