Skip to content

Commit f6a8d54

Browse files
committed
Add Imp fixup for collateral return txout
1 parent 36e0d6f commit f6a8d54

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

eras/alonzo/impl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
* Deprecate `Alonzo` type synonym
1313
* Remove crypto parametrization from `AlonzoEra`
1414

15+
### `testlib`
16+
17+
* Expose `alonzoFixupFees`
18+
1519
## 1.12.0.0
1620

1721
* Remove deprecated `lookupPlutusScript`

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module Test.Cardano.Ledger.Alonzo.ImpTest (
3838
fixupRedeemers,
3939
fixupRedeemerIndices,
4040
fixupScriptWits,
41+
alonzoFixupFees,
4142
) where
4243

4344
import Cardano.Ledger.Address (Addr (..))

eras/babbage/impl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
* Deprecate `Babbage` type synonym
88
* Remove crypto parametrization from `BabbageEra`
99

10+
### `testlib`
11+
12+
* Add `babbageFixupTx`
13+
1014
## 1.10.1.0
1115

1216
* Use `Mismatch` to clarify predicate failures. #4711

eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/ImpTest.hs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{-# OPTIONS_GHC -Wno-orphans #-}
1212

1313
module Test.Cardano.Ledger.Babbage.ImpTest (
14+
babbageFixupTx,
1415
module Test.Cardano.Ledger.Alonzo.ImpTest,
1516
produceRefScript,
1617
produceRefScripts,
@@ -21,13 +22,14 @@ import Cardano.Ledger.Babbage.Core
2122
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
2223
import Cardano.Ledger.Plutus.Language (Language (..), SLanguage (..))
2324
import Cardano.Ledger.Shelley.LedgerState (curPParamsEpochStateL, nesEsL)
24-
import Cardano.Ledger.Tools (setMinCoinTxOut)
25+
import Cardano.Ledger.Tools (ensureMinCoinTxOut, setMinCoinTxOut)
2526
import Cardano.Ledger.TxIn (TxIn, mkTxInPartial)
26-
import Control.Monad (forM)
27+
import Control.Monad (forM, (>=>))
2728
import Data.List.NonEmpty (NonEmpty (..))
2829
import qualified Data.List.NonEmpty as NE
2930
import qualified Data.Sequence.Strict as SSeq
30-
import Lens.Micro ((&), (.~), (<>~))
31+
import GHC.Stack (HasCallStack)
32+
import Lens.Micro
3133
import Test.Cardano.Ledger.Alonzo.ImpTest
3234
import Test.Cardano.Ledger.Babbage.TreeDiff ()
3335
import Test.Cardano.Ledger.Plutus (testingCostModels)
@@ -37,7 +39,40 @@ instance ShelleyEraImp BabbageEra where
3739
defaultInitNewEpochState
3840
(nesEsL . curPParamsEpochStateL . ppCostModelsL <>~ testingCostModels [PlutusV2])
3941
impSatisfyNativeScript = impAllegraSatisfyNativeScript
40-
fixupTx = alonzoFixupTx
42+
fixupTx = babbageFixupTx
43+
44+
babbageFixupTx ::
45+
( HasCallStack
46+
, AlonzoEraImp era
47+
, BabbageEraTxBody era
48+
) =>
49+
Tx era ->
50+
ImpTestM era (Tx era)
51+
babbageFixupTx =
52+
addNativeScriptTxWits
53+
>=> fixupAuxDataHash
54+
>=> addCollateralInput
55+
>=> addRootTxIn
56+
>=> fixupScriptWits
57+
>=> fixupOutputDatums
58+
>=> fixupDatums
59+
>=> fixupRedeemerIndices
60+
>=> fixupTxOuts
61+
>=> fixupCollateralReturn
62+
>=> alonzoFixupFees
63+
>=> fixupRedeemers
64+
>=> fixupPPHash
65+
>=> updateAddrTxWits
66+
67+
fixupCollateralReturn ::
68+
( ShelleyEraImp era
69+
, BabbageEraTxBody era
70+
) =>
71+
Tx era ->
72+
ImpTestM era (Tx era)
73+
fixupCollateralReturn tx = do
74+
pp <- getsNES $ nesEsL . curPParamsEpochStateL
75+
pure $ tx & bodyTxL . collateralReturnTxBodyL %~ fmap (ensureMinCoinTxOut pp)
4176

4277
instance ShelleyEraImp BabbageEra => MaryEraImp BabbageEra
4378

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ instance ShelleyEraImp ConwayEra where
317317

318318
modifyPParams = conwayModifyPParams
319319

320-
fixupTx = alonzoFixupTx
320+
fixupTx = babbageFixupTx
321321

322322
instance MaryEraImp ConwayEra
323323

0 commit comments

Comments
 (0)