Skip to content

Commit

Permalink
Disallow empty command submission
Browse files Browse the repository at this point in the history
Fixes #592
  • Loading branch information
stefanobaghino-da committed Oct 29, 2019
1 parent e887318 commit a39b9d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Expand Up @@ -41,7 +41,8 @@ final class CommandsValidator(ledgerId: LedgerId) {
let <- requirePresence(commands.ledgerEffectiveTime, "ledger_effective_time")
ledgerEffectiveTime = TimestampConversion.toInstant(let)
mrt <- requirePresence(commands.maximumRecordTime, "maximum_record_time")
validatedCommands <- validateInnerCommands(commands.commands, submitter)
commandz <- requireNonEmpty(commands.commands, "commands")
validatedCommands <- validateInnerCommands(commandz, submitter)
ledgerEffectiveTimestamp <- Time.Timestamp
.fromInstant(ledgerEffectiveTime)
.left
Expand Down
Expand Up @@ -248,6 +248,20 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi
assertGrpcError(failure, Status.Code.NOT_FOUND, s"Ledger ID '$invalidLedgerId' not found.")
}

private[this] val disallowEmptyCommandSubmission = LedgerTest(
"CSDisallowEmptyTransactionsSubmission",
"The submission of an empty command should be rejected with INVALID_ARGUMENT"
) { context =>
for {
ledger <- context.participant()
party <- ledger.allocateParty()
emptyRequest <- ledger.submitRequest(party)
failure <- ledger.submit(emptyRequest).failed
} yield {
assertGrpcError(failure, Status.Code.INVALID_ARGUMENT, "Missing field: commands")
}
}

override val tests: Vector[LedgerTest] = Vector(
submitAndWaitTest,
submitAndWaitForTransactionTest,
Expand All @@ -260,6 +274,7 @@ final class CommandService(session: LedgerSession) extends LedgerTestSuite(sessi
submitAndWaitWithInvalidLedgerIdTest,
submitAndWaitForTransactionIdWithInvalidLedgerIdTest,
submitAndWaitForTransactionWithInvalidLedgerIdTest,
submitAndWaitForTransactionTreeWithInvalidLedgerIdTest
submitAndWaitForTransactionTreeWithInvalidLedgerIdTest,
disallowEmptyCommandSubmission
)
}
6 changes: 6 additions & 0 deletions unreleased.rst
Expand Up @@ -10,3 +10,9 @@ HEAD — ongoing
--------------

- [DAML Compiler] Reduce the memory footprint of the IDE and the command line tools (ca. 18% in our experiments).
- [DAML Triggers] The trigger runner now supports triggers using the high-level API directly. These no longer need to be converted to low-level Triggers using ``runTrigger``. Triggers using the low-level API are still supported.
- [DAML Compiler] The package database is now be cleaned automatically on initialization.
This means that you should no longer have to run ``daml clean`` on SDK upgrades
if you use DAR dependencies (e.g. with DAML triggers).
- [Sandbox] Improve performance of looking up contracts from postgres. See `issue #2330 <https://github.com/digital-asset/daml/issues/2330>`__.
- [Ledger API] Disallow empty commands. See `issue #592 <https://github.com/digital-asset/daml/issues/592>`__.

0 comments on commit a39b9d2

Please sign in to comment.