From d0ae0cda2061bbbc191660c8f81cd00723cbbc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 26 Sep 2024 12:04:51 +0200 Subject: [PATCH] create-testnet-data: add negative test of checking of genesis hash --- .../Test/Cli/CreateTestnetData.hs | 24 +++++ .../create-testnet-data/node-config.json | 92 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 cardano-cli/test/cardano-cli-test/files/input/conway/create-testnet-data/node-config.json diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/CreateTestnetData.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/CreateTestnetData.hs index b7cc44f4a9..29bb11454a 100644 --- a/cardano-cli/test/cardano-cli-test/Test/Cli/CreateTestnetData.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/CreateTestnetData.hs @@ -157,3 +157,27 @@ hprop_create_testnet_data_transient_stake_delegators = -- For the golden part of this test, we are anyway covered by 'hprop_golden_create_testnet_data' -- that generates strictly more stuff. + +-- Execute this test with: +-- @cabal test cardano-cli-test --test-options '-p "/create testnet wrong genesis hash/"'@ +hprop_create_testnet_wrong_genesis_hash :: Property +hprop_create_testnet_wrong_genesis_hash = + propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do + let outputDir = tempDir "out" + + (exitCode, _stdout, stderr) <- + H.noteShowM $ + execDetailCardanoCLI + [ "conway" + , "genesis" + , "create-testnet-data" + , "--testnet-magic" + , "42" + , "--node-configuration" + , "test/cardano-cli-test/files/input/conway/create-testnet-data/./node-config.json" + , "--out-dir" + , outputDir + ] + + exitCode === ExitFailure 1 + H.assertWith stderr ("Hash associated to key \"ConwayGenesisHash\" in file" `isInfixOf`) diff --git a/cardano-cli/test/cardano-cli-test/files/input/conway/create-testnet-data/node-config.json b/cardano-cli/test/cardano-cli-test/files/input/conway/create-testnet-data/node-config.json new file mode 100644 index 0000000000..dcfcd85f74 --- /dev/null +++ b/cardano-cli/test/cardano-cli-test/files/input/conway/create-testnet-data/node-config.json @@ -0,0 +1,92 @@ +{ + "AlonzoGenesisHash": "dbc03856c313ce69b7bbcaebcc775347cc8434b0333f67f0b744a359fab16eae", + "ByronGenesisHash": "3b580098c978f3f8654768e963ccabf1d6575480bd7ae18b6891d16f5ceeacea", + "ConwayGenesisHash": "b632b8469ea7d7ae8a66e5d1419f2992764eb6f1527c39aeaef2525f3d3fa5a9", + "EnableLogMetrics": false, + "EnableLogging": true, + "EnableP2P": false, + "ExperimentalHardForksEnabled": true, + "ExperimentalProtocolsEnabled": true, + "LastKnownBlockVersion-Alt": 0, + "LastKnownBlockVersion-Major": 2, + "LastKnownBlockVersion-Minor": 0, + "MaxConcurrencyBulkSync": 1, + "MaxConcurrencyDeadline": 2, + "PBftSignatureThreshold": 0.6, + "Protocol": "Cardano", + "RequiresNetworkMagic": "RequiresMagic", + "ShelleyGenesisHash": "00e8783a023250284b547e6d27c081c044424b56350bc5c83d95dc368efe7805", + "SocketPath": "db/node.socket", + "TestShelleyHardForkAtEpoch": 0, + "TraceBlockFetchClient": false, + "TraceBlockFetchDecisions": false, + "TraceBlockFetchProtocol": false, + "TraceBlockFetchProtocolSerialised": false, + "TraceBlockFetchServer": false, + "TraceBlockchainTime": true, + "TraceChainDb": true, + "TraceChainSyncBlockServer": false, + "TraceChainSyncClient": false, + "TraceChainSyncHeaderServer": false, + "TraceChainSyncProtocol": false, + "TraceConnectionManager": true, + "TraceDnsResolver": true, + "TraceDnsSubscription": true, + "TraceErrorPolicy": true, + "TraceForge": true, + "TraceHandshake": false, + "TraceIpSubscription": true, + "TraceLocalChainSyncProtocol": false, + "TraceLocalConnectionManager": false, + "TraceLocalErrorPolicy": true, + "TraceLocalHandshake": false, + "TraceLocalRootPeers": true, + "TraceLocalServer": false, + "TraceLocalTxSubmissionProtocol": false, + "TraceLocalTxSubmissionServer": false, + "TraceMempool": true, + "TraceMux": false, + "TracePeerSelection": true, + "TracePeerSelectionActions": true, + "TracePublicRootPeers": true, + "TraceServer": true, + "TraceTxInbound": false, + "TraceTxOutbound": false, + "TraceTxSubmissionProtocol": false, + "TurnOnLogMetrics": false, + "defaultBackends": [ + "KatipBK" + ], + "defaultScribes": [ + [ + "FileSK", + "logs/mainnet.log" + ], + [ + "StdoutSK", + "stdout" + ] + ], + "minSeverity": "Debug", + "options": {}, + "rotation": { + "rpKeepFilesNum": 3, + "rpLogLimitBytes": 5000000, + "rpMaxAgeHours": 24 + }, + "setupBackends": [ + "KatipBK" + ], + "setupScribes": [ + { + "scFormat": "ScJson", + "scKind": "FileSK", + "scName": "logs/node.log" + }, + { + "scFormat": "ScJson", + "scKind": "StdoutSK", + "scName": "stdout" + } + ] +}