Skip to content

Commit

Permalink
Use JSON instead of YAML for the golden file
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Dec 12, 2023
1 parent 9aa39bc commit 048fac1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ test-suite cardano-testnet-test
type: exitcode-stdio-1.0

build-depends: aeson
, aeson-pretty
, async
, base16-bytestring
, bytestring
Expand All @@ -196,7 +197,6 @@ test-suite cardano-testnet-test
, time
, transformers
, transformers-except
, yaml

ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ import Testnet.Runtime

import qualified Cardano.Api.Ledger as L
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encode.Pretty as Aeson
import qualified Data.Aeson.Lens as Aeson
import qualified Data.ByteString as BS
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Lazy as LBS
import qualified Data.List as List
import qualified Data.Yaml as Yaml
import qualified Hedgehog.Extras.Test.Golden as H
import Lens.Micro
import Testnet.SubmitApi
Expand Down Expand Up @@ -95,7 +95,8 @@ hprop_transaction = H.integrationRetryWorkspace 0 "submit-api-babbage-transactio
txbodySignedFp <- H.note $ work </> "tx.body.signed"
txbodySignedBinFp <- H.note $ work </> "tx.body.signed.bin"
txFailedResponseFp <- H.note $ work </> "tx.failed.response"
txFailedResponseYamlFp <- H.note $ work </> "tx.failed.response.yaml"
txFailedResponseYamlFp <- H.note $ work </> "tx.failed.response.json"
txFailedResponseYamlGoldenFp <- H.note "test/cardano-testnet-test/files/golden/tx.failed.response.json.golden"

void $ execCli' execConfig
[ "babbage", "query", "utxo"
Expand Down Expand Up @@ -195,12 +196,9 @@ hprop_transaction = H.integrationRetryWorkspace 0 "submit-api-babbage-transactio

v <- H.leftFailM $ H.evalIO $ Aeson.eitherDecodeFileStrict @Aeson.Value txFailedResponseFp

let opts = Yaml.defaultEncodeOptions

H.evalIO $ Yaml.encodeFileWith opts txFailedResponseYamlFp v

H.diffFileVsGoldenFile txFailedResponseYamlFp "test/cardano-testnet-test/files/golden/tx.failed.response.yaml.golden"
H.evalIO $ LBS.writeFile txFailedResponseYamlFp $ Aeson.encodePretty v

H.diffFileVsGoldenFile txFailedResponseYamlFp txFailedResponseYamlGoldenFp

redactHashLbs :: LBS.ByteString -> LBS.ByteString
redactHashLbs = id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"contents": {
"contents": {
"contents": {
"era": "ShelleyBasedEraBabbage",
"error": [
{
"contents": {
"contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 300000000000) (MultiAsset (fromList []))))",
"tag": "UtxoFailure"
},
"tag": "UtxowFailure"
},
{
"contents": {
"contents": "AlonzoInBabbageUtxoPredFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}) (TxIx 0)]))",
"tag": "UtxoFailure"
},
"tag": "UtxowFailure"
}
],
"kind": "ShelleyTxValidationError"
},
"tag": "TxValidationErrorInCardanoMode"
},
"tag": "TxCmdTxSubmitValidationError"
},
"tag": "TxSubmitFail"
}

This file was deleted.

0 comments on commit 048fac1

Please sign in to comment.