mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
sandbox: Make sure we can get the details of an empty list of parties. (#5030)
This would fail only on PostgreSQL because `IN ()` is invalid. H2 seems to be fine with it. CHANGELOG_BEGIN - [Ledger API Server] Support a call to `GetParties` with an empty list of parties. CHANGELOG_END
This commit is contained in:
parent
04196597a7
commit
ad3c3b326b
@ -130,6 +130,7 @@ final class PartyManagement(session: LedgerSession) extends LedgerTestSuite(sess
|
||||
partyDetails <- ledger.getParties(
|
||||
Seq(party1, party2, binding.Primitive.Party("non-existent")))
|
||||
noPartyDetails <- ledger.getParties(Seq(binding.Primitive.Party("non-existent")))
|
||||
zeroPartyDetails <- ledger.getParties(Seq.empty)
|
||||
} yield {
|
||||
assert(
|
||||
partyDetails.sortBy(_.displayName) == Seq(
|
||||
@ -149,6 +150,9 @@ final class PartyManagement(session: LedgerSession) extends LedgerTestSuite(sess
|
||||
assert(
|
||||
noPartyDetails.isEmpty,
|
||||
s"Retrieved some parties when the party specified did not exist: $noPartyDetails")
|
||||
assert(
|
||||
zeroPartyDetails.isEmpty,
|
||||
s"Retrieved some parties when no parties were requested: $zeroPartyDetails")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1469,13 +1469,16 @@ private class JdbcLedgerDao(
|
||||
)
|
||||
|
||||
override def getParties(parties: Seq[Party]): Future[List[PartyDetails]] =
|
||||
dbDispatcher
|
||||
.executeSql("load_parties") { implicit conn =>
|
||||
SQL_SELECT_MULTIPLE_PARTIES
|
||||
.on("parties" -> parties)
|
||||
.as(PartyDataParser.*)
|
||||
}
|
||||
.map(_.map(constructPartyDetails))(executionContext)
|
||||
if (parties.isEmpty)
|
||||
Future.successful(List.empty)
|
||||
else
|
||||
dbDispatcher
|
||||
.executeSql("load_parties") { implicit conn =>
|
||||
SQL_SELECT_MULTIPLE_PARTIES
|
||||
.on("parties" -> parties)
|
||||
.as(PartyDataParser.*)
|
||||
}
|
||||
.map(_.map(constructPartyDetails))(executionContext)
|
||||
|
||||
override def listKnownParties(): Future[List[PartyDetails]] =
|
||||
dbDispatcher
|
||||
|
@ -455,6 +455,14 @@ class JdbcLedgerDaoSpec
|
||||
}
|
||||
}
|
||||
|
||||
"retrieve zero parties" in {
|
||||
for {
|
||||
noPartyDetails <- ledgerDao.getParties(Seq.empty)
|
||||
} yield {
|
||||
noPartyDetails should be(Seq.empty)
|
||||
}
|
||||
}
|
||||
|
||||
"retrieve a single party, if they exist" in {
|
||||
val party = Ref.Party.assertFromString(s"Carol-${UUID.randomUUID()}")
|
||||
val nonExistentParty = UUID.randomUUID().toString
|
||||
|
Loading…
Reference in New Issue
Block a user