Skip to content

Commit

Permalink
Limit the metadata to reasonable sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Apr 30, 2024
1 parent db481de commit a330aab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Cardano.Ledger.Api (
import Cardano.Ledger.Core (EraTx (getMinFeeTx))
import Cardano.Ledger.Credential (Credential (..))
import Control.Lens ((^.))
import Data.ByteString qualified as BS
import Data.Map qualified as Map
import Data.Maybe.Strict (fromSMaybe)
import Data.Set qualified as Set
Expand Down Expand Up @@ -78,6 +79,7 @@ import Test.Hydra.Prelude
import Test.QuickCheck (
Positive (..),
Property,
checkCoverage,
choose,
conjoin,
counterexample,
Expand All @@ -88,14 +90,14 @@ import Test.QuickCheck (
label,
oneof,
property,
vector,
vectorOf,
withMaxSuccess,
(.&&.),
(===),
)
import Test.QuickCheck.Instances.Semigroup ()
import Test.QuickCheck.Monadic (monadicIO)
import Test.QuickCheck.Property (checkCoverage)

spec :: Spec
spec =
Expand Down Expand Up @@ -337,17 +339,18 @@ genBlueprintTxWithUTxO =
pure $ mkMeta [(l, TxMetaList $ Map.elems bytes <> Map.elems numbers <> Map.elems text)]

bytesMetadata = do
metadata <- arbitrary
n <- choose (1, 50)
metadata <- BS.pack <$> vector n
l <- arbitrary
pure $ mkMeta [(l, TxMetaBytes metadata)]

numberMetadata = do
metadata <- arbitrary
metadata <- elements [0 .. 100]
l <- arbitrary
pure $ mkMeta [(l, TxMetaNumber metadata)]

textMetadata = do
n <- choose (2, 50)
n <- choose (2, 22)
metadata <- Text.take n <$> genSomeText
l <- arbitrary
pure $ mkMeta [(l, TxMetaText metadata)]
Expand Down

0 comments on commit a330aab

Please sign in to comment.