Address miklos' comments made in #5966 (#6315)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Remy 2020-06-12 16:33:52 +02:00 committed by GitHub
parent 31d5fb7304
commit 3351dd8963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -1370,7 +1370,7 @@ class EngineTest extends WordSpec with Matchers with EitherValues with BazelRunf
val fetchedCid = toContractId("#1")
val now = Time.Timestamp.now()
val submissionSeed = crypto.Hash.hashPrivateKey(
"fetching contracts that have keys correctly fills in the transaction structur")
"fetching contracts that have keys correctly fills in the transaction structure")
val txSeed = crypto.Hash.deriveTransactionSeed(submissionSeed, participant, now)
"fetched via a fetch" in {

View File

@ -154,7 +154,7 @@ object ValueGenerators {
Gen
.containerOfN[Array, Byte](crypto.Hash.underlyingHashLength, arbitrary[Byte]) map crypto.Hash.assertFromByteArray
private val genSuffixes: Gen[Bytes] = for {
sz <- Gen.chooseNum(0, ContractId.V1.maxSuffixLength)
sz <- Gen.chooseNum(0, ContractId.V1.MaxSuffixLength)
ab <- Gen.containerOfN[Array, Byte](sz, arbitrary[Byte])
} yield Bytes fromByteArray ab

View File

@ -364,15 +364,18 @@ object Value extends CidContainer1[Value] {
}
object V1 {
val maxSuffixLength = 94
// For more details, please refer to V1 Contract ID allocation scheme
// daml-lf/spec/contract-id.rst
private[lf] val MaxSuffixLength = 94
def apply(discriminator: Hash): V1 = new V1(discriminator, Bytes.Empty)
def build(discriminator: crypto.Hash, suffix: Bytes): Either[String, V1] =
Either.cond(
suffix.length <= maxSuffixLength,
suffix.length <= MaxSuffixLength,
new V1(discriminator, suffix),
s"the suffix is too long, expected at most ${maxSuffixLength} bytes, but got ${suffix.length}"
s"the suffix is too long, expected at most $MaxSuffixLength bytes, but got ${suffix.length}"
)
def assertBuild(discriminator: crypto.Hash, suffix: Bytes): V1 =