Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration test for divulgence #6376

Merged
merged 5 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address #6376 (comment)
  • Loading branch information
stefanobaghino-da committed Jun 17, 2020
commit fa910bde5a6d264a8e780055155e55e63136d442
18 changes: 9 additions & 9 deletions compatibility/sandbox-migration/runner/Migration/Divulgence.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ test step modelDar = Test {..}
, "--test=divulgence," <> T.unpack (getParty testOwner) <> "," <> T.unpack (getParty testDivulgee) <> "," <> suffix
]
either fail pure =<< A.eitherDecodeFileStrict' outputFile
validateStep sdkVersion (prevPrivateAssets, prevDivulgedAssets) Result {..} = do
validateStep sdkVersion (prevAssets, prevDivulgedAssets) Result {..} = do
let suffix = getSdkVersion sdkVersion
unless (equivalent oldPrivateAssets prevPrivateAssets) $
throwError ("The old private assets do not match those returned by the previous run: " <> show oldPrivateAssets)
unless (equivalent oldAssets prevAssets) $
throwError ("The old private assets do not match those returned by the previous run: " <> show oldAssets)
unless (equivalent oldDivulgedAssets prevDivulgedAssets) $
throwError ("The old divulged assets do not match those returned by the previous run: " <> show oldDivulgedAssets)
let privateAssetDiff = (map _2 newPrivateAssets) \\ (map _2 oldPrivateAssets)
unless (equivalent privateAssetDiff [Asset testOwner ("private-" <> suffix), Asset testOwner ("divulging-" <> suffix)]) $
throwError ("Expected one private and one divulged contract, got " <> show privateAssetDiff)
let assetsDiff = (map _2 newAssets) \\ (map _2 oldAssets)
unless (equivalent assetsDiff [Asset testOwner ("private-" <> suffix), Asset testOwner ("divulging-" <> suffix)]) $
throwError ("Expected one private and one divulged contract, got " <> show assetsDiff)
let divulgedAssetDiff = (map _2 newDivulgedAssets) \\ (map _2 oldDivulgedAssets)
stefanobaghino-da marked this conversation as resolved.
Show resolved Hide resolved
unless (divulgedAssetDiff == [Asset testOwner ("divulging-" <> suffix)]) $
throwError ("Expected one divulged contract, got " <> show divulgedAssetDiff)
pure (newPrivateAssets, newDivulgedAssets)
pure (newAssets, newDivulgedAssets)

testOwner :: Party
testOwner = Party "owner"
Expand All @@ -62,8 +62,8 @@ data Asset = Asset
instance A.FromJSON Asset

data Result = Result
{ oldPrivateAssets :: [Tuple2 ContractId Asset]
, newPrivateAssets :: [Tuple2 ContractId Asset]
{ oldAssets :: [Tuple2 ContractId Asset]
, newAssets :: [Tuple2 ContractId Asset]
, oldDivulgedAssets :: [Tuple2 ContractId Asset]
, newDivulgedAssets :: [Tuple2 ContractId Asset]
} deriving Generic
Expand Down
4 changes: 2 additions & 2 deletions compatibility/sandbox-migration/src/com/daml/Divulgence.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import scala.concurrent.{ExecutionContext, Future}
object Divulgence {

private final case class Result(
oldPrivateAssets: Seq[Application.ContractResult],
newPrivateAssets: Seq[Application.ContractResult],
oldAssets: Seq[Application.ContractResult],
newAssets: Seq[Application.ContractResult],
oldDivulgedAssets: Seq[Application.ContractResult],
newDivulgedAssets: Seq[Application.ContractResult],
)
Expand Down