Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CO-410] Split test-suites for NetworkMainOrStage/NetworkTestnet #3756

Merged
merged 4 commits into from
Oct 24, 2018

Conversation

intricate
Copy link
Contributor

@intricate intricate commented Oct 15, 2018

Description

"Split" the test-suites, for both RequiresNoMagic and RequiresMagic cases. Also, introduce arbitrary ProtocolMagics (replace dummyProtocolMagic values). Since we hardcoded values in #3733, both splits should pass.

Motivation: in order to follow best practices of modifying tests & source code in separate PRs, today I factored out the testsuite modifications into a separate PR. We are PR'ing this before the full implementation of NetworkMagic is PR'ed, because we want to demonstrate that the tests can be split & parameterized by arbitrary ProtocolMagics, without modifying source code, and still pass. Then, when we modify the source and pass the tests, we will have more confidence in a correct implementation.

Linked issue

https://iohk.myjetbrains.com/youtrack/issue/CO-410

Type of change

  • [~] 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • [~] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • [~] 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • [~] ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • [~] CHANGELOG entry has been added and is linked to the correct PR on GitHub.
    ^ there is no 1.3.1 section in the CHANGELOG, and this is dev work on a release branch, so I'm skipping this.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

@intricate intricate force-pushed the i+j/develop/CO-410/split-test-suites branch 8 times, most recently from 59acf89 to 9c2a9f9 Compare October 16, 2018 23:32
@intricate intricate changed the title [DO NOT MERGE] [WIP] [CO-410] Split test-suites for NetworkMainOrStage/NetworkTestnet [CO-410] Split test-suites for NetworkMainOrStage/NetworkTestnet Oct 17, 2018
@intricate intricate force-pushed the i+j/develop/CO-410/split-test-suites branch 10 times, most recently from fc4b43e to b7cc800 Compare October 23, 2018 03:54
@Jimbo4350 Jimbo4350 force-pushed the i+j/develop/CO-410/split-test-suites branch from b7cc800 to 7a213ab Compare October 23, 2018 12:49
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just a few minor fixes/suggestions.

specBody pm

specBody :: ProtocolMagic -> Spec
specBody _pm = describe "Ssc.VssCertData" $ do -- withProvidedMagicConfig pm $ \_ _ _ -> describe "Ssc.VssCertData" $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some commented out code here.

prop "creates a Set of Addresses by given txs"
addressSetByTxsProp
prop "creates a Set of Addresses by given txs" $
\nm -> addressSetByTxsProp nm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this lambda can be removed.

specBody pm

specBody :: ProtocolMagic -> Spec
specBody pm = withProvidedMagicConfig pm $ \_ _ _ -> describe "computeSharesDistr" $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think withProvidedMagicConfig can be removed here as it doesn't look like any configuration or protocol magic values are being used in this Spec.

fakeAddressHasMaxSizeTest changeAddressGenerator
prop "genUniqueAddress" $
fakeAddressHasMaxSizeTest commonAddressGenerator
-- TODO @intricate: Not sure how to make the constraints play nice here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment left here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this, thanks.

Copy link
Contributor

@mhuesch mhuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments. I'll discuss with Luke whether these are showstoppers or can be deferred to a later "cleanup PR".

genBHLWithMagic
:: ProtocolMagic
-> Gen BlockHeaderList
genBHLWithMagic pm = do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name could be improved - perhaps something like genStubbedBHLW? Since it stubs out some of the parameters of genBHLW?

This is not a big priority, and could be addressed later.

chain/test/Test/Pos/Chain/Block/BlockSpec.hs Show resolved Hide resolved
chain/test/Test/Pos/Chain/Block/BlockSpec.hs Show resolved Hide resolved
chain/test/Test/Pos/Chain/Block/BlockSpec.hs Show resolved Hide resolved
wallet-new/test/unit/Test/Spec/Addresses.hs Show resolved Hide resolved
wallet-new/src/Cardano/Wallet/Kernel.hs Show resolved Hide resolved
wallet-new/test/unit/Test/Spec/Fixture.hs Show resolved Hide resolved
@intricate intricate force-pushed the i+j/develop/CO-410/split-test-suites branch 2 times, most recently from a84a217 to 466215e Compare October 23, 2018 21:42
@intricate intricate dismissed Jimbo4350’s stale review October 23, 2018 21:43

All concerns mentioned here have been addressed.

@intricate intricate force-pushed the i+j/develop/CO-410/split-test-suites branch 2 times, most recently from da4d4f2 to 94bbdaf Compare October 24, 2018 00:09
Copy link
Contributor

@mhuesch mhuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Member

@erikd erikd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@intricate intricate merged commit 70f2b9c into develop Oct 24, 2018
@intricate intricate deleted the i+j/develop/CO-410/split-test-suites branch October 24, 2018 01:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants