[engine] stack-safe daml-lf archive decoding (#14964)

Transform our code for the protobuf-decoding phase to be stack-safe, by means of a Work trampoline. The code-style rules are:

runWork is never called in a nested context.
We introduce an explicit Work.Delay to break recursion.
Increase the size of the many-fields test from 120 to 160 fields.

(At 164 fields we run into the protobuf limit)

Part of: #13410
This commit is contained in:
nickchapman-da 2022-09-20 16:51:50 +01:00 committed by GitHub
parent a15f576308
commit 0ebe770e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 995 additions and 641 deletions

View File

@ -112,14 +112,14 @@ class DecodeV1Spec
val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build() val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build()
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
an[Error.Parsing] shouldBe thrownBy(moduleDecoder(version).decodeKind(input)) an[Error.Parsing] shouldBe thrownBy(moduleDecoder(version).decodeKindForTest(input))
} }
} }
"accept nat kind if lf version >= 1.7" in { "accept nat kind if lf version >= 1.7" in {
val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build() val input = DamlLf1.Kind.newBuilder().setNat(DamlLf1.Unit.newBuilder()).build()
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
moduleDecoder(version).decodeKind(input) shouldBe Ast.KNat moduleDecoder(version).decodeKindForTest(input) shouldBe Ast.KNat
} }
} }
} }
@ -141,7 +141,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(testCases) { natType => forEvery(testCases) { natType =>
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(natType)) an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeTypeForTest(natType))
} }
} }
} }
@ -154,10 +154,12 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(positiveTestCases) { (natType, nat) => forEvery(positiveTestCases) { (natType, nat) =>
decoder.uncheckedDecodeType(natType) shouldBe Ast.TNat(Numeric.Scale.assertFromInt(nat)) decoder.uncheckedDecodeTypeForTest(natType) shouldBe Ast.TNat(
Numeric.Scale.assertFromInt(nat)
)
} }
forEvery(negativeTestCases) { natType => forEvery(negativeTestCases) { natType =>
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(natType)) an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeTypeForTest(natType))
} }
} }
} }
@ -194,7 +196,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(decimalTestCases) { (input, expectedOutput) => forEvery(decimalTestCases) { (input, expectedOutput) =>
decoder.uncheckedDecodeType(input) shouldBe expectedOutput decoder.uncheckedDecodeTypeForTest(input) shouldBe expectedOutput
} }
} }
} }
@ -203,7 +205,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(numericTestCases) { (input, _) => forEvery(numericTestCases) { (input, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(input)) an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeTypeForTest(input))
} }
} }
} }
@ -212,7 +214,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(numericTestCases) { (input, expectedOutput) => forEvery(numericTestCases) { (input, expectedOutput) =>
decoder.uncheckedDecodeType(input) shouldBe expectedOutput decoder.uncheckedDecodeTypeForTest(input) shouldBe expectedOutput
} }
} }
} }
@ -221,7 +223,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(decimalTestCases) { (input, _) => forEvery(decimalTestCases) { (input, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(input)) an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeTypeForTest(input))
} }
} }
} }
@ -229,23 +231,25 @@ class DecodeV1Spec
"reject Any if version < 1.7" in { "reject Any if version < 1.7" in {
forEveryVersionSuchThat(_ < LV.Features.anyType) { version => forEveryVersionSuchThat(_ < LV.Features.anyType) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(buildPrimType(ANY))) an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeTypeForTest(buildPrimType(ANY)))
} }
} }
"accept Any if version >= 1.7" in { "accept Any if version >= 1.7" in {
forEveryVersionSuchThat(_ >= LV.Features.anyType) { version => forEveryVersionSuchThat(_ >= LV.Features.anyType) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
decoder.uncheckedDecodeType(buildPrimType(ANY)) shouldBe TAny decoder.uncheckedDecodeTypeForTest(buildPrimType(ANY)) shouldBe TAny
} }
} }
s"reject BigNumeric and RoundingMode if version < ${LV.Features.bigNumeric}" in { s"reject BigNumeric and RoundingMode if version < ${LV.Features.bigNumeric}" in {
forEveryVersionSuchThat(_ < LV.Features.bigNumeric) { version => forEveryVersionSuchThat(_ < LV.Features.bigNumeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
an[Error.Parsing] shouldBe thrownBy(decoder.uncheckedDecodeType(buildPrimType(BIGNUMERIC)))
an[Error.Parsing] shouldBe thrownBy( an[Error.Parsing] shouldBe thrownBy(
decoder.uncheckedDecodeType(buildPrimType(ROUNDING_MODE)) decoder.uncheckedDecodeTypeForTest(buildPrimType(BIGNUMERIC))
)
an[Error.Parsing] shouldBe thrownBy(
decoder.uncheckedDecodeTypeForTest(buildPrimType(ROUNDING_MODE))
) )
} }
} }
@ -253,8 +257,8 @@ class DecodeV1Spec
s"accept BigNumeric and RoundingMode if version >= ${LV.Features.bigNumeric}" in { s"accept BigNumeric and RoundingMode if version >= ${LV.Features.bigNumeric}" in {
forEveryVersionSuchThat(_ >= LV.Features.bigNumeric) { version => forEveryVersionSuchThat(_ >= LV.Features.bigNumeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
decoder.uncheckedDecodeType(buildPrimType(BIGNUMERIC)) shouldBe TBigNumeric decoder.uncheckedDecodeTypeForTest(buildPrimType(BIGNUMERIC)) shouldBe TBigNumeric
decoder.uncheckedDecodeType(buildPrimType(ROUNDING_MODE)) shouldBe TRoundingMode decoder.uncheckedDecodeTypeForTest(buildPrimType(ROUNDING_MODE)) shouldBe TRoundingMode
} }
} }
@ -301,11 +305,11 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.internedStrings) { version => forEveryVersionSuchThat(_ < LV.Features.internedStrings) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(negativeTestCases) { fieldNames => forEvery(negativeTestCases) { fieldNames =>
decoder.uncheckedDecodeType(buildTStructWithoutInterning(fieldNames)) decoder.uncheckedDecodeTypeForTest(buildTStructWithoutInterning(fieldNames))
} }
forEvery(positiveTestCases) { fieldNames => forEvery(positiveTestCases) { fieldNames =>
an[Error.Parsing] shouldBe thrownBy( an[Error.Parsing] shouldBe thrownBy(
decoder.uncheckedDecodeType(buildTStructWithoutInterning(fieldNames)) decoder.uncheckedDecodeTypeForTest(buildTStructWithoutInterning(fieldNames))
) )
} }
} }
@ -313,11 +317,11 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.internedStrings) { version => forEveryVersionSuchThat(_ >= LV.Features.internedStrings) { version =>
val decoder = moduleDecoder(version, stringTable) val decoder = moduleDecoder(version, stringTable)
forEvery(negativeTestCases) { fieldNames => forEvery(negativeTestCases) { fieldNames =>
decoder.uncheckedDecodeType(buildTStructWithInterning(fieldNames)) decoder.uncheckedDecodeTypeForTest(buildTStructWithInterning(fieldNames))
} }
forEvery(positiveTestCases) { fieldNames => forEvery(positiveTestCases) { fieldNames =>
an[Error.Parsing] shouldBe thrownBy( an[Error.Parsing] shouldBe thrownBy(
decoder.uncheckedDecodeType(buildTStructWithInterning(fieldNames)) decoder.uncheckedDecodeTypeForTest(buildTStructWithInterning(fieldNames))
) )
} }
} }
@ -332,7 +336,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(exceptionBuiltinTypes) { case (proto, bType) => forEvery(exceptionBuiltinTypes) { case (proto, bType) =>
val result = Try(decoder.uncheckedDecodeType(buildPrimType(proto))) val result = Try(decoder.uncheckedDecodeTypeForTest(buildPrimType(proto)))
if (version >= LV.Features.exceptions) if (version >= LV.Features.exceptions)
result shouldBe Success(Ast.TBuiltin(bType)) result shouldBe Success(Ast.TBuiltin(bType))
@ -385,7 +389,9 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.internedTypes) { version => forEveryVersionSuchThat(_ >= LV.Features.internedTypes) { version =>
val decoder = moduleDecoder(version, stringTable, dottedNameTable) val decoder = moduleDecoder(version, stringTable, dottedNameTable)
forEvery(testCases)(proto => an[Error.Parsing] shouldBe thrownBy(decoder.decodeType(proto))) forEvery(testCases)(proto =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeTypeForTest(proto))
)
} }
} }
@ -553,7 +559,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(negativeBuiltinTestCases) { (proto, scala) => forEvery(negativeBuiltinTestCases) { (proto, scala) =>
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -565,7 +571,7 @@ class DecodeV1Spec
forEvery(decimalBuiltinTestCases) { (proto, versionId, scala) => forEvery(decimalBuiltinTestCases) { (proto, versionId, scala) =>
if (LV.Major.V1.minorVersionOrdering.gteq(LV.Minor(versionId), version.minor)) if (LV.Major.V1.minorVersionOrdering.gteq(LV.Minor(versionId), version.minor))
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -576,7 +582,7 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(numericBuiltinTestCases) { (proto, _) => forEvery(numericBuiltinTestCases) { (proto, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toProtoExpr(proto), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
} }
} }
} }
@ -587,7 +593,7 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(numericBuiltinTestCases) { (proto, scala) => forEvery(numericBuiltinTestCases) { (proto, scala) =>
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -601,7 +607,7 @@ class DecodeV1Spec
forEvery(numericComparisonBuiltinCases) { (proto, scala) => forEvery(numericComparisonBuiltinCases) { (proto, scala) =>
if (proto != DamlLf1.BuiltinFunction.EQUAL_NUMERIC || version == LV.v1_7) if (proto != DamlLf1.BuiltinFunction.EQUAL_NUMERIC || version == LV.v1_7)
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -612,7 +618,7 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(decimalBuiltinTestCases) { (proto, _, _) => forEvery(decimalBuiltinTestCases) { (proto, _, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toProtoExpr(proto), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
} }
} }
} }
@ -635,7 +641,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(testCases) { string => forEvery(testCases) { string =>
inside(decoder.decodeExpr(toDecimalProto(string), "test")) { inside(decoder.decodeExprForTest(toDecimalProto(string), "test")) {
case Ast.EPrimLit(Ast.PLNumeric(num)) => case Ast.EPrimLit(Ast.PLNumeric(num)) =>
num shouldBe new BigDecimal(string).setScale(10) num shouldBe new BigDecimal(string).setScale(10)
} }
@ -659,7 +665,9 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(testCases) { string => forEvery(testCases) { string =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toDecimalProto(string), "test")) an[Error.Parsing] shouldBe thrownBy(
decoder.decodeExprForTest(toDecimalProto(string), "test")
)
} }
} }
} }
@ -667,11 +675,11 @@ class DecodeV1Spec
"reject numeric literal if version < 1.7" in { "reject numeric literal if version < 1.7" in {
val decoder = moduleDecoder(LV(LV.Major.V1, LV.Features.numeric.minor), ImmArraySeq("0.0")) val decoder = moduleDecoder(LV(LV.Major.V1, LV.Features.numeric.minor), ImmArraySeq("0.0"))
decoder.decodeExpr(toNumericProto(0), "test") decoder.decodeExprForTest(toNumericProto(0), "test")
forEveryVersionSuchThat(_ < LV.Features.numeric) { version => forEveryVersionSuchThat(_ < LV.Features.numeric) { version =>
val decoder = moduleDecoder(version, ImmArraySeq("0.0")) val decoder = moduleDecoder(version, ImmArraySeq("0.0"))
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toNumericProto(0), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toNumericProto(0), "test"))
} }
} }
@ -693,7 +701,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version, ImmArraySeq(testCases.map(_._2): _*)) val decoder = moduleDecoder(version, ImmArraySeq(testCases.map(_._2): _*))
forEvery(testCases) { (id, string) => forEvery(testCases) { (id, string) =>
inside(decoder.decodeExpr(toNumericProto(id), "test")) { inside(decoder.decodeExprForTest(toNumericProto(id), "test")) {
case Ast.EPrimLit(Ast.PLNumeric(num)) => case Ast.EPrimLit(Ast.PLNumeric(num)) =>
num shouldBe new BigDecimal(string) num shouldBe new BigDecimal(string)
} }
@ -718,8 +726,8 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version, ImmArraySeq("0." +: testCases.map(_._2): _*)) val decoder = moduleDecoder(version, ImmArraySeq("0." +: testCases.map(_._2): _*))
forEvery(testCases) { (id, _) => forEvery(testCases) { (id, _) =>
decoder.decodeExpr(toNumericProto(0), "test") decoder.decodeExprForTest(toNumericProto(0), "test")
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toNumericProto(id), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toNumericProto(id), "test"))
} }
} }
} }
@ -728,7 +736,9 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.numeric) { version => forEveryVersionSuchThat(_ >= LV.Features.numeric) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toDecimalProto("0.0"), "test")) an[Error.Parsing] shouldBe thrownBy(
decoder.decodeExprForTest(toDecimalProto("0.0"), "test")
)
} }
} }
@ -738,7 +748,7 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(comparisonBuiltinCases) { (proto, scala) => forEvery(comparisonBuiltinCases) { (proto, scala) =>
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -748,7 +758,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.genComparison) { version => forEveryVersionSuchThat(_ >= LV.Features.genComparison) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(comparisonBuiltinCases) { (proto, _) => forEvery(comparisonBuiltinCases) { (proto, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toProtoExpr(proto), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
} }
} }
} }
@ -757,7 +767,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.genComparison) { version => forEveryVersionSuchThat(_ >= LV.Features.genComparison) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(genericComparisonBuiltinCases) { (proto, scala) => forEvery(genericComparisonBuiltinCases) { (proto, scala) =>
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -766,7 +776,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.genComparison) { version => forEveryVersionSuchThat(_ < LV.Features.genComparison) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(genericComparisonBuiltinCases) { (proto, _) => forEvery(genericComparisonBuiltinCases) { (proto, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toProtoExpr(proto), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
} }
} }
} }
@ -775,7 +785,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ >= LV.Features.contractIdTextConversions) { version => forEveryVersionSuchThat(_ >= LV.Features.contractIdTextConversions) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(contractIdTextConversionCases) { (proto, scala) => forEvery(contractIdTextConversionCases) { (proto, scala) =>
decoder.decodeExpr(toProtoExpr(proto), "test") shouldBe scala decoder.decodeExprForTest(toProtoExpr(proto), "test") shouldBe scala
} }
} }
} }
@ -784,7 +794,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.Features.contractIdTextConversions) { version => forEveryVersionSuchThat(_ < LV.Features.contractIdTextConversions) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(contractIdTextConversionCases) { (proto, _) => forEvery(contractIdTextConversionCases) { (proto, _) =>
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(toProtoExpr(proto), "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
} }
} }
} }
@ -815,7 +825,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(exceptionBuiltinCases) { (proto, scala) => forEvery(exceptionBuiltinCases) { (proto, scala) =>
val result = Try(decoder.decodeExpr(toProtoExpr(proto), "test")) val result = Try(decoder.decodeExprForTest(toProtoExpr(proto), "test"))
if (version >= LV.Features.bigNumeric) if (version >= LV.Features.bigNumeric)
result shouldBe Success(scala) result shouldBe Success(scala)
@ -845,7 +855,7 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
forEvery(roundingModeTestCases) { (proto, scala) => forEvery(roundingModeTestCases) { (proto, scala) =>
val result = val result =
Try(decoder.decodeExpr(roundingToProtoExpr(proto), "test")) Try(decoder.decodeExprForTest(roundingToProtoExpr(proto), "test"))
if (version >= LV.Features.bigNumeric) if (version >= LV.Features.bigNumeric)
result shouldBe Success(Ast.EPrimLit(Ast.PLRoundingMode(scala))) result shouldBe Success(Ast.EPrimLit(Ast.PLRoundingMode(scala)))
@ -880,7 +890,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version, ImmArraySeq.empty, ImmArraySeq.empty, typeTable) val decoder = moduleDecoder(version, ImmArraySeq.empty, ImmArraySeq.empty, typeTable)
forEvery(exceptionBuiltinCases) { (proto, scala) => forEvery(exceptionBuiltinCases) { (proto, scala) =>
val result = Try(decoder.decodeExpr(proto, "test")) val result = Try(decoder.decodeExprForTest(proto, "test"))
if (version >= LV.Features.exceptions) if (version >= LV.Features.exceptions)
result shouldBe Success(scala) result shouldBe Success(scala)
@ -914,7 +924,7 @@ class DecodeV1Spec
val stringTable = ImmArraySeq("a") val stringTable = ImmArraySeq("a")
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version, stringTable, ImmArraySeq.empty, typeTable) val decoder = moduleDecoder(version, stringTable, ImmArraySeq.empty, typeTable)
val result = Try(decoder.decodeExpr(tryCatchExprProto, "test")) val result = Try(decoder.decodeExprForTest(tryCatchExprProto, "test"))
if (version >= LV.Features.exceptions) if (version >= LV.Features.exceptions)
result shouldBe Success(tryCatchExprScala) result shouldBe Success(tryCatchExprScala)
else else
@ -1044,7 +1054,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
forEvery(testCases) { (proto, scala) => forEvery(testCases) { (proto, scala) =>
val result = Try(interfacePrimitivesDecoder(version).decodeExpr(proto, "test")) val result = Try(interfacePrimitivesDecoder(version).decodeExprForTest(proto, "test"))
if (version < LV.Features.basicInterfaces) if (version < LV.Features.basicInterfaces)
inside(result) { case Failure(error) => error shouldBe a[Error.Parsing] } inside(result) { case Failure(error) => error shouldBe a[Error.Parsing] }
else else
@ -1134,7 +1144,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
forEvery(testCases) { (proto, scala) => forEvery(testCases) { (proto, scala) =>
val result = Try(interfacePrimitivesDecoder(version).decodeExpr(proto, "test")) val result = Try(interfacePrimitivesDecoder(version).decodeExprForTest(proto, "test"))
if (version < LV.Features.extendedInterfaces) if (version < LV.Features.extendedInterfaces)
inside(result) { case Failure(error) => error shouldBe a[Error.Parsing] } inside(result) { case Failure(error) => error shouldBe a[Error.Parsing] }
else else
@ -1198,7 +1208,7 @@ class DecodeV1Spec
val decoder = val decoder =
moduleDecoder(version, ImmArraySeq("Choice"), interfaceDottedNameTable, typeTable) moduleDecoder(version, ImmArraySeq("Choice"), interfaceDottedNameTable, typeTable)
val proto = DamlLf1.Expr.newBuilder().setUpdate(protoUpdate).build() val proto = DamlLf1.Expr.newBuilder().setUpdate(protoUpdate).build()
decoder.decodeExpr(proto, "test") shouldBe Ast.EUpdate(scala) decoder.decodeExprForTest(proto, "test") shouldBe Ast.EUpdate(scala)
} }
} }
} }
@ -1236,7 +1246,7 @@ class DecodeV1Spec
val decoder = val decoder =
moduleDecoder(version, ImmArraySeq("Choice"), interfaceDottedNameTable, typeTable) moduleDecoder(version, ImmArraySeq("Choice"), interfaceDottedNameTable, typeTable)
val proto = DamlLf1.Expr.newBuilder().setUpdate(exerciseInterfaceProto).build() val proto = DamlLf1.Expr.newBuilder().setUpdate(exerciseInterfaceProto).build()
decoder.decodeExpr(proto, "test") shouldBe Ast.EUpdate(exerciseInterfaceScala) decoder.decodeExprForTest(proto, "test") shouldBe Ast.EUpdate(exerciseInterfaceScala)
} }
} }
} }
@ -1413,7 +1423,7 @@ class DecodeV1Spec
forEveryVersion { version => forEveryVersion { version =>
val decoder = interfaceDefDecoder(version) val decoder = interfaceDefDecoder(version)
val result = Try(decoder.decodeDefInterface(interfaceName, requiresDefInterface)) val result = Try(decoder.decodeDefInterfaceForTest(interfaceName, requiresDefInterface))
if (version >= LV.Features.extendedInterfaces) if (version >= LV.Features.extendedInterfaces)
result shouldBe Success(requiresDefInterfaceScala) result shouldBe Success(requiresDefInterfaceScala)
else else
@ -1630,9 +1640,9 @@ class DecodeV1Spec
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
decoder.decodeChoice(templateName, protoChoiceWithoutObservers) decoder.decodeChoiceForTest(templateName, protoChoiceWithoutObservers)
an[Error.Parsing] should be thrownBy (decoder an[Error.Parsing] should be thrownBy (decoder
.decodeChoice(templateName, protoChoiceWithObservers)) .decodeChoiceForTest(templateName, protoChoiceWithObservers))
} }
} }
@ -1660,10 +1670,10 @@ class DecodeV1Spec
val decoder = moduleDecoder(version, stringTable) val decoder = moduleDecoder(version, stringTable)
decoder.decodeChoice(templateName, protoChoiceWithoutObservers) decoder.decodeChoiceForTest(templateName, protoChoiceWithoutObservers)
an[Error.Parsing] should be thrownBy ( an[Error.Parsing] should be thrownBy (
decoder decoder
.decodeChoice(templateName, protoChoiceWithObservers), .decodeChoiceForTest(templateName, protoChoiceWithObservers),
) )
} }
@ -1694,9 +1704,9 @@ class DecodeV1Spec
val decoder = moduleDecoder(version, stringTable, ImmArraySeq.empty, typeTable) val decoder = moduleDecoder(version, stringTable, ImmArraySeq.empty, typeTable)
an[Error.Parsing] should be thrownBy ( an[Error.Parsing] should be thrownBy (
decoder.decodeChoice(templateName, protoChoiceWithoutObservers), decoder.decodeChoiceForTest(templateName, protoChoiceWithoutObservers),
) )
decoder.decodeChoice(templateName, protoChoiceWithObservers) decoder.decodeChoiceForTest(templateName, protoChoiceWithObservers)
} }
} }
} }
@ -1723,7 +1733,8 @@ class DecodeV1Spec
onlySerializableDataDefs = false, onlySerializableDataDefs = false,
) )
val parseError = val parseError =
the[Error.Parsing] thrownBy (decoder.decodeInternedTypes(env, pkgWithInternedTypes)) the[Error.Parsing] thrownBy (decoder
.decodeInternedTypesForTest(env, pkgWithInternedTypes))
parseError.toString should include("interned types table is not supported") parseError.toString should include("interned types table is not supported")
} }
} }
@ -1749,7 +1760,7 @@ class DecodeV1Spec
forEveryVersionSuchThat(_ < LV.v1_dev) { version => forEveryVersionSuchThat(_ < LV.v1_dev) { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
an[Error.Parsing] shouldBe thrownBy(decoder.decodeExpr(expr, "test")) an[Error.Parsing] shouldBe thrownBy(decoder.decodeExprForTest(expr, "test"))
} }
} }
@ -1761,7 +1772,7 @@ class DecodeV1Spec
.build() .build()
forEveryVersion { version => forEveryVersion { version =>
val decoder = moduleDecoder(version) val decoder = moduleDecoder(version)
val ex = the[Error.Parsing] thrownBy decoder.decodeDefValue(defValue) val ex = the[Error.Parsing] thrownBy decoder.decodeDefValueForTest(defValue)
ex.msg shouldBe "DefValue must have no_party_literals set to true" ex.msg shouldBe "DefValue must have no_party_literals set to true"
} }
} }

