-
Notifications
You must be signed in to change notification settings - Fork 631
[release/1.3.1] [CO-354] Split test-suites for NMNothing/NMJust #3559
[release/1.3.1] [CO-354] Split test-suites for NMNothing/NMJust #3559
Conversation
N.B. this PR contains commits which are part of PR #3556 and PR #3558. Thus, the "Files Changed" is inflated, and if someone reviews this before #3556 and #3558 are merged, it would be simplest to review only the commits:
EDIT: |
= round (calculateTxSizeLinear linearFeePolicy (estimateSize addrAttrSize 16 ins outs)) | ||
where | ||
addrAttrSize = 128 + (case rnm of NMMustBeNothing -> 0 | ||
NMMustBeJust -> 4) |
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.
@edsko @matt-noonan : would be great to get your feedback on this.
Since a NetworkMagic
seems to take up 4 bytes, I add 4 to the AddrAttributes
estimated byte size. I'm aware that there's now a better way to estimate things on develop
, but this seems like a simple fix to me, unless I'm missing something.
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.
I think it's fine, we have better checks on the 1.4 branch where this is anyway more important, so we can revisit this there.
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.
The hardcoded 4 bytes has been updated to 7 bytes, since an Int32
has 3 more bytes than a Word8
.
db3f23a
to
864bf74
Compare
cc87ef4
to
864bf74
Compare
864bf74
to
bbe8266
Compare
I've just updated this PR to run the testsuites multiple times, with different |
bbe8266
to
54a1394
Compare
|
||
-- We run the tests this number of times, with different `ProtocolMagics`, to get increased | ||
-- coverage. We should really do this inside of the `prop`, but it is difficult to do that | ||
-- without significant rewriting of the testsuite. |
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.
👍
NMNothing -> 0 | ||
-- Encoding size: | ||
-- Map key: 2 bytes (1 for header, 1 for Word8) | ||
-- Map val: 1-5 bytes (1 for header, 0-4 for Word32) |
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.
Is this an Int32
now? Stupid compiler doesn't know how to type check comments :)
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.
Ugh, fixed 😆
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.
Ah that one's my fault. oops.
This implements part 3.5 of the ProtocolMagic' master plan. Merged with: [CO-354] Incorporate Luke's fix for `generator` testsuite
This test was failing, apparently due to the increased sizes of `AddrAttributes` in the NMJust case. I added 4 bytes to the maximum byte limit, which is the amount by which `AddrAttributes` grows when the `NetworkMagic` value is added.
54a1394
to
63149f1
Compare
@@ -54,6 +55,12 @@ instance Arbitrary ProtocolMagicId where | |||
instance Arbitrary RequiresNetworkMagic where | |||
arbitrary = elements [NMMustBeNothing, NMMustBeJust] | |||
|
|||
genProtocolMagicUniformWithRNM :: RequiresNetworkMagic -> Gen ProtocolMagic |
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.
👍
@@ -102,7 +103,6 @@ import Pos.WorkMode (EmptyMempoolExt) | |||
import Test.Pos.Block.Logic.Emulation (Emulation (..), runEmulation, sudoLiftIO) | |||
import Test.Pos.Configuration (defaultTestBlockVersionData, defaultTestConf, | |||
defaultTestGenesisSpec) | |||
import Test.Pos.Crypto.Dummy (dummyProtocolMagic) |
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.
💯
specBody pm | ||
|
||
specBody :: ProtocolMagic -> Spec | ||
specBody pm = withProvidedMagicConfig pm $ withCompileInfo def $ |
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.
Replacing withStaticConfigurations
with withProvidedMagicConfig
feels a bit reminiscent of the issue we originally encountered in Test.Pos.Generator.Block.LrcSpec
in which withProvidedMagicConfig
makes use of withGenesisSpec
while withStaticConfigurations
doesn't. Since we're unsure as to whether the tests rely on this fact, we should probably stick with withStaticConfigurations
.
specBody pm | ||
|
||
specBody :: ProtocolMagic -> Spec | ||
specBody pm = withProvidedMagicConfig pm $ |
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.
Replacing
withStaticConfigurations
withwithProvidedMagicConfig
feels a bit reminiscent of the issue we originally encountered inTest.Pos.Generator.Block.LrcSpec
in whichwithProvidedMagicConfig
makes use ofwithGenesisSpec
whilewithStaticConfigurations
doesn't. Since we're unsure as to whether the tests rely on this fact, we should probably stick withwithStaticConfigurations
.
1b09905
to
547e635
Compare
To minimize risk of inadequate test coverage, due to too few `ProtocolMagic`s being used, we run the tests a specified number of times, with different `ProtocolMagic` values. We also use `choose` from Quickcheck to get uniformly distributed random values for the `ProtocolMagicId` field. `arbitrary`, by comparison, generates small Int32s, which is not desirable for testing because we want to exercise multiple sizes of CBOR encoding.
547e635
to
0b6404e
Compare
modifyMaxSuccess (`div` testMultiple) $ do | ||
pm <- runIO (generate (genProtocolMagicUniformWithRNM rnm)) | ||
describe ("(requiresNetworkMagic=" ++ show rnm ++ ")") $ | ||
specBody pm |
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.
Nice!
Description
"Split" the test-suites, for both NMMustBeNothing and NMMustBeJust cases. Also, introduce arbitrary ProtocolMagics (replace dummyProtocolMagic values). Since we hardcoded values in (3), 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 arbitraryProtocolMagic
s, 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-354
Type of change
Developer checklist
^ 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