Cardano-node: Unit tests

Created on 27 Feb 2020  ยท  6Comments  ยท  Source: input-output-hk/cardano-node

Hi,
I've checked /cardano-node/cardano-node/test/ directory and I found only Spec.hs which contained only

import Cardano.Prelude

main :: IO ()
main = putStrLn "Test suite not yet implemented"

Are UNIT tests not yet implemented or am I looking in a wrong place? If they are not yet implemented, when do you expect to implement them and don't you think they would be a good first issue candidates for new developers?

good first issue priority medium

Most helpful comment

@oneEdoubleD, thanks, I have noticed and I am looking around the dependency tree.

All 6 comments

The cardano-cli will be in flux soon (again) so we are going to hold off on writing tests until those changes have been made.

It's worth noting that the node is almost like a wrapper of several different components (consensus, ledger, networking, ...) that _do_ have unit tests. There should be some tests around the CLI (once it's stable) though!

@oneEdoubleD, thanks, I have noticed and I am looking around the dependency tree.

Yes, there are lots of Hedgehog/Quickcheck tests in the various components. It would be great to have additional unit tests, of course, once the CLI has stabilised! All contributions welcome!

Thank you sir mark
I'm trying to help you
And find some answers to your question.

There are now numerous tests in this repo.

The test output (cabal test all -j1):

Building test suite 'cardano-api-test' for cardano-api-1.13.0..
Running 1 test suites...
Test suite cardano-api-test: RUNNING...
โ”โ”โ” Test.Cardano.Api.CBOR โ”โ”โ”
  โœ“ prop_AddressByron_CBOR passed 100 tests.
  โœ“ prop_AddressShelley_CBOR passed 100 tests.
  โœ“ prop_Certificate_CBOR passed 100 tests.
  โœ“ prop_GenesisVerificationKey_CBOR passed 100 tests.
  โœ“ prop_SigningKey_CBOR passed 100 tests.
  โœ“ prop_Update_CBOR passed 100 tests.
  โœ“ prop_PaymentVerificationKey_CBOR passed 100 tests.
  โœ“ prop_StakingVerificationKey_CBOR passed 100 tests.
  โœ“ prop_VerificationKeyStakePool_CBOR passed 100 tests.
  โœ“ prop_VerificationKeyStaking_CBOR passed 100 tests.
  โœ“ prop_VerificationKeyVRF_CBOR passed 100 tests.
  โœ“ prop_TxSigned_CBOR passed 100 tests.
  โœ“ prop_TxUnsigned_CBOR passed 100 tests.
  โœ“ 13 succeeded.
โ”โ”โ” Test.Cardano.Api.Convert โ”โ”โ”
  โœ“ prop_roundtrip_AddressShelley_hex passed 500 tests.
  โœ“ prop_roundtrip_TxIn_hex passed 500 tests.
  โœ“ prop_roundtrip_TxOut_hex passed 500 tests.
  โœ“ 3 succeeded.
โ”โ”โ” Test.Cardano.Api.View โ”โ”โ”
  โœ“ prop_roundtrip_AddressByron_view passed 100 tests.
  โœ“ prop_roundtrip_AddressShelley_view passed 100 tests.
  โœ“ prop_roundtrip_CertificateShelley_view passed 100 tests.
  โœ“ prop_roundtrip_GenesisVerificationKey_view passed 100 tests.
  โœ“ prop_roundtrip_SigningKey_view passed 100 tests.
  โœ“ prop_roundtrip_Update_view passed 100 tests.
  โœ“ prop_roundtrip_PaymentVerificationKey_view passed 100 tests.
  โœ“ prop_roundtrip_StakingVerificationKey_view passed 100 tests.
  โœ“ prop_roundtrip_VerificationKeyVRF_view passed 100 tests.
  โœ“ prop_roundtrip_TxSigned_view passed 100 tests.
  โœ“ prop_roundtrip_TxUnsigned_view passed 100 tests.
  โœ“ 11 succeeded.
โ”โ”โ” Test.Cardano.Api โ”โ”โ”
  โœ“ prop_byronGenSigningKey_unique passed 100 tests.
  โœ“ prop_shelleyGenSigningKey_unique passed 100 tests.
  โœ“ 2 succeeded.
โ”โ”โ” Test.Cardano.Api.Typed.CBOR โ”โ”โ”
  โœ“ prop_roundtrip_operational_certificate_CBOR passed 100 tests.
  โœ“ prop_roundtrip_operational_certificate_issue_counter_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_byron_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_byron_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_payment_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_payment_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_stake_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_stake_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_genesis_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_genesis_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_genesis_delegate_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_genesis_delegate_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_stake_pool_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_stake_pool_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_vrf_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_vrf_CBOR passed 100 tests.
  โœ“ prop_roundtrip_verification_key_kes_CBOR passed 100 tests.
  โœ“ prop_roundtrip_signing_key_kes_CBOR passed 100 tests.
  โœ“ 18 succeeded.
โ”โ”โ” Test.Cardano.Api.Typed.Envelope โ”โ”โ”
  โœ“ prop_roundtrip_ByronVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_ByronSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_PaymentVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_PaymentSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_StakeVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_StakeSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_StakePoolVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_StakePoolSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_GenesisVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_GenesisSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_GenesisDelegateVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_GenesisDelegateSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_KesVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_KesSigningKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_VrfVerificationKey_envelope passed 100 tests.
  โœ“ prop_roundtrip_VrfSigningKey_envelope passed 100 tests.
  โœ“ 16 succeeded.
โ”โ”โ” Test.Cardano.Api.Typed.RawBytes โ”โ”โ”
  โœ“ prop_roundtrip_shelley_address_raw passed 100 tests.
  โœ“ prop_roundtrip_byron_address_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_ByronKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_PaymentKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_StakeKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_StakePoolKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_GenesisKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_GenesisDelegateKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_KesKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_VrfKey_hash_raw passed 100 tests.
  โœ“ prop_roundtrip_verification_GenesisUTxOKey_hash_raw passed 100 tests.
  โœ“ 11 succeeded.
Test suite cardano-api-test: PASS
Building test suite 'cardano-cli-pioneers' for cardano-cli-1.13.0..
Running 1 test suites...
Test suite cardano-cli-pioneers: RUNNING...
โ”โ”โ” Pioneers Example 1 โ”โ”โ”
61849338c0b5c996ff42175e14a236d122b31f26e7640e4e8ec72ad46c9afee118
  โœ“ prop_buildShelleyPaymentAddress passed 1 test.
018ab42b1ad055d7bc98baef5401df56b4855120d1054c2f8b75006e0de60602d250e4db900068e2876b143f2252ec1eac9d37a73021479e4a33c24ceb825a39c1
  โœ“ prop_buildShelleyStakeAddress passed 1 test.
  โœ“ 2 succeeded.
โ”โ”โ” Pioneers Example 2 โ”โ”โ”
  โœ“ prop_createTransaction passed 1 test.
  โœ“ 1 succeeded.
โ”โ”โ” Pioneers Example 3 โ”โ”โ”
  โœ“ prop_createOperationalCertificate passed 1 test.
  โœ“ 1 succeeded.
โ”โ”โ” ITN key conversion โ”โ”โ”
  โœ“ prop_convertITNKeys passed 1 test.
  โœ“ golden_bech32Decode passed 1 test.
  โœ“ 2 succeeded.
Test suite cardano-cli-pioneers: PASS
Test suite logged to:
/home/erikd/IOHK/NewCodeBase/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cardano-cli-1.13.0/t/cardano-cli-pioneers/test/cardano-cli-1.13.0-cardano-cli-pioneers.log
1 of 1 test suites (1 of 1 test cases) passed.
Preprocessing test suite 'cardano-cli-test' for cardano-cli-1.13.0..
Building test suite 'cardano-cli-test' for cardano-cli-1.13.0..
Running 1 test suites...
Test suite cardano-cli-test: RUNNING...
== address-build ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048082
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048082
PASSED [ address-build ]

== address-info ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048102
Test currently disabled
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048102
PASSED [ address-info ]

== address-key-gen ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048109
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048109
PASSED [ address-key-gen ]

== address-key-hash ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048123
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048123
PASSED [ address-key-hash ]

== genesis-create ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048137
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048137
PASSED [ genesis-create ]

== genesis-initial-addr ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048241
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048241
PASSED [ genesis-initial-addr ]

== genesis-initial-txin ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048255
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048255
PASSED [ genesis-initial-txin ]

