Skip to content

Commit 668afdd

Browse files
committed
Add readUtxos smoke test
1 parent 12bae80 commit 668afdd

File tree

1 file changed

+33
-17
lines changed
  • cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Rpc

1 file changed

+33
-17
lines changed

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Rpc/Query.hs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
5050
let ceo = ConwayEraOnwardsConway
5151
sbe = convert ceo
5252
eraName = eraToString sbe
53-
options = def{cardanoNodeEra = AnyShelleyBasedEra sbe, cardanoEnableRpc=True}
53+
options = def{cardanoNodeEra = AnyShelleyBasedEra sbe, cardanoEnableRpc = True}
5454

5555
TestnetRuntime
5656
{ testnetMagic
@@ -62,7 +62,9 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
6262
execConfig <- mkExecConfig tempAbsPath' nodeSprocket testnetMagic
6363
epochStateView <- getEpochStateView configurationFile (nodeSocketPath node0)
6464
pparams <- unLedgerProtocolParameters <$> getProtocolParams epochStateView ceo
65-
H.noteShowPretty_ pparams
65+
-- H.noteShowPretty_ pparams
66+
utxos <- findAllUtxos epochStateView sbe
67+
H.noteShowPretty_ utxos
6668
rpcSocket <- H.note . unFile $ nodeRpcSocketPath node0
6769

6870
----------
@@ -74,24 +76,30 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
7476
ChainTipAtGenesis -> H.failure
7577
ChainTip (SlotNo slot) (HeaderHash hash) (BlockNo blockNo) -> pure (slot, SBS.fromShort hash, blockNo)
7678

77-
------------
78-
-- RPC query
79-
------------
79+
--------------
80+
-- RPC queries
81+
--------------
8082
let rpcServer = Rpc.ServerUnix rpcSocket
81-
response <- H.noteShowM . H.evalIO . Rpc.withConnection def rpcServer $ \conn -> do
82-
let req = Rpc.defMessage
83-
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readParams")) req
84-
85-
----------------
86-
-- Test response
87-
----------------
88-
response ^. #ledgerTip . #slot === slot
89-
response ^. #ledgerTip . #hash === blockHash
90-
response ^. #ledgerTip . #height === blockNo
91-
response ^. #ledgerTip . #timestamp === 0 -- not possible to implement at this moment
83+
(pparamsResponse, utxosResponse) <- H.noteShowM . H.evalIO . Rpc.withConnection def rpcServer $ \conn -> do
84+
pparams' <- do
85+
let req = Rpc.defMessage
86+
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readParams")) req
87+
88+
utxos' <- do
89+
let req = Rpc.defMessage
90+
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readUtxos")) req
91+
pure (pparams', utxos')
92+
93+
------------------------
94+
-- Test readParams response
95+
------------------------
96+
pparamsResponse ^. #ledgerTip . #slot === slot
97+
pparamsResponse ^. #ledgerTip . #hash === blockHash
98+
pparamsResponse ^. #ledgerTip . #height === blockNo
99+
pparamsResponse ^. #ledgerTip . #timestamp === 0 -- not possible to implement at this moment
92100

93101
-- https://docs.cardano.org/about-cardano/explore-more/parameter-guide
94-
let chainParams = response ^. #values . #cardano
102+
let chainParams = pparamsResponse ^. #values . #cardano
95103
babbageEraOnwardsConstraints (convert ceo) $ do
96104
pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to L.unCoin
97105
=== chainParams ^. #coinsPerUtxoByte . to fromIntegral
@@ -164,3 +172,11 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
164172
pparams ^. L.ppGovActionDepositL === chainParams ^. #governanceActionDeposit . to fromIntegral
165173
pparams ^. L.ppDRepDepositL === chainParams ^. #drepDeposit . to fromIntegral
166174
pparams ^. L.ppDRepActivityL . to L.unEpochInterval === chainParams ^. #drepInactivityPeriod . to fromIntegral
175+
176+
--------------------------
177+
-- Test readUtxos response
178+
--------------------------
179+
180+
H.noteShowPretty $ utxos
181+
H.noteShowPretty $ utxosResponse
182+
H.failure

0 commit comments

Comments
 (0)