mirror of
https://github.com/corda/corda.git
synced 2024-12-24 15:16:45 +00:00
Standardise error messages regarding state issuance
This makes the error messages when verifying state issuance consistent between Cash, CommercialPaper and Obligation contracts, in preparation for introducing a common issue clause between the contracts.
This commit is contained in:
parent
7655356ec2
commit
0404ef4f62
@ -165,10 +165,10 @@ public class JavaCommercialPaper implements Contract {
|
||||
if (cmd.getValue() instanceof JavaCommercialPaper.Commands.Issue) {
|
||||
State output = single(outputs);
|
||||
if (!inputs.isEmpty()) {
|
||||
throw new IllegalStateException("Failed Requirement: there is no input state");
|
||||
throw new IllegalStateException("Failed Requirement: output values sum to more than the inputs");
|
||||
}
|
||||
if (output.faceValue.getQuantity() == 0) {
|
||||
throw new IllegalStateException("Failed Requirement: the face value is not zero");
|
||||
throw new IllegalStateException("Failed Requirement: output values sum to more than the inputs");
|
||||
}
|
||||
|
||||
TimestampCommand timestampCommand = tx.getTimestampByName("Notary Service");
|
||||
@ -182,7 +182,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
}
|
||||
|
||||
if (!cmd.getSigners().contains(output.issuance.getParty().getOwningKey())) {
|
||||
throw new IllegalStateException("Failed Requirement: the issuance is signed by the claimed issuer of the paper");
|
||||
throw new IllegalStateException("Failed Requirement: output states are issued by a command signer");
|
||||
}
|
||||
} else {
|
||||
// Everything else (Move, Redeem) requires inputs (they are not first to be actioned)
|
||||
|
@ -115,13 +115,13 @@ class CommercialPaper : Contract {
|
||||
val time = timestamp?.before ?: throw IllegalArgumentException("Issuances must be timestamped")
|
||||
requireThat {
|
||||
// Don't allow people to issue commercial paper under other entities identities.
|
||||
"the issuance is signed by the claimed issuer of the paper" by
|
||||
"output states are issued by a command signer" by
|
||||
(output.issuance.party.owningKey in command.signers)
|
||||
"the face value is not zero" by (output.faceValue.quantity > 0)
|
||||
"output values sum to more than the inputs" by (output.faceValue.quantity > 0)
|
||||
"the maturity date is not in the past" by (time < output.maturityDate)
|
||||
// Don't allow an existing CP state to be replaced by this issuance.
|
||||
// TODO: Consider how to handle the case of mistaken issuances, or other need to patch.
|
||||
"there is no input state" by inputs.isEmpty()
|
||||
"output values sum to more than the inputs" by inputs.isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ abstract class FungibleAsset<T> : Contract {
|
||||
val assetCommands = tx.commands.select<FungibleAsset.Commands>()
|
||||
requireThat {
|
||||
"the issue command has a nonce" by (issueCommand.value.nonce != 0L)
|
||||
"output deposits are owned by a command signer" by (issuer in issueCommand.signingParties)
|
||||
"output states are issued by a command signer" by (issuer in issueCommand.signingParties)
|
||||
"output values sum to more than the inputs" by (outputAmount > inputAmount)
|
||||
"there is only a single issue command" by (assetCommands.count() == 1)
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ class Obligation<P> : Contract {
|
||||
val outputAmount: Amount<P> = outputs.sumObligations<P>()
|
||||
requireThat {
|
||||
"the issue command has a nonce" by (issueCommand.value.nonce != 0L)
|
||||
"output deposits are owned by a command signer" by (obligor in issueCommand.signingParties)
|
||||
"output states are issued by a command signer" by (obligor in issueCommand.signingParties)
|
||||
"output values sum to more than the inputs" by (outputAmount > inputAmount)
|
||||
"valid settlement issuance definition is not this issuance definition" by inputs.none { it.issuanceDef in it.acceptableIssuanceDefinitions }
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class CommercialPaperTestsGeneric {
|
||||
output { thisTest.getPaper() }
|
||||
command(DUMMY_PUBKEY_1) { thisTest.getIssueCommand() }
|
||||
timestamp(TEST_TX_TIME)
|
||||
this `fails with` "signed by the claimed issuer"
|
||||
this `fails with` "output states are issued by a command signer"
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class CommercialPaperTestsGeneric {
|
||||
output { thisTest.getPaper().withFaceValue(0.DOLLARS `issued by` issuer) }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand() }
|
||||
timestamp(TEST_TX_TIME)
|
||||
this `fails with` "face value is not zero"
|
||||
this `fails with` "output values sum to more than the inputs"
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ class CommercialPaperTestsGeneric {
|
||||
output { thisTest.getPaper() }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand() }
|
||||
timestamp(TEST_TX_TIME)
|
||||
this `fails with` "there is no input state"
|
||||
this `fails with` "output values sum to more than the inputs"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class CashTests {
|
||||
transaction {
|
||||
output { outState }
|
||||
command(DUMMY_PUBKEY_1) { Cash.Commands.Issue() }
|
||||
this `fails with` "output deposits are owned by a command signer"
|
||||
this `fails with` "output states are issued by a command signer"
|
||||
}
|
||||
transaction {
|
||||
output {
|
||||
|
@ -96,7 +96,7 @@ class ObligationTests {
|
||||
transaction {
|
||||
output { outState }
|
||||
command(DUMMY_PUBKEY_1) { Obligation.Commands.Issue(outState.issuanceDef) }
|
||||
this `fails with` "output deposits are owned by a command signer"
|
||||
this `fails with` "output states are issued by a command signer"
|
||||
}
|
||||
transaction {
|
||||
output {
|
||||
|
Loading…
Reference in New Issue
Block a user