From c860faf5ffd3bb01f11e0d08a4e3eeccd4f95baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 9 Nov 2023 16:51:42 +0100 Subject: [PATCH 1/5] Genesis/Create: harden an existing test --- .../Test/Golden/Shelley/Genesis/Create.hs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs index 183e342fef..7cbf5c79b9 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs @@ -17,6 +17,7 @@ import qualified Data.HashMap.Lazy as HM import qualified Data.Set as S import qualified Data.Time.Clock as DT +import Test.Cardano.CLI.Aeson (assertHasMappings) import Test.Cardano.CLI.Util as OP import Hedgehog (Property, forAll, (===)) @@ -129,24 +130,24 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do for_ [1 .. delegateCount] $ \i -> do -- Check Genesis keys - H.assertFileOccurences 1 "GenesisSigningKey_ed25519" $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisVerificationKey_ed25519" $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" + assertHasMappings [("type", "GenesisVerificationKey_ed25519")] $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" + assertHasMappings [("type", "GenesisSigningKey_ed25519")] $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" -- Check delegate keys - H.assertFileOccurences 1 "GenesisDelegateSigningKey_ed25519" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisDelegateVerificationKey_ed25519" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" - H.assertFileOccurences 1 "NodeOperationalCertificateIssueCounter" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" + assertHasMappings [("type", "GenesisDelegateSigningKey_ed25519")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" + assertHasMappings [("type", "GenesisDelegateVerificationKey_ed25519")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" + assertHasMappings [("type", "NodeOperationalCertificateIssueCounter")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" -- Check utxo keys - H.assertFileOccurences 1 "GenesisUTxOSigningKey_ed25519" $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisUTxOVerificationKey_ed25519" $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" + assertHasMappings [("type", "GenesisUTxOSigningKey_ed25519")] $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" + assertHasMappings [("type", "GenesisUTxOVerificationKey_ed25519")] $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" H.assertEndsWithSingleNewline $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" @@ -208,24 +209,24 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do for_ [1 .. delegateCount] $ \i -> do -- Check Genesis keys - H.assertFileOccurences 1 "GenesisSigningKey_ed25519" $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisVerificationKey_ed25519" $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" + assertHasMappings [("type", "GenesisSigningKey_ed25519")] $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" + assertHasMappings [("type", "GenesisVerificationKey_ed25519")] $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" H.assertEndsWithSingleNewline $ tempDir <> "/genesis-keys/genesis" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/genesis-keys/genesis" <> show i <> ".vkey" -- Check delegate keys - H.assertFileOccurences 1 "GenesisDelegateSigningKey_ed25519" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisDelegateVerificationKey_ed25519" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" - H.assertFileOccurences 1 "NodeOperationalCertificateIssueCounter" $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" + assertHasMappings [("type", "GenesisDelegateSigningKey_ed25519")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" + assertHasMappings [("type", "GenesisDelegateVerificationKey_ed25519")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" + assertHasMappings [("type", "NodeOperationalCertificateIssueCounter")] $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".vkey" H.assertEndsWithSingleNewline $ tempDir <> "/delegate-keys/delegate" <> show i <> ".counter" -- Check utxo keys - H.assertFileOccurences 1 "GenesisUTxOSigningKey_ed25519" $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" - H.assertFileOccurences 1 "GenesisUTxOVerificationKey_ed25519" $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" + assertHasMappings [("type", "GenesisUTxOSigningKey_ed25519")] $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" + assertHasMappings [("type", "GenesisUTxOVerificationKey_ed25519")] $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" H.assertEndsWithSingleNewline $ tempDir <> "/utxo-keys/utxo" <> show i <> ".skey" H.assertEndsWithSingleNewline $ tempDir <> "/utxo-keys/utxo" <> show i <> ".vkey" From b1248fba6b37009ced2d673110a8f2f4a9320d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Nov 2023 12:13:58 +0100 Subject: [PATCH 2/5] Shelley/Genesis: harden an existing test --- .../Test/Golden/Shelley/Genesis/KeyGenGenesis.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs index d08d1675a6..bdc4b0035d 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs @@ -4,6 +4,7 @@ module Test.Golden.Shelley.Genesis.KeyGenGenesis where import Control.Monad (void) +import Test.Cardano.CLI.Aeson import Test.Cardano.CLI.Util import Hedgehog (Property) @@ -23,8 +24,8 @@ hprop_golden_shelleyGenesisKeyGenGenesis = propertyOnce . H.moduleWorkspace "tmp , "--signing-key-file", signingKeyFile ] - H.assertFileOccurences 1 "GenesisVerificationKey_ed25519" verificationKeyFile - H.assertFileOccurences 1 "GenesisSigningKey_ed25519" signingKeyFile + assertHasMappings [("type", "GenesisVerificationKey_ed25519")] verificationKeyFile + assertHasMappings [("type", "GenesisSigningKey_ed25519")] signingKeyFile H.assertEndsWithSingleNewline verificationKeyFile H.assertEndsWithSingleNewline signingKeyFile From a3e55eec8293383d7461e336c8d0355e5d90397b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Nov 2023 12:16:54 +0100 Subject: [PATCH 3/5] Shelley/Genesis: harden an existing test --- .../Test/Golden/Shelley/Genesis/KeyGenUtxo.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs index e6f234d3bb..d3dff1416b 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs @@ -4,6 +4,7 @@ module Test.Golden.Shelley.Genesis.KeyGenUtxo where import Control.Monad (void) +import Test.Cardano.CLI.Aeson import Test.Cardano.CLI.Util import Hedgehog (Property) @@ -23,8 +24,8 @@ hprop_golden_shelleyGenesisKeyGenUtxo = propertyOnce . H.moduleWorkspace "tmp" $ , "--signing-key-file", utxoSigningKeyFile ] - H.assertFileOccurences 1 "GenesisUTxOVerificationKey_ed25519" utxoVerificationKeyFile - H.assertFileOccurences 1 "GenesisUTxOSigningKey_ed25519" utxoSigningKeyFile + assertHasMappings [("type", "GenesisUTxOVerificationKey_ed25519")] utxoVerificationKeyFile + assertHasMappings [("type", "GenesisUTxOSigningKey_ed25519")] utxoSigningKeyFile H.assertEndsWithSingleNewline utxoVerificationKeyFile H.assertEndsWithSingleNewline utxoSigningKeyFile From 59039f802e353861809840be0ce85d5890c94fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Nov 2023 12:19:50 +0100 Subject: [PATCH 4/5] Shelley/Node: harden an existing test --- .../Test/Golden/Shelley/Node/KeyGenVrf.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/KeyGenVrf.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/KeyGenVrf.hs index 3f7fc72793..944ed4b339 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/KeyGenVrf.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/KeyGenVrf.hs @@ -4,6 +4,7 @@ module Test.Golden.Shelley.Node.KeyGenVrf where import Control.Monad (void) +import Test.Cardano.CLI.Aeson import Test.Cardano.CLI.Util import Hedgehog (Property) @@ -23,8 +24,8 @@ hprop_golden_shelleyNodeKeyGenVrf = propertyOnce . H.moduleWorkspace "tmp" $ \te , "--signing-key-file", signingKey ] - H.assertFileOccurences 1 "VRF Verification Key" verificationKey - H.assertFileOccurences 1 "VRF Signing Key" signingKey + assertHasMappings [("type", "VrfVerificationKey_PraosVRF"), ("description", "VRF Verification Key")] verificationKey + assertHasMappings [("type", "VrfSigningKey_PraosVRF"), ("description", "VRF Signing Key")] signingKey H.assertEndsWithSingleNewline verificationKey H.assertEndsWithSingleNewline signingKey @@ -41,8 +42,8 @@ hprop_golden_shelleyNodeKeyGenVrf_te = propertyOnce . H.moduleWorkspace "tmp" $ , "--signing-key-file", signingKey ] - H.assertFileOccurences 1 "VRF Verification Key" verificationKey - H.assertFileOccurences 1 "VRF Signing Key" signingKey + assertHasMappings [("type", "VrfVerificationKey_PraosVRF"), ("description", "VRF Verification Key")] verificationKey + assertHasMappings [("type", "VrfSigningKey_PraosVRF"), ("description", "VRF Signing Key")] signingKey H.assertEndsWithSingleNewline verificationKey H.assertEndsWithSingleNewline signingKey From 0775ed714a451d2311288734fe8abeff7d896124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Nov 2023 15:14:12 +0100 Subject: [PATCH 5/5] Shelley/Node: harden an existing test --- .../Test/Golden/Shelley/Node/IssueOpCert.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs index faadd0e372..f5839cabc5 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs @@ -4,6 +4,7 @@ module Test.Golden.Shelley.Node.IssueOpCert where import Control.Monad (void) +import Test.Cardano.CLI.Aeson (assertHasMappings) import Test.Cardano.CLI.Util import Hedgehog (Property) @@ -37,8 +38,8 @@ hprop_golden_shelleyNodeIssueOpCert = propertyOnce . H.moduleWorkspace "tmp" $ \ , "--out-file", operationalCertFile ] - H.assertFileOccurences 1 "NodeOperationalCertificate" operationalCertFile - H.assertFileOccurences 1 "Next certificate issue number: 1" operationalCertificateIssueCounterFile + assertHasMappings [("type", "NodeOperationalCertificate")] operationalCertFile + assertHasMappings [("type", "NodeOperationalCertificateIssueCounter"), ("description", "Next certificate issue number: 1")] operationalCertificateIssueCounterFile H.assertEndsWithSingleNewline operationalCertFile H.assertEndsWithSingleNewline operationalCertificateIssueCounterFile