ifaces: tests for by_interface nodes in transactions (#13321)

This adds tests for decode . encode = id in the transaction
encoder/decoders.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Robin Krom 2022-03-18 11:34:45 +01:00 committed by GitHub
parent 6a103dfa83
commit b14e4aeacd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -28,6 +28,7 @@ import scalaz.scalacheck.ScalaCheckBinding._
object ValueGenerators {
import TransactionVersion.minExceptions
import TransactionVersion.minInterfaces
//generate decimal values
def numGen(scale: Numeric.Scale): Gen[Numeric] = {
@ -303,6 +304,7 @@ object ValueGenerators {
signatories <- genNonEmptyParties
stakeholders <- genNonEmptyParties
key <- Gen.option(keyWithMaintainersGen)
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
} yield Node.Create(
coid,
templateId,
@ -311,9 +313,7 @@ object ValueGenerators {
signatories,
stakeholders,
key,
None,
// TODO https://github.com/digital-asset/daml/issues/12051
// also vary byInterface
byInterface,
version,
)
}
@ -333,6 +333,7 @@ object ValueGenerators {
stakeholders <- genNonEmptyParties
key <- Gen.option(keyWithMaintainersGen)
byKey <- Gen.oneOf(true, false)
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
} yield Node.Fetch(
coid,
templateId,
@ -341,9 +342,7 @@ object ValueGenerators {
stakeholders,
key,
byKey,
None,
// TODO https://github.com/digital-asset/daml/issues/12051
// also vary byInterface
byInterface,
version,
)
}
@ -386,6 +385,7 @@ object ValueGenerators {
exerciseResult <- if (version < minExceptions) valueGen.map(Some(_)) else Gen.option(valueGen)
key <- Gen.option(keyWithMaintainersGen)
byKey <- Gen.oneOf(true, false)
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
} yield Node.Exercise(
targetCoid,
templateId,
@ -400,9 +400,7 @@ object ValueGenerators {
exerciseResult,
key,
byKey,
None,
// TODO https://github.com/digital-asset/daml/issues/12051
// also vary byInterface (but it requires an interface choice)
byInterface,
version,
)
}

View File

@ -906,6 +906,10 @@ class TransactionCoderSpec
create.copy(
arg = normalize(create.arg, create.version),
key = create.key.map(normalizeKey(_, create.version)),
byInterface =
if (create.version >= TransactionVersion.minInterfaces)
create.byInterface
else None,
)
}
@ -916,6 +920,10 @@ class TransactionCoderSpec
if (fetch.version >= TransactionVersion.minByKey)
fetch.byKey
else false,
byInterface =
if (fetch.version >= TransactionVersion.minInterfaces)
fetch.byInterface
else None,
)
private[this] def normalizeExe(exe: Node.Exercise) =
@ -938,6 +946,10 @@ class TransactionCoderSpec
if (exe.version >= TransactionVersion.minByKey)
exe.byKey
else false,
byInterface =
if (exe.version >= TransactionVersion.minInterfaces)
exe.byInterface
else None,
)
private[this] def normalizeKey(