@@ -33,17 +33,19 @@ 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
40
41
import qualified Data.Aeson.Key as Aeson
41
42
import qualified Data.Aeson.KeyMap as Aeson
43
+ import qualified Data.Aeson.Lens as Aeson
42
44
import Data.Bifunctor (bimap )
43
45
import qualified Data.ByteString.Lazy as LBS
44
46
import Data.Data (type (:~: ) (Refl ))
45
47
import qualified Data.Map as Map
46
- import Data.String
48
+ import Data.String ( IsString ( fromString ))
47
49
import Data.Text (Text )
48
50
import qualified Data.Text as T
49
51
import qualified Data.Text.Lazy as TL
@@ -56,6 +58,7 @@ import Lens.Micro ((^.))
56
58
import System.Directory (makeAbsolute )
57
59
import System.FilePath ((</>) )
58
60
61
+ import Testnet.Components.Configuration (eraToString )
59
62
import Testnet.Components.Query (EpochStateView , checkDRepsNumber , getEpochStateView ,
60
63
watchEpochStateUpdate )
61
64
import qualified Testnet.Defaults as Defaults
@@ -65,7 +68,6 @@ import Testnet.Process.Cli.Transaction (TxOutAddress (ReferenceScriptA
65
68
import Testnet.Process.Run (execCli' , execCliStdoutToJson , mkExecConfig )
66
69
import Testnet.Property.Assert (assertErasEqual )
67
70
import Testnet.Property.Util (integrationWorkspace )
68
- import Testnet.Start.Types (eraToString )
69
71
import Testnet.TestQueryCmds (TestQueryCmds (.. ), forallQueryCommands )
70
72
import Testnet.Types
71
73
@@ -230,6 +232,39 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
230
232
H. noteM_ $ execCli' execConfig [ eraName, " query" , " stake-distribution"
231
233
, " --out-file" , stakePoolsOutFile ]
232
234
235
+ TestQuerySPOStakeDistributionCmd ->
236
+ -- spo-stake-distribution
237
+ do
238
+ -- Query all SPOs
239
+ aesonSpoDist :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution" , " --all-spos" ]
240
+ secondHash <- H. evalMaybe $ T. unpack <$> aesonSpoDist ^? Aeson. nth 1 . Aeson. nth 0 . Aeson. _String
241
+ secondAmount <- H. evalMaybe $ aesonSpoDist ^? Aeson. nth 1 . Aeson. nth 1 . Aeson. _Number
242
+
243
+ -- Query individual SPO using result and ensure result is the same
244
+ secondSpoInfo :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution" , " --spo-key-hash" , secondHash ]
245
+ individualHash <- H. evalMaybe $ T. unpack <$> secondSpoInfo ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
246
+ individualAmount <- H. evalMaybe $ secondSpoInfo ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
247
+ secondHash === individualHash
248
+ secondAmount === individualAmount
249
+
250
+ -- Query individual SPO using SPOs verification file
251
+ let spoKey = verificationKey . poolNodeKeysCold $ Defaults. defaultSpoKeys 1
252
+ fileQueryResult :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution"
253
+ , " --spo-verification-key-file" , unFile spoKey
254
+ ]
255
+ fileQueryHash <- H. evalMaybe $ T. unpack <$> fileQueryResult ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
256
+ fileQueryAmount <- H. evalMaybe $ fileQueryResult ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
257
+
258
+ -- Query individual SPO using SPOs bech32 of key and compare to previous result
259
+ delegatorVKey :: VerificationKey StakePoolKey <- readVerificationKeyFromFile AsStakePoolKey work spoKey
260
+ keyQueryResult :: Aeson. Value <- execCliStdoutToJson execConfig [ eraName, " query" , " spo-stake-distribution"
261
+ , " --spo-verification-key" , T. unpack $ serialiseToBech32 delegatorVKey
262
+ ]
263
+ keyQueryHash <- H. evalMaybe $ T. unpack <$> keyQueryResult ^? Aeson. nth 0 . Aeson. nth 0 . Aeson. _String
264
+ keyQueryAmount <- H. evalMaybe $ keyQueryResult ^? Aeson. nth 0 . Aeson. nth 1 . Aeson. _Number
265
+ fileQueryHash === keyQueryHash
266
+ fileQueryAmount === keyQueryAmount
267
+
233
268
TestQueryStakeAddressInfoCmd ->
234
269
-- stake-address-info
235
270
do
@@ -362,9 +397,6 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H.
362
397
-- treasury
363
398
H. noteM_ $ execCli' execConfig [ eraName, " query" , " treasury" ]
364
399
365
- TestQuerySPOStakeDistributionCmd -> do
366
- pure () -- FIXME: https://github.com/IntersectMBO/cardano-node/pull/5932
367
-
368
400
where
369
401
-- | Wait for the part of the epoch when futurePParams are known
370
402
waitForFuturePParamsToStabilise
0 commit comments