Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace roundtripCBOR with trippingCbor #5069

Merged
merged 4 commits into from
Apr 15, 2023

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Apr 7, 2023

roundtripCBOR was used to reduce the amount of code for round trip tests, but it does not work well with GADTs.

We expect to use GADTs more in these tests in order to make them era independent.

Work-arounds for roundtripCBOR have been used to make it possible to encode tests for multiple eras. These include:

  • Writing an property test per era
  • Generating a property test per era with a test function that returns a [TestTree] instead of a Property

This PR introduces trippingCbor which captures the tripping part of the property test.

It turns out that writing out the property test directly rather than generating the property gives us the flexibility to use GADTs and thus be able to encode era independent property tests, which allows us to eliminate per era duplication and avoid generating test groups.

@newhoggy newhoggy changed the title Replace roundtrip cbor with tripping cbor Replace roundtripCBOR with trippingCBOR Apr 7, 2023
@newhoggy newhoggy force-pushed the newhoggy/replace-roundtrip_CBOR-with-trippingCBOR branch from 2357ebb to 0ef2e8c Compare April 7, 2023 04:05
@newhoggy newhoggy marked this pull request as ready for review April 7, 2023 04:06
@newhoggy newhoggy force-pushed the newhoggy/replace-roundtrip_CBOR-with-trippingCBOR branch from 0ef2e8c to e8b50c5 Compare April 7, 2023 05:41
@newhoggy newhoggy changed the title Replace roundtripCBOR with trippingCBOR Replace roundtripCBOR with trippingCbor Apr 7, 2023
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.

👍 Nice

@newhoggy newhoggy force-pushed the newhoggy/replace-roundtrip_CBOR-with-trippingCBOR branch 3 times, most recently from 6830f1d to 9384c16 Compare April 12, 2023 22:44
-> (TxInsCollateral era, [Fund])
-> TxFee era
-> TxMetadataInEra era
-> TxGenerator era
genTx protocolParameters (collateral, collFunds) fee metadata inFunds outputs
genTx _era protocolParameters (collateral, collFunds) fee metadata inFunds outputs
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask what the motivation for the change is? I don't find any in the scope of this PR (as in: it builds and behaves fine without that change)?
If it is some kind of future-proofing, why not use cardanoEra @era in the body of genTx without changing call sites?

Copy link
Contributor Author

@newhoggy newhoggy Apr 14, 2023

Choose a reason for hiding this comment

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

Please see this comment:

#5069 (comment)

By passing in the era as an argument, the caller can easily specify which era they want to run a property test for.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes of course, that makes total sense then.
Thank you @newhoggy

@newhoggy newhoggy added this pull request to the merge queue Apr 14, 2023
@newhoggy newhoggy removed this pull request from the merge queue due to a manual request Apr 14, 2023
@newhoggy newhoggy force-pushed the newhoggy/replace-roundtrip_CBOR-with-trippingCBOR branch from 9384c16 to 2be0d46 Compare April 14, 2023 23:16
@newhoggy newhoggy added this pull request to the merge queue Apr 15, 2023
Merged via the queue into master with commit a993ec6 Apr 15, 2023
@iohk-bors iohk-bors bot deleted the newhoggy/replace-roundtrip_CBOR-with-trippingCBOR branch April 15, 2023 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants