@@ -14,17 +14,17 @@ import Hydra.Cardano.Api hiding (initialLedgerState)
14
14
import Hydra.Ledger.Cardano.Builder
15
15
16
16
import qualified Cardano.Api.UTxO as UTxO
17
- import Cardano.Binary (decodeAnnotator , serialize' , unsafeDeserialize' )
17
+ import Cardano.Binary (decodeAnnotator , serialize' )
18
18
import qualified Cardano.Crypto.DSIGN as CC
19
19
import qualified Cardano.Ledger.Babbage.Tx as Ledger
20
+ import Cardano.Ledger.BaseTypes (StrictMaybe (.. ))
20
21
import qualified Cardano.Ledger.BaseTypes as Ledger
21
22
import qualified Cardano.Ledger.Credential as Ledger
22
23
import qualified Cardano.Ledger.Shelley.API.Mempool as Ledger
23
24
import qualified Cardano.Ledger.Shelley.Genesis as Ledger
24
25
import qualified Cardano.Ledger.Shelley.LedgerState as Ledger
25
26
import qualified Cardano.Ledger.Shelley.Rules.Ledger as Ledger
26
27
import qualified Cardano.Ledger.Shelley.UTxO as Ledger
27
- import qualified Cardano.Ledger.TxIn as Ledger
28
28
import qualified Codec.CBOR.Decoding as CBOR
29
29
import qualified Codec.CBOR.Encoding as CBOR
30
30
import Control.Arrow (left )
@@ -33,13 +33,12 @@ import qualified Data.ByteString as BS
33
33
import Data.Default (def )
34
34
import qualified Data.Map.Strict as Map
35
35
import Data.Maybe (fromJust )
36
- import Data.Maybe.Strict (StrictMaybe (.. ))
37
36
import Data.Text.Lazy.Builder (toLazyText )
38
37
import Formatting.Buildable (build )
39
38
import qualified Hydra.Contract.Head as Head
40
39
import Hydra.Ledger (IsTx (.. ), Ledger (.. ), ValidationError (.. ))
41
40
import Hydra.Ledger.Cardano.Json ()
42
- import Plutus .V2.Ledger.Api (fromBuiltin )
41
+ import PlutusLedgerApi .V2 (fromBuiltin )
43
42
import Test.Cardano.Ledger.Babbage.Serialisation.Generators ()
44
43
import Test.QuickCheck (
45
44
choose ,
@@ -127,7 +126,7 @@ instance Arbitrary Tx where
127
126
-- TODO: shrinker!
128
127
arbitrary = fromLedgerTx . withoutProtocolUpdates <$> arbitrary
129
128
where
130
- withoutProtocolUpdates tx@ (Ledger. ValidatedTx body _ _ _) =
129
+ withoutProtocolUpdates tx@ (Ledger. AlonzoTx body _ _ _) =
131
130
let body' = body{Ledger. txUpdates = SNothing }
132
131
in tx{Ledger. body = body'}
133
132
@@ -152,14 +151,14 @@ mkSimpleTx (txin, TxOut owner valueIn datum refScript) (recipient, valueOut) sk
152
151
}
153
152
154
153
outs =
155
- TxOut @ CtxTx recipient valueOut TxOutDatumNone ReferenceScriptNone :
156
- [ TxOut @ CtxTx
157
- owner
158
- (valueIn <> negateValue valueOut)
159
- (toTxContext datum)
160
- refScript
161
- | valueOut /= valueIn
162
- ]
154
+ TxOut @ CtxTx recipient valueOut TxOutDatumNone ReferenceScriptNone
155
+ : [ TxOut @ CtxTx
156
+ owner
157
+ (valueIn <> negateValue valueOut)
158
+ (toTxContext datum)
159
+ refScript
160
+ | valueOut /= valueIn
161
+ ]
163
162
164
163
fee = Lovelace 0
165
164
@@ -218,14 +217,6 @@ generateOneTransfer networkId (utxo, (_, sender), txs) _ = do
218
217
_ ->
219
218
error " Couldn't generate transaction sequence: need exactly one UTXO."
220
219
221
- -- | A more random generator than the 'Arbitrary TxIn' from cardano-ledger.
222
- genTxIn :: Gen TxIn
223
- genTxIn =
224
- fmap fromLedgerTxIn . Ledger. TxIn
225
- -- NOTE: [88, 32] is a CBOR prefix for a bytestring of 32 bytes.
226
- <$> fmap (unsafeDeserialize' . BS. pack . ([88 , 32 ] <> )) (vectorOf 32 arbitrary)
227
- <*> fmap Ledger. TxIx (choose (0 , 99 ))
228
-
229
220
-- TODO: Enable arbitrary datum in generators
230
221
-- TODO: This should better be called 'genOutputFor'
231
222
genOutput ::
@@ -387,9 +378,6 @@ shrinkValue =
387
378
instance Arbitrary AssetName where
388
379
arbitrary = AssetName . BS. take 32 <$> arbitrary
389
380
390
- instance Arbitrary TxIn where
391
- arbitrary = genTxIn
392
-
393
381
instance Arbitrary TxId where
394
382
arbitrary = onlyTxId <$> arbitrary
395
383
where
0 commit comments