Skip to content

Commit

Permalink
Fix a bug in the QC shrinker for the p2p governor mock environment
Browse files Browse the repository at this point in the history
The shrink function for GovernorScripts (a type within the PeerGraph
within the GovernorMockEnvironment) was in some corner cases returning
"shrunk" values that were the same as the original. This violates the
shrink property and causes shrinking to loop.

This fix allow test cases exhibiting property violations involving the
p2p governor to be shrunk, where previously the shrinking would usually
loop.

I found this bug by adding some extra properties to check the shrinking
functions satisfy the shrink propery. That infrastructure is not
included in this patch, but will be added in a later patch.
  • Loading branch information
dcoutts authored and coot committed May 12, 2021
1 parent 2f2f2f9 commit 04c8874
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -205,8 +205,11 @@ instance Arbitrary GovernorScripts where
| gossipScript' <- shrink gossipScript
]
++
[ GovernorScripts gossipScript (fixConnectionScript connectionScript')
| connectionScript' <- shrink connectionScript
[ GovernorScripts gossipScript connectionScript'
| connectionScript' <- map fixConnectionScript (shrink connectionScript)
-- fixConnectionScript can result in re-creating the same script
-- which would cause shrinking to loop. Filter out such cases.
, connectionScript' /= connectionScript
]

-- | We ensure that eventually the connection script will allow to connect to
Expand Down

0 comments on commit 04c8874

Please sign in to comment.