mirror of
https://github.com/corda/corda.git
synced 2025-06-18 07:08:15 +00:00
Tx validation detect duplicate inputs (#138)
* Move duplicate input detection to transaction verification Duplicate detection was previously part of the NotaryFlow.
This commit is contained in:
committed by
Andrius Dagys
parent
44065243bb
commit
6b7edf5af6
@ -103,25 +103,6 @@ class NotaryServiceTests {
|
||||
assertEquals(f1.resultFuture.getOrThrow(), f2.resultFuture.getOrThrow())
|
||||
}
|
||||
|
||||
@Test fun `should report conflict when inputs are reused within a single transactions`() {
|
||||
val stx = run {
|
||||
val inputState = issueState(clientNode)
|
||||
// Use inputState twice as input of a single transaction.
|
||||
val tx = TransactionType.General.Builder(notaryNode.info.notaryIdentity).withItems(inputState, inputState)
|
||||
tx.signWith(clientNode.keyPair!!)
|
||||
tx.toSignedTransaction(false)
|
||||
}
|
||||
|
||||
val future = clientNode.services.startFlow(NotaryFlow.Client(stx))
|
||||
|
||||
net.runNetwork()
|
||||
|
||||
val ex = assertFailsWith(NotaryException::class) { future.resultFuture.getOrThrow() }
|
||||
val notaryError = ex.error as NotaryError.Conflict
|
||||
assertEquals(notaryError.tx, stx.tx)
|
||||
notaryError.conflict.verified()
|
||||
}
|
||||
|
||||
@Test fun `should report conflict when inputs are reused across transactions`() {
|
||||
val inputState = issueState(clientNode)
|
||||
val stx = run {
|
||||
|
Reference in New Issue
Block a user