Skip to content

Commit 6ab39ee

Browse files
author
Jamie Bertram
committed
Fix roundtrip encoding for integration tests
1 parent 58d4944 commit 6ab39ee

File tree

1 file changed

+6
-23
lines changed
  • marlowe-integration-tests/test/Language/Marlowe/Runtime/Web

1 file changed

+6
-23
lines changed

marlowe-integration-tests/test/Language/Marlowe/Runtime/Web/Common.hs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ module Language.Marlowe.Runtime.Web.Common (
1414
) where
1515

1616
import Cardano.Api (
17-
CardanoEra (..),
18-
ShelleyBasedEra (ShelleyBasedEraBabbage),
17+
BabbageEra,
1918
ShelleyWitnessSigningKey (..),
20-
TextEnvelopeCddl (..),
21-
deserialiseTxLedgerCddl,
19+
Tx,
2220
getTxBody,
2321
getTxWitnesses,
24-
serialiseWitnessLedgerCddl,
2522
signShelleyTransaction,
2623
)
2724
import Control.Concurrent (threadDelay)
@@ -49,7 +46,7 @@ import Language.Marlowe.Runtime.Web.Client (
4946
putTransaction,
5047
putWithdrawal,
5148
)
52-
import Language.Marlowe.Runtime.Web.Server.DTO (ToDTO (toDTO))
49+
import Language.Marlowe.Runtime.Web.Server.DTO (FromDTO (..), ToDTO (toDTO))
5350
import qualified PlutusLedgerApi.V2 as PV2
5451
import Servant.Client.Streaming (ClientM)
5552

@@ -209,23 +206,9 @@ applyInputs Wallet{..} contractId inputs = do
209206
}
210207

211208
signShelleyTransaction' :: Web.UnwitnessedTx -> [ShelleyWitnessSigningKey] -> IO Web.TxWitness
212-
signShelleyTransaction' Web.UnwitnessedTx{..} wits = do
213-
let te =
214-
TextEnvelopeCddl
215-
{ teCddlType = utType
216-
, teCddlDescription = utDescription
217-
, teCddlRawCBOR = Web.unBase16 utCborHex
218-
}
219-
txBody <- case deserialiseTxLedgerCddl BabbageEra te of
220-
Left err -> fail $ show err
221-
Right a -> pure a
222-
let witnessCddl =
223-
serialiseWitnessLedgerCddl ShelleyBasedEraBabbage $
224-
head $
225-
getTxWitnesses $
226-
signShelleyTransaction (getTxBody txBody) wits
227-
pure case witnessCddl of
228-
TextEnvelopeCddl ty _ bytes -> Web.TxWitness ty "" $ Web.Base16 bytes
209+
signShelleyTransaction' txEnvelope wits = do
210+
tx :: Tx BabbageEra <- expectJust "Failed to deserialise tx" $ fromDTO txEnvelope
211+
pure $ toDTO $ head $ getTxWitnesses $ signShelleyTransaction (getTxBody tx) wits
229212

230213
waitUntilConfirmed :: (MonadIO m) => (a -> Web.TxStatus) -> m a -> m a
231214
waitUntilConfirmed getStatus getResource = do

0 commit comments

Comments
 (0)