From dbac6ec92c503f8b70e390df8df6bbea3de70cba Mon Sep 17 00:00:00 2001 From: Brian W Bush Date: Mon, 30 Oct 2023 15:49:49 -0600 Subject: [PATCH] PLT-7684 Web integration test for open roles. --- .../Language/Marlowe/Runtime/Web/Common.hs | 1 - .../Runtime/Web/Contracts/Contract/Post.hs | 18 +++++++++++++++--- .../Runtime/Web/Contracts/Contract/Put.hs | 1 - .../Contracts/Transactions/Transaction/Post.hs | 1 - .../Contracts/Transactions/Transaction/Put.hs | 1 - .../Marlowe/Runtime/Web/StandardContract.hs | 1 - marlowe-integration/app/Main.hs | 1 - marlowe-runtime-web/.golden/OpenApi/golden | 3 --- .../src/Language/Marlowe/Runtime/Web/Types.hs | 1 - marlowe-runtime-web/test/Spec.hs | 1 - 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Common.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Common.hs index acce2805c8..c8b26f671f 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Common.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Common.hs @@ -70,7 +70,6 @@ createCloseContract Wallet{..} = do { metadata = mempty , version = Web.V1 , roles = Nothing - , threadTokenName = Nothing , contract = ContractOrSourceId $ Left V1.Close , minUTxODeposit = Nothing , tags = mempty diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Post.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Post.hs index b7c422ab33..a8721ce82a 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Post.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Post.hs @@ -19,7 +19,20 @@ import Test.Integration.Marlowe.Local (withLocalMarloweRuntime) spec :: Spec spec = describe "Valid POST /contracts" do - it "returns the contract header" $ withLocalMarloweRuntime $ runIntegrationTest do + it "returns the contract header" + . specWithRolesConfig + $ Web.Mint . Map.singleton "PartyA" . Web.RoleTokenSimple + it "returns the contract header (open roles)" + . specWithRolesConfig + . const . Web.Mint $ Map.fromList + [ + ("Thread", Web.ThreadRoleTokenSimple) + , ("PartyA", Web.OpenRoleTokenSimple) + ] + +specWithRolesConfig :: (Web.Address -> Web.RolesConfig) -> IO () +specWithRolesConfig roles = + withLocalMarloweRuntime $ runIntegrationTest do partyAWallet <- getGenesisWallet 0 partyBWallet <- getGenesisWallet 1 @@ -45,8 +58,7 @@ spec = describe "Valid POST /contracts" do Web.PostContractsRequest { metadata = mempty , version = Web.V1 - , roles = Just $ Web.Mint $ Map.singleton "PartyA" $ Web.RoleTokenSimple partyAWebChangeAddress - , threadTokenName = Nothing + , roles = Just $ roles partyAWebChangeAddress , contract = ContractOrSourceId $ Left contract , minUTxODeposit = Nothing , tags = mempty diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Put.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Put.hs index 332f09b750..510136ce2b 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Put.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Contract/Put.hs @@ -46,7 +46,6 @@ spec = describe "POST /contracts/{contractId}/transactions" do { metadata = mempty , version = Web.V1 , roles = Just $ Web.Mint $ Map.singleton "PartyA" $ RoleTokenSimple partyAWebChangeAddress - , threadTokenName = Nothing , contract = ContractOrSourceId $ Left contract , minUTxODeposit = Nothing , tags = mempty diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Post.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Post.hs index 23b87f18e0..2eb136d1c1 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Post.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Post.hs @@ -49,7 +49,6 @@ spec = describe "POST /contracts/{contractId}/transactions" do { metadata = mempty , version = Web.V1 , roles = Just $ Web.Mint $ Map.singleton "Party A" $ RoleTokenSimple partyAWebChangeAddress - , threadTokenName = Nothing , contract = ContractOrSourceId $ Left contract , minUTxODeposit = Nothing , tags = mempty diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Put.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Put.hs index ae0f16b555..234124109d 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Put.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Contracts/Transactions/Transaction/Put.hs @@ -54,7 +54,6 @@ spec = describe "PUT /contracts/{contractId}/transactions/{transaction}" do { metadata = mempty , version = Web.V1 , roles = Just $ Web.Mint $ Map.singleton "Party A" $ RoleTokenSimple partyAWebChangeAddress - , threadTokenName = Nothing , contract = ContractOrSourceId $ Left contract , minUTxODeposit = Nothing , tags = mempty diff --git a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/StandardContract.hs b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/StandardContract.hs index dd34a65d5b..db8d2a2d9b 100644 --- a/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/StandardContract.hs +++ b/marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/StandardContract.hs @@ -106,7 +106,6 @@ createStandardContractWithTags tags partyAWallet partyBWallet = do { metadata = mempty , version = Web.V1 , roles = Just $ Web.Mint $ Map.singleton "Party A" $ RoleTokenSimple partyAWebChangeAddress - , threadTokenName = Nothing , contract = ContractOrSourceId $ Right contractSourceId , minUTxODeposit = Nothing , tags = tags diff --git a/marlowe-integration/app/Main.hs b/marlowe-integration/app/Main.hs index add9641af4..7c1d566510 100644 --- a/marlowe-integration/app/Main.hs +++ b/marlowe-integration/app/Main.hs @@ -58,7 +58,6 @@ main = withLocalMarloweRuntime \MarloweRuntime{..} -> do , tags = mempty , version = Web.V1 , roles = Nothing - , threadTokenName = Nothing , contract = ContractOrSourceId $ Left V1.Close , minUTxODeposit = Nothing } diff --git a/marlowe-runtime-web/.golden/OpenApi/golden b/marlowe-runtime-web/.golden/OpenApi/golden index f544e01273..4f7c3a8304 100644 --- a/marlowe-runtime-web/.golden/OpenApi/golden +++ b/marlowe-runtime-web/.golden/OpenApi/golden @@ -1974,9 +1974,6 @@ }, "type": "object" }, - "threadTokenName": { - "type": "string" - }, "version": { "$ref": "#/components/schemas/MarloweVersion" } diff --git a/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs b/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs index 246369d286..1f70ea9c30 100644 --- a/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs +++ b/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs @@ -773,7 +773,6 @@ data PostContractsRequest = PostContractsRequest , metadata :: Map Word64 Metadata , version :: MarloweVersion , roles :: Maybe RolesConfig - , threadTokenName :: Maybe String , contract :: ContractOrSourceId , minUTxODeposit :: Maybe Word64 } diff --git a/marlowe-runtime-web/test/Spec.hs b/marlowe-runtime-web/test/Spec.hs index 7b99d0a6e3..f64648a83f 100644 --- a/marlowe-runtime-web/test/Spec.hs +++ b/marlowe-runtime-web/test/Spec.hs @@ -218,7 +218,6 @@ instance Arbitrary Web.PostContractsRequest where <*> arbitrary <*> arbitrary <*> arbitrary - <*> arbitrary -- size of 6 will result in a 1-layer deep contract being generated (this is -- all we care about for the purposes of schema checking). <*> arbitrary