mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
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:
parent
6a103dfa83
commit
b14e4aeacd
@ -28,6 +28,7 @@ import scalaz.scalacheck.ScalaCheckBinding._
|
|||||||
object ValueGenerators {
|
object ValueGenerators {
|
||||||
|
|
||||||
import TransactionVersion.minExceptions
|
import TransactionVersion.minExceptions
|
||||||
|
import TransactionVersion.minInterfaces
|
||||||
|
|
||||||
//generate decimal values
|
//generate decimal values
|
||||||
def numGen(scale: Numeric.Scale): Gen[Numeric] = {
|
def numGen(scale: Numeric.Scale): Gen[Numeric] = {
|
||||||
@ -303,6 +304,7 @@ object ValueGenerators {
|
|||||||
signatories <- genNonEmptyParties
|
signatories <- genNonEmptyParties
|
||||||
stakeholders <- genNonEmptyParties
|
stakeholders <- genNonEmptyParties
|
||||||
key <- Gen.option(keyWithMaintainersGen)
|
key <- Gen.option(keyWithMaintainersGen)
|
||||||
|
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
|
||||||
} yield Node.Create(
|
} yield Node.Create(
|
||||||
coid,
|
coid,
|
||||||
templateId,
|
templateId,
|
||||||
@ -311,9 +313,7 @@ object ValueGenerators {
|
|||||||
signatories,
|
signatories,
|
||||||
stakeholders,
|
stakeholders,
|
||||||
key,
|
key,
|
||||||
None,
|
byInterface,
|
||||||
// TODO https://github.com/digital-asset/daml/issues/12051
|
|
||||||
// also vary byInterface
|
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -333,6 +333,7 @@ object ValueGenerators {
|
|||||||
stakeholders <- genNonEmptyParties
|
stakeholders <- genNonEmptyParties
|
||||||
key <- Gen.option(keyWithMaintainersGen)
|
key <- Gen.option(keyWithMaintainersGen)
|
||||||
byKey <- Gen.oneOf(true, false)
|
byKey <- Gen.oneOf(true, false)
|
||||||
|
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
|
||||||
} yield Node.Fetch(
|
} yield Node.Fetch(
|
||||||
coid,
|
coid,
|
||||||
templateId,
|
templateId,
|
||||||
@ -341,9 +342,7 @@ object ValueGenerators {
|
|||||||
stakeholders,
|
stakeholders,
|
||||||
key,
|
key,
|
||||||
byKey,
|
byKey,
|
||||||
None,
|
byInterface,
|
||||||
// TODO https://github.com/digital-asset/daml/issues/12051
|
|
||||||
// also vary byInterface
|
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -386,6 +385,7 @@ object ValueGenerators {
|
|||||||
exerciseResult <- if (version < minExceptions) valueGen.map(Some(_)) else Gen.option(valueGen)
|
exerciseResult <- if (version < minExceptions) valueGen.map(Some(_)) else Gen.option(valueGen)
|
||||||
key <- Gen.option(keyWithMaintainersGen)
|
key <- Gen.option(keyWithMaintainersGen)
|
||||||
byKey <- Gen.oneOf(true, false)
|
byKey <- Gen.oneOf(true, false)
|
||||||
|
byInterface <- if (version < minInterfaces) Gen.const(None) else Gen.option(idGen)
|
||||||
} yield Node.Exercise(
|
} yield Node.Exercise(
|
||||||
targetCoid,
|
targetCoid,
|
||||||
templateId,
|
templateId,
|
||||||
@ -400,9 +400,7 @@ object ValueGenerators {
|
|||||||
exerciseResult,
|
exerciseResult,
|
||||||
key,
|
key,
|
||||||
byKey,
|
byKey,
|
||||||
None,
|
byInterface,
|
||||||
// TODO https://github.com/digital-asset/daml/issues/12051
|
|
||||||
// also vary byInterface (but it requires an interface choice)
|
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -906,6 +906,10 @@ class TransactionCoderSpec
|
|||||||
create.copy(
|
create.copy(
|
||||||
arg = normalize(create.arg, create.version),
|
arg = normalize(create.arg, create.version),
|
||||||
key = create.key.map(normalizeKey(_, 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)
|
if (fetch.version >= TransactionVersion.minByKey)
|
||||||
fetch.byKey
|
fetch.byKey
|
||||||
else false,
|
else false,
|
||||||
|
byInterface =
|
||||||
|
if (fetch.version >= TransactionVersion.minInterfaces)
|
||||||
|
fetch.byInterface
|
||||||
|
else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
private[this] def normalizeExe(exe: Node.Exercise) =
|
private[this] def normalizeExe(exe: Node.Exercise) =
|
||||||
@ -938,6 +946,10 @@ class TransactionCoderSpec
|
|||||||
if (exe.version >= TransactionVersion.minByKey)
|
if (exe.version >= TransactionVersion.minByKey)
|
||||||
exe.byKey
|
exe.byKey
|
||||||
else false,
|
else false,
|
||||||
|
byInterface =
|
||||||
|
if (exe.version >= TransactionVersion.minInterfaces)
|
||||||
|
exe.byInterface
|
||||||
|
else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
private[this] def normalizeKey(
|
private[this] def normalizeKey(
|
||||||
|
Loading…
Reference in New Issue
Block a user