Skip to content

Commit 61eef33

Browse files
committed
Remove and fix JSON tests for cardano Tx
The hard-coded JSON test is not applicable anymore and the expected schema for ToJSON Tx is now RawTransaction.
1 parent 4bf12e4 commit 61eef33

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

hydra-node/test/Hydra/Ledger/CardanoSpec.hs

+5-16
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Hydra.Ledger.Cardano (
3030
)
3131
import Test.Aeson.GenericSpecs (roundtripAndGoldenSpecs)
3232
import Test.Cardano.Ledger.Babbage.Arbitrary ()
33-
import Test.QuickCheck (Property, checkCoverage, conjoin, counterexample, cover, forAll, forAllBlind, property, sized, vectorOf, (.&&.), (===))
33+
import Test.QuickCheck (Property, checkCoverage, conjoin, counterexample, cover, forAll, forAllBlind, property, sized, vectorOf, withMaxSuccess, (.&&.), (===))
3434
import Test.QuickCheck.Property (expectFailure)
3535
import Test.Util (propCollisionResistant)
3636

@@ -71,20 +71,9 @@ spec =
7171
prop "Roundtrip CBOR encoding" $ roundtripCBOR @Tx
7272

7373
prop "JSON encoding of Tx according to schema" $
74-
prop_validateJSONSchema @Tx "api.json" $
75-
key "components" . key "schemas" . key "Transaction"
76-
77-
-- TODO(SN): rather ensure we use the right (cardano-api's) witness format as a test
78-
it "parses a specific Tx" $ do
79-
let bs =
80-
"{\"witnesses\":\
81-
\ {\"keys\": [\"825820db995fe25169d141cab9bbba92baa01f9f2e1ece7df4cb2ac05190f37fcc1f9d58400599ccd0028389216631446cf0f9a4b095bbed03c25537595aa5a2e107e3704a55050c4ee5198a0aa9fc88007791ef9f3847cd96f3cb9a430d1c2d81c817480c\"]\
82-
\ },\
83-
\ \"body\":{\"outputs\":[{\"address\":\"addr1vx35vu6aqmdw6uuc34gkpdymrpsd3lsuh6ffq6d9vja0s6spkenss\",\"value\":{\"lovelace\":14}}],\
84-
\ \"inputs\":[\"9fdc525c20bc00d9dfa9d14904b65e01910c0dfe3bb39865523c1e20eaeb0903#0\"]\
85-
\ }\
86-
\ }"
87-
shouldParseJSONAs @Tx bs
74+
withMaxSuccess 5 $
75+
prop_validateJSONSchema @Tx "api.json" $
76+
key "components" . key "schemas" . key "RawTransaction"
8877

8978
describe "applyTransactions" $ do
9079
prop "works with valid transaction" appliesValidTransaction
@@ -108,7 +97,7 @@ spec =
10897
it "produces realistic values" $
10998
forAll genValue propRealisticValue
11099

111-
shouldParseJSONAs :: forall a. FromJSON a => LByteString -> Expectation
100+
shouldParseJSONAs :: forall a. (HasCallStack, FromJSON a) => LByteString -> Expectation
112101
shouldParseJSONAs bs =
113102
case Aeson.eitherDecode bs of
114103
Left err -> failure err

0 commit comments

Comments
 (0)