Skip to content

Commit

Permalink
Reduce memory and time efficiency of test
Browse files Browse the repository at this point in the history
  • Loading branch information
bolt12 committed Oct 31, 2023
1 parent e3536c8 commit 12b7a3f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ instance Arbitrary UseBootstrapPeers where
, (1, UseBootstrapPeers <$> arbitrary)
]

shrink DontUseBootstrapPeers = []
shrink (UseBootstrapPeers _) = [DontUseBootstrapPeers]

instance Arbitrary PeerTrustable where
arbitrary = elements [ IsNotTrustable, IsTrustable ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import Ouroboros.Network.PeerSelection.LedgerPeers.Type
(IsBigLedgerPeer, LedgerStateJudgement (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PeerSelection.PublicRootPeers
(PublicRootPeers)
(PublicRootPeers (..))
import qualified Ouroboros.Network.PeerSelection.PublicRootPeers as PublicRootPeers
import Ouroboros.Network.PeerSelection.Types (PeerStatus (..))
import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount,
Expand Down Expand Up @@ -772,25 +772,38 @@ instance Arbitrary GovernorMockEnvironment where
ledgerStateJudgement = fmap (first getArbitraryLedgerStateJudgement)
ledgerStateJudgement'
}
| (localRootPeers', publicRootPeers', targets',
| (targets',
pickKnownPeersForPeerShare',
pickColdPeersToPromote',
pickWarmPeersToPromote',
pickHotPeersToDemote',
pickWarmPeersToDemote',
pickColdPeersToForget',
ledgerStateJudgement')
<- shrink (localRootPeers, publicRootPeers, targets,
ledgerStateJudgement',
useBootstrapPeers'
)
<- shrink (targets,
pickKnownPeersForPeerShare,
pickColdPeersToPromote,
pickWarmPeersToPromote,
pickHotPeersToDemote,
pickWarmPeersToDemote,
pickColdPeersToForget,
fmap (first ArbitraryLedgerStateJudgement) ledgerStateJudgement
fmap (first ArbitraryLedgerStateJudgement) ledgerStateJudgement,
useBootstrapPeers
),
useBootstrapPeers' <- shrink useBootstrapPeers
localRootPeers' <- shrinkLocalRootPeers localRootPeers,
publicRootPeers' <- shrinkPublicRootPeers publicRootPeers
]
where
shrinkLocalRootPeers (LocalRootPeers m g) =
[ LocalRootPeers m' g'
| (m', g') <- shrink (m, g)
]
shrinkPublicRootPeers (PublicRootPeers pp bsp lp blp) =
[ PublicRootPeers pp' bsp' lp' blp'
| (pp', bsp', lp', blp') <- shrink (pp, bsp, lp, blp)
]


--
Expand Down

0 comments on commit 12b7a3f

Please sign in to comment.