@@ -16,8 +16,7 @@ module Cardano.Testnet.Test.Cli.Query
1616import Cardano.Api
1717import Cardano.Api.Experimental (Some (.. ))
1818import qualified Cardano.Api.Genesis as Api
19- import Cardano.Api.Ledger (Coin (Coin ), EpochInterval (EpochInterval ), StandardCrypto ,
20- extractHash , unboundRational )
19+ import Cardano.Api.Ledger (Coin (Coin ), EpochInterval (EpochInterval ), StandardCrypto , unboundRational )
2120import qualified Cardano.Api.Ledger as L
2221import Cardano.Api.Shelley (StakeCredential (StakeCredentialByKey ), StakePoolKey )
2322
@@ -26,10 +25,6 @@ import Cardano.CLI.Types.Key (VerificationKeyOrFile (VerificationKeyFi
2625import Cardano.CLI.Types.Output (QueryTipLocalStateOutput )
2726import Cardano.Crypto.Hash (hashToStringAsHex )
2827import qualified Cardano.Ledger.BaseTypes as L
29- import Cardano.Ledger.Core (valueTxOutL )
30- import Cardano.Ledger.Shelley.LedgerState (esLStateL , lsUTxOStateL , nesEpochStateL ,
31- utxosUtxoL )
32- import qualified Cardano.Ledger.UTxO as L
3328import Cardano.Testnet
3429
3530import Prelude
@@ -56,7 +51,6 @@ import qualified Data.Vector as Vector
5651import GHC.Exts (IsList (.. ))
5752import GHC.Stack (HasCallStack , withFrozenCallStack )
5853import qualified GHC.Stack as GHC
59- import Lens.Micro ((^.) )
6054import System.Directory (makeAbsolute )
6155import System.FilePath ((</>) )
6256
@@ -352,6 +346,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
352346 [(ReferenceScriptAddress plutusV3Script, transferAmount)]
353347 signedTx <- signTx execConfig cEra refScriptSizeWork " signed-tx" txBody [Some $ paymentKeyInfoPair wallet1]
354348 submitTx execConfig cEra signedTx
349+
355350 -- Wait until transaction is on chain and obtain transaction identifier
356351 txId <- retrieveTransactionId execConfig signedTx
357352 txIx <- H. evalMaybeM $ watchEpochStateUpdate epochStateView (EpochInterval 2 ) (getTxIx sbe txId transferAmount)
@@ -493,15 +488,15 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
493488 makeStakeAddress (fromNetworkMagic $ NetworkMagic $ fromIntegral testnetMagic) (StakeCredentialByKey $ verificationKeyHash delegatorVKey)
494489
495490 getTxIx :: forall m era . HasCallStack => MonadTest m => ShelleyBasedEra era -> String -> Coin -> (AnyNewEpochState , SlotNo , BlockNo ) -> m (Maybe Int )
496- getTxIx sbe txId amount (AnyNewEpochState sbe' newEpochState _ , _, _) = do
491+ getTxIx sbe txId amount (AnyNewEpochState sbe' _ tbs , _, _) = do
497492 Refl <- H. leftFail $ assertErasEqual sbe sbe'
498- shelleyBasedEraConstraints sbe' ( do
499- return $ Map. foldlWithKey (\ acc (L. TxIn (L. TxId thisTxId) (L. TxIx thisTxIx)) txOut ->
493+ shelleyBasedEraConstraints sbe' $ do
494+ return $ Map. foldlWithKey (\ acc (TxIn (TxId thisTxId) (TxIx thisTxIx)) ( TxOut _ txOutValue _ _) ->
500495 case acc of
501- Nothing | hashToStringAsHex (extractHash thisTxId) == txId &&
502- valueToLovelace (fromLedgerValue sbe (txOut ^. valueTxOutL)) == Just amount -> Just $ fromIntegral thisTxIx
496+ Nothing | hashToStringAsHex thisTxId == txId &&
497+ txOutValueToLovelace txOutValue == amount -> Just $ fromIntegral thisTxIx
503498 | otherwise -> Nothing
504- x -> x) Nothing $ L. unUTxO $ newEpochState ^. nesEpochStateL . esLStateL . lsUTxOStateL . utxosUtxoL)
499+ x -> x) Nothing $ getUTxOValues sbe' tbs
505500
506501-- | @redactJsonStringFieldInFile [(k0, v0), (k1, v1), ..] sourceFilePath targetFilePath@ reads the JSON at @sourceFilePath@, and then
507502-- replaces the value associated to @k0@ by @v0@, replaces the value associated to @k1@ by @v1@, etc.
0 commit comments