Conversation
When properties are defined as functions, it is easier to paste shrinked counterexamples.
df9dbc4 to
46c736f
Compare
bolt12
left a comment
There was a problem hiding this comment.
LGTMjust some small comments
ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/testlib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs
Outdated
Show resolved
Hide resolved
| <- listOf1 (listOf1 (sublistOf (makeRelayAccessPoint <$> ledgerPeersRelays) | ||
| `suchThat` (not . null))) |
There was a problem hiding this comment.
using suchThat might make the generator slower. Perhaps we can generate directly from NonEmpty ?
There was a problem hiding this comment.
There was a problem hiding this comment.
we need sublistOf1 which is not in QuickCheck
There was a problem hiding this comment.
Added 😁, for now it lives in this file; once we'll need it elsewhere we can move it to ouroboros-network-testing.
There was a problem hiding this comment.
Right, that's because you can't have a sublistOf1 of the empty list. I took a look at your implementation. I found this one to be simpler
sublistOf1 :: NonEmpty a -> Gen [a]
sublistOf1 (NonEmpty xs) = do
(e:listWithoutE) <- pick xs
subList <- sublistOf listWithoutE
pure (e:subList)
where
pick :: NonEmpty a -> Gen (a, [a])
pick (NonEmpty as) = do
i <- choose (0, length as - 1)
case splitAt i as of
(l, (a:as')) -> pure (a, l ++ as')
(l, []) -> pick lI wrote it here without any LSP help, might need some help compiling 😄
There was a problem hiding this comment.
My implementation preserves the order of elements.
There was a problem hiding this comment.
Ah right we have to preserve that, it shouldn't be hard to tweak mine to fix it without requiring the impartiality from yours, no?
ouroboros-network/testlib/Test/Ouroboros/Network/LedgerPeers.hs
Outdated
Show resolved
Hide resolved
The `naLedgerPeers` requires a script of ledger peers. We used to generate just a single ledger peer, instead generate a list of them. The ledger peer generation had a devision by zero error, which is fixed in this commit as well.
46c736f to
2e041df
Compare
Description
Fixes: #5091
Checklist
Quality
Maintenance
ouroboros-networkproject.