== genesis-key-gen-delegate ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048269
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048269
PASSED [ genesis-key-gen-delegate ]

== genesis-key-gen-genesis ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048286
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048286
PASSED [ genesis-key-gen-genesis ]

== genesis-key-gen-utxo ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048300
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048300
PASSED [ genesis-key-gen-utxo ]

== genesis-key-hash ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048314
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048314
PASSED [ genesis-key-hash ]

== node-issue-op-cert ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048328
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048328
PASSED [ node-issue-op-cert ]

== node-key-gen ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048343
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048343
PASSED [ node-key-gen ]

== node-key-gen-kes ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048358
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048358
PASSED [ node-key-gen-kes ]

== node-key-gen-vrf ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048372
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048372
PASSED [ node-key-gen-vrf ]

== shellcheck ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048386
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048386
PASSED [ shellcheck ]

== stake-address-build ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048421
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048421
PASSED [ stake-address-build ]

== stake-address-deregistration-certificate ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048434
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048434
PASSED [ stake-address-deregistration-certificate ]

== stake-address-key-gen ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048447
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048447
PASSED [ stake-address-key-gen ]

== stake-address-registration-certificate ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048461
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048461
PASSED [ stake-address-registration-certificate ]

== text-view-info ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048474
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048474
PASSED [ text-view-info ]

== transaction-build-raw ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048490
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048490
PASSED [ transaction-build-raw ]

== transaction-calculate-min-fee ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048504
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048504
PASSED [ transaction-calculate-min-fee ]

== transaction-sign ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048518
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048518
PASSED [ transaction-sign ]

== version ==
Running in /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048543
Cleaning up /home/erikd/IOHK/NewCodeBase/cardano-node/cardano-cli/tmp/3048543
PASSED [ version ]

25 tests passed, 0 failed.

Test suite cardano-cli-test: PASS
Building test suite 'cardano-config-test' for cardano-config-0.1.0.0..
Running 1 test suites...
Test suite cardano-config-test: RUNNING...
โ”โ”โ” Test.Cardano.Config.Json โ”โ”โ”
  โœ“ prop_roundtrip_NodeAddress_JSON passed 100 tests.
      has address 92% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ยท โœ“ 1%
      no address   8% โ–ˆโ–Œยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท โœ“ 1%
  โœ“ prop_roundtrip_NodeHostAddress_JSON passed 100 tests.
      has address 94% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Šยท โœ“ 1%
      no address   6% โ–ˆโ–ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท โœ“ 1%
  โœ“ prop_roundtrip_NodeSetup_JSON passed 100 tests.
  โœ“ prop_roundtrip_NetworkTopology_JSON passed 100 tests.
  โœ“ 4 succeeded.
โ”โ”โ” Test.Cardano.Config.Types โ”โ”โ”
  โœ“ prop_golden_ShelleyGenesis passed 1 test.
  โœ“ prop_roundtrip_Address_CBOR passed 100 tests.
  โœ“ prop_roundtrip_Address_JSON passed 100 tests.
  โœ“ prop_roundtrip_GenesisDelegationPair_JSON passed 100 tests.
  โœ“ prop_roundtrip_FundPair_JSON passed 100 tests.
  โœ“ prop_roundtrip_ShelleyGenesis_JSON passed 500 tests.
  โœ“ prop_roundtrip_VerKeyVRF_SimpleVRF_CBOR passed 50 tests.
  โœ“ prop_roundtrip_VKeyES_TPraosStandardCrypto_CBOR passed 20 tests.
  โœ“ 8 succeeded.
โ”โ”โ” Test.Cardano.Config.TextView โ”โ”โ”
  โœ“ prop_roundtrip_multiline_hex passed 100 tests.
  โœ“ prop_roundtrip_TextView passed 100 tests.
  โœ“ prop_roundtrip_shelley_SigningKey_view passed 100 tests.
  โœ“ 3 succeeded.
Test suite cardano-config-test: PASS

Closing this,. There are tests, both in this repo and in the repos this one depends on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peteremiljensen picture peteremiljensen  ยท  4Comments

aftershowrc picture aftershowrc  ยท  3Comments

2072 picture 2072  ยท  8Comments

deepfire picture deepfire  ยท  4Comments

deepfire picture deepfire  ยท  3Comments