Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
[#676] cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
redxaxder committed Feb 3, 2020
1 parent ea860dd commit 18c3a83
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions cardano-ledger/cardano-ledger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library
hs-source-dirs: src
exposed-modules:
Cardano.Chain.Block
Cardano.Chain.Byron.Auxiliary
Cardano.Chain.Byron.API
Cardano.Chain.Common
Cardano.Chain.Constants
Cardano.Chain.Delegation
Expand Down Expand Up @@ -179,7 +179,7 @@ test-suite cardano-ledger-test
Test.Cardano.Chain.Block.Model.Examples
Test.Cardano.Chain.Block.Validation
Test.Cardano.Chain.Block.ValidationMode
Test.Cardano.Chain.Byron.Auxiliary
Test.Cardano.Chain.Byron.API

Test.Cardano.Chain.Buildable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

-- | Auxiliary definitions to make working with the Byron ledger easier
module Cardano.Chain.Byron.Auxiliary (
module Cardano.Chain.Byron.API (
-- * Extract info from genesis config
allowedDelegators
, boundaryBlockSlot
Expand Down Expand Up @@ -213,8 +213,7 @@ applyChainTick :: Gen.Config
-> CC.ChainValidationState
-> CC.ChainValidationState
applyChainTick cfg slotNo cvs = cvs {
CC.cvsLastSlot = slotNo
, CC.cvsUpdateState = CC.epochTransition
CC.cvsUpdateState = CC.epochTransition
(mkEpochEnvironment cfg cvs)
(CC.cvsUpdateState cvs)
slotNo
Expand Down Expand Up @@ -580,7 +579,7 @@ fromCBORABlockOrBoundaryHdr epochSlots = do
fromCBOR @Word >>= \case
0 -> ABOBBoundaryHdr <$> CC.fromCBORABoundaryHeader
1 -> ABOBBlockHdr <$> CC.fromCBORAHeader epochSlots
t -> panic $ "Unknown tag in encoded HeaderOrBoundary" <> show t
t -> fail $ "Unknown tag in encoded HeaderOrBoundary" <> show t

-- | The analogue of 'Data.Either.either'
aBlockOrBoundaryHdr :: (CC.AHeader a -> b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ tickDelegation currentEpoch currentSlot =
let ss' = pruneScheduledDelegations currentEpoch currentSlot (schedulingState s)
in s{ schedulingState = ss'}

-- Activate certificates up to this slot
-- | Activate certificates up to this slot
activateDelegations :: SlotNumber -> State -> State
activateDelegations currentSlot s@(State ss as) =
let Scheduling.State delegations _keyEpochs = ss
as' = foldl Activation.activateDelegation as
(Seq.filter ((<= currentSlot) . Scheduling.sdSlot) delegations)
in s { activationState = as' }

-- Remove stale values from 'Scheduling.State'
-- | Remove stale values from 'Scheduling.State'
pruneScheduledDelegations
:: EpochNumber
-> SlotNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# Language RankNTypes #-}


module Test.Cardano.Chain.Byron.Auxiliary
module Test.Cardano.Chain.Byron.API
( genApplyMempoolPayloadErr
, ts_roundTripApplyMempoolPayloadErrCompat
, ts_scheduledDelegations
Expand All @@ -12,10 +12,9 @@ module Test.Cardano.Chain.Byron.Auxiliary
where

import Cardano.Prelude
-- import Test.Cardano.Prelude

import Cardano.Crypto (ProtocolMagicId)
import Cardano.Chain.Byron.Auxiliary
import Cardano.Chain.Byron.API
( ApplyMempoolPayloadErr (..)
, getDelegationMap
, applyChainTick
Expand Down Expand Up @@ -50,7 +49,7 @@ import Cardano.Chain.Genesis (configSlotSecurityParam)
import qualified Cardano.Chain.Genesis as Genesis

tests :: TSGroup
tests scenario = Group "Test.Cardano.Chain.Byron.Auxiliary"
tests scenario = Group "Test.Cardano.Chain.Byron.API"
[ ( "ts_chainTick", ts_chainTick scenario)
, ( "ts_roundTripApplyMempoolPayloadErrCompat", ts_roundTripApplyMempoolPayloadErrCompat scenario)
, ( "ts_scheduledDelegations", ts_scheduledDelegations scenario)
Expand Down Expand Up @@ -87,7 +86,6 @@ setupChainValidationState sampleTrace =

-- | getDelegationMap . applyChainTick slot == previewDelegationMap slot
ts_scheduledDelegations :: TSProperty
--FIXME: This is a failing test.
ts_scheduledDelegations = withTestsTS 100 . property $ do
let traceLength = 10 :: Word64
sampleTrace <- forAll $ STS.trace @CHAIN () traceLength
Expand Down
2 changes: 1 addition & 1 deletion cardano-ledger/test/cardano-ledger-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ library
Test.Cardano.Chain.Block.Validation
Test.Cardano.Chain.Block.ValidationMode

Test.Cardano.Chain.Byron.Auxiliary
Test.Cardano.Chain.Byron.API

Test.Cardano.Chain.Buildable

Expand Down
4 changes: 2 additions & 2 deletions cardano-ledger/test/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import qualified Test.Cardano.Chain.UTxO.ValidationMode
import qualified Test.Cardano.Chain.Update.CBOR
import qualified Test.Cardano.Chain.Update.Properties
import qualified Test.Cardano.Chain.Elaboration.Delegation
import qualified Test.Cardano.Chain.Byron.Auxiliary
import qualified Test.Cardano.Chain.Byron.API

main :: IO ()
main =
Expand Down Expand Up @@ -66,5 +66,5 @@ main =
, Test.Cardano.Chain.UTxO.ValidationMode.tests
, Test.Cardano.Chain.Update.CBOR.tests
, Test.Cardano.Chain.Update.Properties.tests
, Test.Cardano.Chain.Byron.Auxiliary.tests
, Test.Cardano.Chain.Byron.API.tests
]
1 change: 1 addition & 0 deletions nix/.stack.nix/cardano-ledger.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 18c3a83

Please sign in to comment.