View File

@ -3,7 +3,7 @@ TX #0 1970-01-01T00:00:00Z [Test:42] version: 14
#0:0 version: 14 #0:0 version: 14
│ disclosed to (since): Alice (#0) │ disclosed to (since): Alice (#0)
└─> create Test:BigTemplate@XXXXXXXX └─> create Test:BigTemplate@XXXXXXXX
with: { p = 'Alice', x000 = 0, x001 = 1, x002 = 2, x003 = 3, x004 = 4, x005 = 5, x006 = 6, x007 = 7, x008 = 8, x009 = 9, x010 = 10, x011 = 11, x012 = 12, x013 = 13, x014 = 14, x015 = 15, x016 = 16, x017 = 17, x018 = 18, x019 = 19, x020 = 20, x021 = 21, x022 = 22, x023 = 23, x024 = 24, x025 = 25, x026 = 26, x027 = 27, x028 = 28, x029 = 29, x030 = 30, x031 = 31, x032 = 32, x033 = 33, x034 = 34, x035 = 35, x036 = 36, x037 = 37, x038 = 38, x039 = 39, x040 = 40, x041 = 41, x042 = 42, x043 = 43, x044 = 44, x045 = 45, x046 = 46, x047 = 47, x048 = 48, x049 = 49, x050 = 50, x051 = 51, x052 = 52, x053 = 53, x054 = 54, x055 = 55, x056 = 56, x057 = 57, x058 = 58, x059 = 59, x060 = 60, x061 = 61, x062 = 62, x063 = 63, x064 = 64, x065 = 65, x066 = 66, x067 = 67, x068 = 68, x069 = 69, x070 = 70, x071 = 71, x072 = 72, x073 = 73, x074 = 74, x075 = 75, x076 = 76, x077 = 77, x078 = 78, x079 = 79, x080 = 80, x081 = 81, x082 = 82, x083 = 83, x084 = 84, x085 = 85, x086 = 86, x087 = 87, x088 = 88, x089 = 89, x090 = 90, x091 = 91, x092 = 92, x093 = 93, x094 = 94, x095 = 95, x096 = 96, x097 = 97, x098 = 98, x099 = 99, x100 = 100, x101 = 101, x102 = 102, x103 = 103, x104 = 104, x105 = 105, x106 = 106, x107 = 107, x108 = 108, x109 = 109, x110 = 110, x111 = 111, x112 = 112, x113 = 113, x114 = 114, x115 = 115, x116 = 116, x117 = 117, x118 = 118, x119 = 119 } with: { p = 'Alice', x000 = 0, x001 = 1, x002 = 2, x003 = 3, x004 = 4, x005 = 5, x006 = 6, x007 = 7, x008 = 8, x009 = 9, x010 = 10, x011 = 11, x012 = 12, x013 = 13, x014 = 14, x015 = 15, x016 = 16, x017 = 17, x018 = 18, x019 = 19, x020 = 20, x021 = 21, x022 = 22, x023 = 23, x024 = 24, x025 = 25, x026 = 26, x027 = 27, x028 = 28, x029 = 29, x030 = 30, x031 = 31, x032 = 32, x033 = 33, x034 = 34, x035 = 35, x036 = 36, x037 = 37, x038 = 38, x039 = 39, x040 = 40, x041 = 41, x042 = 42, x043 = 43, x044 = 44, x045 = 45, x046 = 46, x047 = 47, x048 = 48, x049 = 49, x050 = 50, x051 = 51, x052 = 52, x053 = 53, x054 = 54, x055 = 55, x056 = 56, x057 = 57, x058 = 58, x059 = 59, x060 = 60, x061 = 61, x062 = 62, x063 = 63, x064 = 64, x065 = 65, x066 = 66, x067 = 67, x068 = 68, x069 = 69, x070 = 70, x071 = 71, x072 = 72, x073 = 73, x074 = 74, x075 = 75, x076 = 76, x077 = 77, x078 = 78, x079 = 79, x080 = 80, x081 = 81, x082 = 82, x083 = 83, x084 = 84, x085 = 85, x086 = 86, x087 = 87, x088 = 88, x089 = 89, x090 = 90, x091 = 91, x092 = 92, x093 = 93, x094 = 94, x095 = 95, x096 = 96, x097 = 97, x098 = 98, x099 = 99, x100 = 100, x101 = 101, x102 = 102, x103 = 103, x104 = 104, x105 = 105, x106 = 106, x107 = 107, x108 = 108, x109 = 109, x110 = 110, x111 = 111, x112 = 112, x113 = 113, x114 = 114, x115 = 115, x116 = 116, x117 = 117, x118 = 118, x119 = 119, x120 = 120, x121 = 121, x122 = 122, x123 = 123, x124 = 124, x125 = 125, x126 = 126, x127 = 127, x128 = 128, x129 = 129, x130 = 130, x131 = 131, x132 = 132, x133 = 133, x134 = 134, x135 = 135, x136 = 136, x137 = 137, x138 = 138, x139 = 139, x140 = 140, x141 = 141, x142 = 142, x143 = 143, x144 = 144, x145 = 145, x146 = 146, x147 = 147, x148 = 148, x149 = 149, x150 = 150, x151 = 151, x152 = 152, x153 = 153, x154 = 154, x155 = 155, x156 = 156, x157 = 157, x158 = 158, x159 = 159 }
active contracts: active contracts:
00fc4114f9e0408a3b8587e01e9bc7daaceffd8f1a42e7e17f0ccbd44d5427b8c5 00fc4114f9e0408a3b8587e01e9bc7daaceffd8f1a42e7e17f0ccbd44d5427b8c5

View File

@ -26,10 +26,10 @@ template BigTemplate
x090: Int, x091: Int, x092: Int, x093: Int, x094: Int, x095: Int, x096: Int, x097: Int, x098: Int, x099: Int x090: Int, x091: Int, x092: Int, x093: Int, x094: Int, x095: Int, x096: Int, x097: Int, x098: Int, x099: Int
x100: Int, x101: Int, x102: Int, x103: Int, x104: Int, x105: Int, x106: Int, x107: Int, x108: Int, x109: Int x100: Int, x101: Int, x102: Int, x103: Int, x104: Int, x105: Int, x106: Int, x107: Int, x108: Int, x109: Int
x110: Int, x111: Int, x112: Int, x113: Int, x114: Int, x115: Int, x116: Int, x117: Int, x118: Int, x119: Int x110: Int, x111: Int, x112: Int, x113: Int, x114: Int, x115: Int, x116: Int, x117: Int, x118: Int, x119: Int
-- x120: Int, x121: Int, x122: Int, x123: Int, x124: Int, x125: Int, x126: Int, x127: Int, x128: Int, x129: Int x120: Int, x121: Int, x122: Int, x123: Int, x124: Int, x125: Int, x126: Int, x127: Int, x128: Int, x129: Int
-- x130: Int, x131: Int, x132: Int, x133: Int, x134: Int, x135: Int, x136: Int, x137: Int, x138: Int, x139: Int x130: Int, x131: Int, x132: Int, x133: Int, x134: Int, x135: Int, x136: Int, x137: Int, x138: Int, x139: Int
-- x140: Int, x141: Int, x142: Int, x143: Int, x144: Int, x145: Int, x146: Int, x147: Int, x148: Int, x149: Int x140: Int, x141: Int, x142: Int, x143: Int, x144: Int, x145: Int, x146: Int, x147: Int, x148: Int, x149: Int
-- x150: Int, x151: Int, x152: Int, x153: Int, x154: Int, x155: Int, x156: Int, x157: Int, x158: Int, x159: Int x150: Int, x151: Int, x152: Int, x153: Int, x154: Int, x155: Int, x156: Int, x157: Int, x158: Int, x159: Int
-- x160: Int, x161: Int, x162: Int, x163: Int, x164: Int, x165: Int, x166: Int, x167: Int, x168: Int, x169: Int -- x160: Int, x161: Int, x162: Int, x163: Int, x164: Int, x165: Int, x166: Int, x167: Int, x168: Int, x169: Int
-- x170: Int, x171: Int, x172: Int, x173: Int, x174: Int, x175: Int, x176: Int, x177: Int, x178: Int, x179: Int -- x170: Int, x171: Int, x172: Int, x173: Int, x174: Int, x175: Int, x176: Int, x177: Int, x178: Int, x179: Int
-- x180: Int, x181: Int, x182: Int, x183: Int, x184: Int, x185: Int, x186: Int, x187: Int, x188: Int, x189: Int -- x180: Int, x181: Int, x182: Int, x183: Int, x184: Int, x185: Int, x186: Int, x187: Int, x188: Int, x189: Int
@ -54,10 +54,10 @@ run = do
090 091 092 093 094 095 096 097 098 099 090 091 092 093 094 095 096 097 098 099
100 101 102 103 104 105 106 107 108 109 100 101 102 103 104 105 106 107 108 109
110 111 112 113 114 115 116 117 118 119 110 111 112 113 114 115 116 117 118 119
-- 120 121 122 123 124 125 126 127 128 129 120 121 122 123 124 125 126 127 128 129
-- 130 131 132 133 134 135 136 137 138 139 130 131 132 133 134 135 136 137 138 139
-- 140 141 142 143 144 145 146 147 148 149 140 141 142 143 144 145 146 147 148 149
-- 150 151 152 153 154 155 156 157 158 159 150 151 152 153 154 155 156 157 158 159
-- 160 161 162 163 164 165 166 167 168 169 -- 160 161 162 163 164 165 166 167 168 169
-- 170 171 172 173 174 175 176 177 178 179 -- 170 171 172 173 174 175 176 177 178 179
-- 180 181 182 183 184 185 186 187 188 189 -- 180 181 182 183 184 185 186 187 188 189