-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add cbor round trip tests for Block
for each era
#4869
base: master
Are you sure you want to change the base?
Conversation
RoundTrip
tests for blocks for each era tests for
Block` for each era
23d176c
to
af18f12
Compare
roundTripBlock :: | ||
forall era. | ||
( EraSegWits era | ||
, Arbitrary (Tx era) | ||
) => | ||
Spec | ||
roundTripBlock = | ||
prop (show (typeRep $ Proxy @(Block (BHeader StandardCrypto) era))) $ | ||
withMaxSuccess 3 $ | ||
roundTripAnnEraExpectation @era @(Block (BHeader StandardCrypto) era) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to add this funciton to the testlib, so it can be used in consensus as well. For this it needs to be parameterized by block header
roundTripBlock :: | |
forall era. | |
( EraSegWits era | |
, Arbitrary (Tx era) | |
) => | |
Spec | |
roundTripBlock = | |
prop (show (typeRep $ Proxy @(Block (BHeader StandardCrypto) era))) $ | |
withMaxSuccess 3 $ | |
roundTripAnnEraExpectation @era @(Block (BHeader StandardCrypto) era) | |
roundTripBlock :: | |
forall era bh. | |
( EraSegWits era | |
, Arbitrary (Tx era) | |
) => | |
Spec | |
roundTripBlock = | |
prop (show (typeRep $ Proxy @(Block bh era))) $ | |
withMaxSuccess 3 $ | |
roundTripAnnEraExpectation @era @(Block bh era) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! good point, thanks.
roundTripBlock @BabbageEra | ||
roundTripBlock @ConwayEra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do not make sense, because block header as defined in this package is never used with Babbage onwards
roundTripBlock @BabbageEra | |
roundTripBlock @ConwayEra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wondered about whether it brings any value at all like this, but I agree, no point testing unrealistic stuff.
I will try adding for TxSeq instead!
tests for
Block` for each eraBlock
for each era
Description
While looking into roundtrip tests, I discovered we don't have any for Block.
I have added such tests for each era to
cardano-protocol-tpraos
.Since
Block
is defined incore
, the tests would be better suited incore
, and then referenced and ran in each, but the problem is the reference toBHeader
which is defined incardano-protocol-tpraos
.Is there something else I can use instead of
BHeader
? I can see there isBHeaderView
, but it doesn't seem to be suitable for this kind of testing.Another note: the
cddlRoundTrip
specs don't pass forBlock
, because of the checks we make in the TxSeq DecCBOR instances - the data we're generating from cddl is not internally consistent to pass these checks.Checklist
CHANGELOG.md
files updated for packages with externally visible changesNew section is never added with the code changes. (See RELEASING.md)
.cabal
andCHANGELOG.md
files when necessary, according to theversioning process.
.cabal
files updated when necessaryIf you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
scripts/fourmolize.sh
)scripts/cabal-format.sh
)hie.yaml
updated (usescripts/gen-hie.sh
)