Skip to content

Commit

Permalink
Address miklos' comment made in #5966
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
remyhaemmerle-da committed Jun 11, 2020
1 parent 5051383 commit ba0aab9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

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 =
Expand Down

0 comments on commit ba0aab9

Please sign in to comment.