@@ -11,7 +11,6 @@ import Cardano.Crypto.DSIGN qualified as CC
11
11
import Cardano.Crypto.Hash (hashToBytes )
12
12
import Cardano.Ledger.BaseTypes qualified as Ledger
13
13
import Cardano.Ledger.Credential qualified as Ledger
14
- import Cardano.Ledger.Shelley.UTxO qualified as Ledger
15
14
import Codec.CBOR.Magic (uintegerFromBytes )
16
15
import Data.ByteString qualified as BS
17
16
import Data.Map.Strict qualified as Map
@@ -28,24 +27,23 @@ import Hydra.Tx.Party (Party (..))
28
27
import PlutusTx.Builtins (fromBuiltin )
29
28
import Test.Cardano.Ledger.Conway.Arbitrary ()
30
29
import Test.Hydra.Tx.Fixture qualified as Fixtures
31
- import Test.QuickCheck (listOf , oneof , scale , shrinkList , shrinkMapBy , suchThat , vector , vectorOf )
30
+ import Test.QuickCheck (listOf , oneof , scale , shrinkList , shrinkMapBy , sized , suchThat , vector , vectorOf )
32
31
33
32
-- * TxOut
34
33
35
34
instance Arbitrary (TxOut CtxUTxO ) where
36
35
arbitrary = genTxOut
37
36
shrink txOut = fromLedgerTxOut <$> shrink (toLedgerTxOut txOut)
38
37
39
- -- | Generate a 'Babbage ' era 'TxOut', which may contain arbitrary assets
38
+ -- | Generate a 'Conway ' era 'TxOut', which may contain arbitrary assets
40
39
-- addressed to public keys and scripts, as well as datums.
41
40
--
42
41
-- NOTE: This generator does
43
42
-- * not produce byron addresses as most of the cardano ecosystem dropped support for that (including plutus),
44
- -- * not produce reference scripts as they are not fully "visible" from plutus,
45
43
-- * replace stake pointers with null references as nobody uses that.
46
44
genTxOut :: Gen (TxOut ctx )
47
45
genTxOut =
48
- (noRefScripts . noStakeRefPtr <$> gen)
46
+ (noStakeRefPtr <$> gen)
49
47
`suchThat` notByronAddress
50
48
where
51
49
gen =
@@ -71,9 +69,6 @@ genTxOut =
71
69
TxOut (ShelleyAddressInEra (ShelleyAddress Ledger. Testnet cre sr)) val dat refScript
72
70
_ -> out
73
71
74
- noRefScripts out =
75
- out{txOutReferenceScript = ReferenceScriptNone }
76
-
77
72
-- | Generate a 'TxOut' with a byron address. This is usually not supported by
78
73
-- Hydra or Plutus.
79
74
genTxOutByron :: Gen (TxOut ctx )
@@ -114,19 +109,11 @@ shrinkUTxO = shrinkMapBy (UTxO . fromList) UTxO.pairs (shrinkList shrinkOne)
114
109
| value' <- shrinkValue value
115
110
]
116
111
117
- -- | Generate a complete arbitrary UTxO, which may contain arbitrary assets in
118
- -- 'TxOut's addressed to public keys *and* scripts. NOTE: This is not reducing
119
- -- size when generating assets in 'TxOut's, so will end up regularly with 300+
120
- -- assets with generator size 30. NOTE: The Arbitrary TxIn instance from the
121
- -- ledger is producing colliding values, so we replace them.
112
+ -- | Generate a complete arbitrary UTxO. See also 'genTxOut'.
122
113
genUTxO :: Gen UTxO
123
- genUTxO = do
124
- utxoMap <- Map. toList . Ledger. unUTxO <$> arbitrary
125
- fmap UTxO. fromPairs . forM utxoMap $ \ (_, o) -> do
126
- i <- arbitrary
127
- pure (i, fromLedgerTxOut o)
114
+ genUTxO = sized genUTxOSized
128
115
129
- -- | Generate a 'Babbage ' era 'UTxO' with given number of outputs. See also
116
+ -- | Generate a 'Conway ' era 'UTxO' with given number of outputs. See also
130
117
-- 'genTxOut'.
131
118
genUTxOSized :: Int -> Gen UTxO
132
119
genUTxOSized numUTxO =
0 commit comments