Improve divulgence warning message. (#10595)

Based on feedback from @bame-da on issue #9947

changelog_begin
changelog_end
This commit is contained in:
Sofia Faro 2021-08-17 13:06:03 +01:00 committed by GitHub
parent fd9d8724fc
commit fb09b72f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -693,14 +693,9 @@ main =
]
expectScriptSuccess rs (vr "testDivulge") $ \r ->
matchRegex r $ T.concat
[ "Warnings: \n"
, " Tried to fetch or exercise -homePackageId-:Test:T contract ContractId\\([0-9a-f]*\\) "
, "but none of the reading parties actAs = Set\\(p2\\), readAs = Set\\(\\) are a stakeholder TreeSet\\(p1\\). "
, "Use of divulged contracts is deprecated and incompatible with pruning\n"
, " Tried to fetch or exercise -homePackageId-:Test:T contract ContractId\\([0-9a-f]*\\) "
, "but none of the reading parties actAs = Set\\(p2\\), readAs = Set\\(\\) are a stakeholder TreeSet\\(p1\\). "
, "Use of divulged contracts is deprecated and incompatible with pruning$"
, " Tried to fetch or exercise -homePackageId-:Test:T on contract [0-9a-f]* but none of the reading parties \\[p2\\] are contract stakeholders \\[p1\\]. Use of divulged contracts is deprecated and incompatible with pruning. To remedy, add one of the readers \\[p2\\] as an observer to the contract.\n"
, " Tried to fetch or exercise -homePackageId-:Test:T on contract [0-9a-f]* but none of the reading parties \\[p2\\] are contract stakeholders \\[p1\\]. Use of divulged contracts is deprecated and incompatible with pruning. To remedy, add one of the readers \\[p2\\] as an observer to the contract."
],
testCase "multi-party query" $ do
rs <-

View File

@ -752,11 +752,13 @@ private[lf] object Speedy {
onLedger.visibleToStakeholders(contract.stakeholders) match {
case SVisibleToStakeholders.Visible => ()
case SVisibleToStakeholders.NotVisible(actAs, readAs) =>
val readers = (actAs union readAs).mkString(",")
val stakeholders = contract.stakeholders.mkString(",")
this.warningLog.add(
Warning(
commitLocation = onLedger.commitLocation,
message =
s"Tried to fetch or exercise ${contract.templateId} contract ${cid} but none of the reading parties actAs = ${actAs}, readAs = ${readAs} are a stakeholder ${contract.stakeholders}. Use of divulged contracts is deprecated and incompatible with pruning",
s"Tried to fetch or exercise ${contract.templateId} on contract ${cid.coid} but none of the reading parties [${readers}] are contract stakeholders [${stakeholders}]. Use of divulged contracts is deprecated and incompatible with pruning. To remedy, add one of the readers [${readers}] as an observer to the contract.",
)
)
}