mirror of
https://github.com/corda/corda.git
synced 2025-04-07 19:34:41 +00:00
Expand details provided when erroring due to missing signatures in notary flow
Signed-off-by: Ross Nicoll <ross.nicoll@r3.com>
This commit is contained in:
parent
a4254ac695
commit
1362a305c9
@ -1,8 +1,10 @@
|
||||
package net.corda.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.core.contracts.StateRef
|
||||
import net.corda.core.crypto.*
|
||||
import net.corda.core.crypto.DigitalSignature
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.crypto.SignedData
|
||||
import net.corda.core.crypto.signWithECDSA
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.node.services.TimestampChecker
|
||||
import net.corda.core.node.services.UniquenessException
|
||||
@ -48,7 +50,7 @@ object NotaryFlow {
|
||||
try {
|
||||
stx.verifySignatures(notaryParty.owningKey)
|
||||
} catch (ex: SignedTransaction.SignaturesMissingException) {
|
||||
throw NotaryException(NotaryError.SignaturesMissing(ex.missing))
|
||||
throw NotaryException(NotaryError.SignaturesMissing(ex))
|
||||
}
|
||||
|
||||
val response = sendAndReceive<Result>(notaryParty, SignRequest(stx))
|
||||
@ -182,9 +184,10 @@ sealed class NotaryError {
|
||||
/** Thrown if the time specified in the timestamp command is outside the allowed tolerance */
|
||||
class TimestampInvalid : NotaryError()
|
||||
|
||||
class TransactionInvalid : NotaryError()
|
||||
class TransactionInvalid(val msg: String) : NotaryError()
|
||||
class SignaturesInvalid(val msg: String): NotaryError()
|
||||
|
||||
class SignaturesMissing(val missingSigners: Set<CompositeKey>) : NotaryError() {
|
||||
override fun toString() = "Missing signatures from: ${missingSigners.map { it.toBase58String() }}"
|
||||
class SignaturesMissing(val cause: SignedTransaction.SignaturesMissingException) : NotaryError() {
|
||||
override fun toString() = cause.toString()
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ class ValidatingNotaryFlow(otherSide: Party,
|
||||
wtx.toLedgerTransaction(serviceHub).verify()
|
||||
} catch (e: Exception) {
|
||||
when (e) {
|
||||
is TransactionVerificationException,
|
||||
is SignatureException -> throw NotaryException(NotaryError.TransactionInvalid())
|
||||
is TransactionVerificationException -> NotaryException(NotaryError.TransactionInvalid(e.toString()))
|
||||
is SignatureException -> throw NotaryException(NotaryError.SignaturesInvalid(e.toString()))
|
||||
else -> throw e
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,7 @@ class ValidatingNotaryFlow(otherSide: Party,
|
||||
try {
|
||||
stx.verifySignatures(serviceHub.myInfo.notaryIdentity.owningKey)
|
||||
} catch(e: SignedTransaction.SignaturesMissingException) {
|
||||
throw NotaryException(NotaryError.SignaturesMissing(e.missing))
|
||||
throw NotaryException(NotaryError.SignaturesMissing(e))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class ValidatingNotaryServiceTests {
|
||||
val future = runClient(stx)
|
||||
|
||||
val ex = assertFailsWith(NotaryException::class) { future.getOrThrow() }
|
||||
assertThat(ex.error).isInstanceOf(NotaryError.TransactionInvalid::class.java)
|
||||
assertThat(ex.error).isInstanceOf(NotaryError.SignaturesInvalid::class.java)
|
||||
}
|
||||
|
||||
@Test fun `should report error for missing signatures`() {
|
||||
@ -73,7 +73,7 @@ class ValidatingNotaryServiceTests {
|
||||
val notaryError = ex.error
|
||||
assertThat(notaryError).isInstanceOf(NotaryError.SignaturesMissing::class.java)
|
||||
|
||||
val missingKeys = (notaryError as NotaryError.SignaturesMissing).missingSigners
|
||||
val missingKeys = (notaryError as NotaryError.SignaturesMissing).cause.missing
|
||||
assertEquals(setOf(expectedMissingKey), missingKeys)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user