Skip to content

Commit c7f0287

Browse files
committed
Use certs w/out deposits in some script validation tests
For some reason, these tests fail if we use certificates with deposits, so as a temporary measure we will avoid using deposits in these cases. Related: #4571
1 parent a5d8109 commit c7f0287

File tree

1 file changed

+20
-5
lines changed
  • eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec

1 file changed

+20
-5
lines changed

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Valid.hs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
module Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec.Valid (spec, alonzoEraSpecificSpec) where
1212

13+
import Cardano.Ledger.Address
1314
import Cardano.Ledger.Allegra.Scripts (
1415
pattern RequireTimeExpire,
1516
)
@@ -19,9 +20,9 @@ import Cardano.Ledger.Alonzo.Rules (
1920
)
2021
import Cardano.Ledger.Alonzo.Scripts (eraLanguages)
2122
import Cardano.Ledger.Alonzo.TxWits (unTxDatsL)
22-
import Cardano.Ledger.BaseTypes (StrictMaybe (..), inject, natVersion)
23+
import Cardano.Ledger.BaseTypes (Globals (networkId), StrictMaybe (..), inject, natVersion)
2324
import Cardano.Ledger.Coin (Coin (..))
24-
import Cardano.Ledger.Credential (Credential (..), StakeReference (..))
25+
import Cardano.Ledger.Credential (Credential (..), StakeReference (..), credToText)
2526
import Cardano.Ledger.Mary.Value (AssetName (..), MaryValue (..), MultiAsset (..), PolicyID (..))
2627
import Cardano.Ledger.Plutus (
2728
Data (..),
@@ -35,8 +36,10 @@ import Cardano.Ledger.Shelley.Scripts (
3536
pattern RequireSignature,
3637
)
3738
import qualified Data.Map.Strict as Map
39+
import qualified Data.Sequence.Strict as SSeq
40+
import qualified Data.Text as T
3841
import GHC.Exts (fromList)
39-
import Lens.Micro ((%~), (&), (.~))
42+
import Lens.Micro (to, (%~), (&), (.~))
4043
import Lens.Micro.Mtl (use)
4144
import qualified PlutusLedgerApi.Common as P
4245
import Test.Cardano.Ledger.Alonzo.ImpTest
@@ -157,7 +160,7 @@ alonzoEraSpecificSpec = do
157160
mkBasicTxBody & withdrawalsTxBodyL .~ Withdrawals [(account, mempty)]
158161

159162
it "Not validating WITHDRAWAL script" $ do
160-
account <- registerStakeCredential $ ScriptHashObj alwaysFailsNoDatumHash
163+
account <- registerStakeCredentialNoDeposit $ ScriptHashObj alwaysFailsNoDatumHash
161164
submitPhase2Invalid_ $
162165
mkBasicTx $
163166
mkBasicTxBody & withdrawalsTxBodyL .~ Withdrawals [(account, mempty)]
@@ -183,7 +186,7 @@ alonzoEraSpecificSpec = do
183186
rewardScriptHashes = [alwaysSucceedsNoDatumHash, timelockScriptHash2]
184187
txIns <- traverse produceScript inputScriptHashes
185188
multiAsset <- MultiAsset . fromList <$> traverse scriptAsset assetScriptHashes
186-
rewardAccounts <- traverse (registerStakeCredential . ScriptHashObj) rewardScriptHashes
189+
rewardAccounts <- traverse (registerStakeCredentialNoDeposit . ScriptHashObj) rewardScriptHashes
187190
outputAddr <- freshKeyHash @'Payment
188191
let
189192
txOut =
@@ -215,3 +218,15 @@ alonzoEraSpecificSpec = do
215218
else
216219
-- Conway fixed the bug that was causing DELEG to fail
217220
submitTx_ tx
221+
where
222+
-- NOTE: certain tests somehow require certificates without deposits
223+
-- otherwise, they will yield a Plutus failure
224+
-- TODO: figure out what's the problem, this might be of interest:
225+
-- https://github.com/IntersectMBO/cardano-ledger/issues/4571
226+
registerStakeCredentialNoDeposit cred = do
227+
submitTxAnn_ ("Register Reward Account: " <> T.unpack (credToText cred)) $
228+
mkBasicTx mkBasicTxBody
229+
& bodyTxL . certsTxBodyL
230+
.~ SSeq.fromList [RegTxCert cred]
231+
nId <- use (impGlobalsL . to networkId)
232+
pure $ RewardAccount nId cred

0 commit comments

Comments
 (0)