@@ -33,10 +33,12 @@ import Cardano.Testnet
33
33
34
34
import Prelude
35
35
36
+ import Control.Lens ((^?) )
36
37
import Control.Monad (forM_ )
37
38
import Control.Monad.Catch (MonadCatch )
38
39
import qualified Data.Aeson as Aeson
39
40
import qualified Data.Aeson.Encode.Pretty as Aeson
41
+ import qualified Data.Aeson.Lens as Aeson
40
42
import qualified Data.Aeson.Key as Aeson
41
43
import qualified Data.Aeson.KeyMap as Aeson
42
44
import Data.Bifunctor (bimap )
@@ -231,6 +233,39 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
231
233
H. noteM_ $ execCli' execConfig [ eraName, " query" , " stake-distribution"
232
234
, " --out-file" , stakePoolsOutFile ]
233
235
236
+ TestQuerySPOStakeDistributionCmd ->
237
+ -- spo-stake-distribution
238
+ do
239
+ -- Query all SPOs
240
+ aesonSpoDist :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution" , " --all-spos" ]
241
+ secondHash <- H. evalMaybe $ T. unpack <$> aesonSpoDist ^? Aeson. nth 1 . Aeson. nth 0 . Aeson. _String
242
+ secondAmount <- H. evalMaybe $ aesonSpoDist ^? Aeson. nth 1 . Aeson. nth 1 . Aeson. _Number
243
+
244
+ -- Query individual SPO using result and ensure result is the same
245
+ secondSpoInfo :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution" , " --spo-key-hash" , secondHash ]
246
+ individualHash <- H. evalMaybe $ T. unpack <$> secondSpoInfo ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
247
+ individualAmount <- H. evalMaybe $ secondSpoInfo ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
248
+ secondHash === individualHash
249
+ secondAmount === individualAmount
250
+
251
+ -- Query individual SPO using SPOs verification file
252
+ let spoKey = verificationKey . poolNodeKeysCold $ Defaults. defaultSpoKeys 1
253
+ fileQueryResult :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution"
254
+ , " --spo-verification-key-file" , unFile spoKey
255
+ ]
256
+ fileQueryHash <- H. evalMaybe $ T. unpack <$> fileQueryResult ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
257
+ fileQueryAmount <- H. evalMaybe $ fileQueryResult ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
258
+
259
+ -- Query individual SPO using SPOs bech32 of key and compare to previous result
260
+ delegatorVKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile AsStakePoolKey work spoKey
261
+ keyQueryResult :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution"
262
+ , " --spo-verification-key" , T. unpack $ serialiseToBech32 delegatorVKey
263
+ ]
264
+ keyQueryHash <- H. evalMaybe $ T. unpack <$> keyQueryResult ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
265
+ keyQueryAmount <- H. evalMaybe $ keyQueryResult ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
266
+ fileQueryHash === keyQueryHash
267
+ fileQueryAmount === keyQueryAmount
268
+
234
269
TestQueryStakeAddressInfoCmd ->
235
270
-- stake-address-info
236
271
do
@@ -363,9 +398,6 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
363
398
-- treasury
364
399
H. noteM_ $ execCli' execConfig [ eraName, " query" , " treasury" ]
365
400
366
- TestQuerySPOStakeDistributionCmd -> do
367
- pure () -- FIXME: https://github.com/IntersectMBO/cardano-node/pull/5932
368
-
369
401
where
370
402
-- | Wait for the part of the epoch when futurePParams are known
371
403
waitForFuturePParamsToStabilise
0 commit comments