|
| 1 | +{-# LANGUAGE DataKinds #-} |
| 2 | +{-# LANGUAGE NamedFieldPuns #-} |
| 3 | +{-# LANGUAGE OverloadedLabels #-} |
| 4 | +{-# LANGUAGE OverloadedLists #-} |
| 5 | +{-# LANGUAGE OverloadedStrings #-} |
| 6 | +{-# LANGUAGE ScopedTypeVariables #-} |
| 7 | +{-# LANGUAGE TypeApplications #-} |
| 8 | + |
| 9 | +module Cardano.Testnet.Test.Rpc.Transaction |
| 10 | + ( hprop_rpc_transaction |
| 11 | + ) |
| 12 | +where |
| 13 | + |
| 14 | +import Cardano.Api |
| 15 | +import qualified Cardano.Api.Ledger as L |
| 16 | + |
| 17 | +import Cardano.CLI.Type.Output (QueryTipLocalStateOutput (..)) |
| 18 | +import qualified Cardano.Ledger.Api as L |
| 19 | +import qualified Cardano.Ledger.Binary.Version as L |
| 20 | +import qualified Cardano.Ledger.Conway.Core as L |
| 21 | +import qualified Cardano.Ledger.Conway.PParams as L |
| 22 | +import qualified Cardano.Ledger.Plutus as L |
| 23 | +import qualified Cardano.Rpc.Client as Rpc |
| 24 | +import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as UtxoRpc |
| 25 | +import Cardano.Rpc.Server.Internal.UtxoRpc.Query () |
| 26 | +import Cardano.Testnet |
| 27 | + |
| 28 | +import Prelude |
| 29 | + |
| 30 | +import qualified Data.ByteString.Short as SBS |
| 31 | +import Data.Default.Class |
| 32 | +import qualified Data.Map.Strict as M |
| 33 | +import Lens.Micro |
| 34 | + |
| 35 | +import Testnet.Components.Query |
| 36 | +import Testnet.Process.Run |
| 37 | +import Testnet.Property.Util (integrationRetryWorkspace) |
| 38 | +import Testnet.Start.Types |
| 39 | + |
| 40 | +import Hedgehog |
| 41 | +import qualified Hedgehog as H |
| 42 | +import qualified Hedgehog.Extras.Test.Base as H |
| 43 | +import qualified Hedgehog.Extras.Test.TestWatchdog as H |
| 44 | + |
| 45 | +hprop_rpc_transaction :: Property |
| 46 | +hprop_rpc_transaction = integrationRetryWorkspace 2 "rpc-tx" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do |
| 47 | + conf@Conf{tempAbsPath} <- mkConf tempAbsBasePath' |
| 48 | + let tempAbsPath' = unTmpAbsPath tempAbsPath |
| 49 | + |
| 50 | + let ceo = ConwayEraOnwardsConway |
| 51 | + sbe = convert ceo |
| 52 | + eraName = eraToString sbe |
| 53 | + options = def{cardanoNodeEra = AnyShelleyBasedEra sbe, cardanoEnableRpc = True} |
| 54 | + |
| 55 | + TestnetRuntime |
| 56 | + { testnetMagic |
| 57 | + , configurationFile |
| 58 | + , testnetNodes = node0@TestnetNode{nodeSprocket} : _ |
| 59 | + } <- |
| 60 | + createAndRunTestnet options def conf |
| 61 | + |
| 62 | + execConfig <- mkExecConfig tempAbsPath' nodeSprocket testnetMagic |
| 63 | + epochStateView <- getEpochStateView configurationFile (nodeSocketPath node0) |
| 64 | + pparams <- unLedgerProtocolParameters <$> getProtocolParams epochStateView ceo |
| 65 | + -- H.noteShowPretty_ pparams |
| 66 | + utxos <- findAllUtxos epochStateView sbe |
| 67 | + H.noteShowPretty_ utxos |
| 68 | + rpcSocket <- H.note . unFile $ nodeRpcSocketPath node0 |
| 69 | + |
| 70 | + -------------- |
| 71 | + -- RPC queries |
| 72 | + -------------- |
| 73 | + let rpcServer = Rpc.ServerUnix rpcSocket |
| 74 | + (pparamsResponse, utxosResponse) <- H.noteShowM . H.evalIO . Rpc.withConnection def rpcServer $ \conn -> do |
| 75 | + pparams' <- do |
| 76 | + let req = Rpc.defMessage |
| 77 | + Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readParams")) req |
| 78 | + |
| 79 | + utxos' <- do |
| 80 | + let req = Rpc.defMessage |
| 81 | + Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readUtxos")) req |
| 82 | + pure (pparams', utxos') |
| 83 | + |
| 84 | + H.failure |
0 commit comments