cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.
Apache License 2.0
755 stars 213 forks source link

Demonstrate that JSON roundtrip property is not always satisfied for `TxMetadataWithSchema`. #4646

Open jonathanknowles opened 1 week ago

jonathanknowles commented 1 week ago

Related Issue

Description

This PR demonstrates that the JSON roundtrip property does not always hold for values of the TxMetadataWithSchema type, and provides a single counterexample:

TxMetadataWithSchema TxMetadataNoSchema $
Cardano.TxMetadata $
Map.fromList
  [ ( 1
    , Cardano.TxMetaMap
      [ (Cardano.TxMetaText "k", Cardano.TxMetaText "v1")
      , (Cardano.TxMetaText "k", Cardano.TxMetaText "v2")
      ]
    )
  ]

With the following command:

cabal test cardano-wallet-unit --test-options '--match "Broken round trip for TxMetadataWithSchema"'

We see the following failure (link to failure on Buildkite):

Cardano.Wallet.Api.Types
  Broken round trip for TxMetadataWithSchema [x]

Failures:

  test/unit/Cardano/Wallet/Api/TypesSpec.hs:905:47:
  1) Cardano.Wallet.Api.Types Broken round trip for TxMetadataWithSchema
       expected: Just (TxMetadataWithSchema {txMetadataWithSchema_schema = TxMetadataNoSchema, txMetadataWithSchema_metadata = TxMetadata (fromList [(1,TxMetaMap [(TxMetaText "k",TxMetaText "v1"),(TxMetaText "k",TxMetaText "v2")])])})
        but got: Just (TxMetadataWithSchema {txMetadataWithSchema_schema = TxMetadataNoSchema, txMetadataWithSchema_metadata = TxMetadata (fromList [(1,TxMetaMap [(TxMetaText "k",TxMetaText "v2")])])})

  To rerun use: --match "/Cardano.Wallet.Api.Types/Broken round trip for TxMetadataWithSchema/" --seed 321733787

Randomized with seed 321733787