{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

module Test.Cardano.Ledger.Api.State.Imp.QuerySpec where

import Cardano.Ledger.Api.State.Query (
  CommitteeMemberState (..),
  CommitteeMembersState (..),
  HotCredAuthStatus (..),
  MemberStatus (..),
  NextEpochChange (..),
  queryCommitteeMembersState,
  queryDRepState,
 )
import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Coin
import Cardano.Ledger.Conway.Governance (
  GovAction (..),
  GovPurposeId (..),
  Voter (StakePoolVoter),
 )
import Cardano.Ledger.Conway.PParams (ppDRepActivityL)
import Cardano.Ledger.Credential (Credential (KeyHashObj))
import Cardano.Ledger.DRep
import Cardano.Ledger.Keys (KeyRole (..))
import qualified Cardano.Ledger.Shelley.HardForks as HF
import Cardano.Ledger.Shelley.LedgerState
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Lens.Micro
import Lens.Micro.Mtl
import Test.Cardano.Ledger.Conway.ImpTest
import Test.Cardano.Ledger.Core.Rational ((%!))
import Test.Cardano.Ledger.Imp.Common

spec ::
  forall era.
  ConwayEraImp era =>
  SpecWith (ImpInit (LedgerSpec era))
spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era))
spec = do
  forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"DRep" forall a b. (a -> b) -> a -> b
$ do
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"Expiries are reported correctly" forall a b. (a -> b) -> a -> b
$ do
      let drepStateFromQuery ::
            (HasCallStack, Monad m) =>
            Credential 'DRepRole ->
            NewEpochState era ->
            m DRepState
          drepStateFromQuery :: forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes =
            case forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Credential 'DRepRole
drep (forall era.
NewEpochState era
-> Set (Credential 'DRepRole)
-> Map (Credential 'DRepRole) DRepState
queryDRepState NewEpochState era
nes forall a. Monoid a => a
mempty) of
              Maybe DRepState
Nothing -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"Expected for DRep " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Credential 'DRepRole
drep forall a. [a] -> [a] -> [a]
++ String
" to be present in the query result"
              Just DRepState
state -> forall (f :: * -> *) a. Applicative f => a -> f a
pure DRepState
state
      forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"simple expiry" forall a b. (a -> b) -> a -> b
$ do
        EpochNo
curEpochNo <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL
        let drepActivity :: Word32
drepActivity = Word32
3
        forall era.
ShelleyEraImp era =>
(PParams era -> PParams era) -> ImpTestM era ()
modifyPParams forall a b. (a -> b) -> a -> b
$ forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
ppDRepActivityL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000
        NewEpochState era
nes <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes
        DRepState
drepState forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo (Word32 -> EpochInterval
EpochInterval Word32
drepActivity)
        let n :: Natural
n = Natural
4
        forall era.
ShelleyEraImp era =>
Natural -> ImpTestM era () -> ImpTestM era ()
passNEpochsChecking Natural
n forall a b. (a -> b) -> a -> b
$
          forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$ EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$
          EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$
            Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)

      forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"dRep registered when there are dormant epochs" forall a b. (a -> b) -> a -> b
$ do
        let drepActivity :: Word32
drepActivity = Word32
3
        forall era.
ShelleyEraImp era =>
(PParams era -> PParams era) -> ImpTestM era ()
modifyPParams forall a b. (a -> b) -> a -> b
$ forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
ppDRepActivityL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        let n :: Natural
n = Natural
2
        forall era. ShelleyEraImp era => Natural -> ImpTestM era ()
passNEpochs Natural
n
        forall era. HasCallStack => EpochNo -> ImpTestM era ()
expectNumDormantEpochs forall a b. (a -> b) -> a -> b
$ Word64 -> EpochNo
EpochNo (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000

        let expectedExpiry :: ImpM (LedgerSpec era) EpochNo
expectedExpiry = do
              EpochNo
epochNo <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL
              let tot :: EpochNo
tot = EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
epochNo (Word32 -> EpochInterval
EpochInterval Word32
drepActivity)
              ProtVer
pv <- forall era. EraGov era => ImpTestM era ProtVer
getProtVer
              forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
                if ProtVer -> Bool
HF.bootstrapPhase ProtVer
pv
                  then (Word64 -> Word64 -> Word64) -> EpochNo -> EpochNo -> EpochNo
binOpEpochNo forall a. Num a => a -> a -> a
(+) EpochNo
tot (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
                  else EpochNo
tot

        ImpM (LedgerSpec era) EpochNo
expectedExpiry forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep

        NewEpochState era
nes <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        forall era.
ConwayEraImp era =>
StrictMaybe GovActionId -> ImpTestM era (GovAction era)
mkMinFeeUpdateGovAction forall a. StrictMaybe a
SNothing forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era ()
submitGovAction_

        ImpM (LedgerSpec era) EpochNo
expectedExpiry forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep
        DRepState
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes
        ImpM (LedgerSpec era) EpochNo
expectedExpiry forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
shouldBe (DRepState
drepState forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL)

      forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"proposals are made and numDormantEpochs are added" forall a b. (a -> b) -> a -> b
$ do
        EpochNo
curEpochNo <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL
        let drepActivity :: Word32
drepActivity = Word32
3
        forall era.
ShelleyEraImp era =>
(PParams era -> PParams era) -> ImpTestM era ()
modifyPParams forall a b. (a -> b) -> a -> b
$ forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
ppDRepActivityL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000
        NewEpochState era
nes <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes
        DRepState
drepState forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo (Word32 -> EpochInterval
EpochInterval Word32
drepActivity)
        let n :: Natural
n = Natural
2
            actualExpiry :: EpochNo
actualExpiry = EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        forall era.
ShelleyEraImp era =>
Natural -> ImpTestM era () -> ImpTestM era ()
passNEpochsChecking Natural
n forall a b. (a -> b) -> a -> b
$
          forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep EpochNo
actualExpiry
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$ EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        forall era.
ConwayEraImp era =>
StrictMaybe GovActionId -> ImpTestM era (GovAction era)
mkMinFeeUpdateGovAction forall a. StrictMaybe a
SNothing forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era ()
submitGovAction_
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep EpochNo
actualExpiry
        NewEpochState era
nes1 <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState1 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes1
        DRepState
drepState1 forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo
actualExpiry
        forall era.
ShelleyEraImp era =>
Natural -> ImpTestM era () -> ImpTestM era ()
passNEpochsChecking (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
drepActivity) forall a b. (a -> b) -> a -> b
$
          forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
True
      forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"update certificates are submitted and proposals are made" forall a b. (a -> b) -> a -> b
$ do
        EpochNo
curEpochNo <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL
        let drepActivity :: Word32
drepActivity = Word32
3
        forall era.
ShelleyEraImp era =>
(PParams era -> PParams era) -> ImpTestM era ()
modifyPParams forall a b. (a -> b) -> a -> b
$ forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
ppDRepActivityL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000
        NewEpochState era
nes <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes
        DRepState
drepState forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo (Word32 -> EpochInterval
EpochInterval Word32
drepActivity)
        let n :: Natural
n = Natural
3
        forall era.
ShelleyEraImp era =>
Natural -> ImpTestM era () -> ImpTestM era ()
passNEpochsChecking Natural
n forall a b. (a -> b) -> a -> b
$
          forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
        forall era. HasCallStack => EpochNo -> ImpTestM era ()
expectNumDormantEpochs forall a b. (a -> b) -> a -> b
$ Word64 -> EpochNo
EpochNo (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$ EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$
          EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$
            Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'DRepRole -> ImpTestM era ()
updateDRep Credential 'DRepRole
drep
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$ EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$
          EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$
            Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        forall era. HasCallStack => EpochNo -> ImpTestM era ()
expectNumDormantEpochs forall a b. (a -> b) -> a -> b
$ Word64 -> EpochNo
EpochNo (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n)
        NewEpochState era
nes1 <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState1 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes1
        DRepState
drepState1
          forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL
            forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo -> EpochInterval -> EpochNo
addEpochInterval
              EpochNo
curEpochNo
              (Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n))
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole
drep forall a b. (a -> b) -> a -> b
$ EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval Word32
drepActivity
        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        forall era. HasCallStack => EpochNo -> ImpTestM era ()
expectNumDormantEpochs forall a b. (a -> b) -> a -> b
$ Word64 -> EpochNo
EpochNo (forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n forall a. Num a => a -> a -> a
+ Word64
1)
        forall era.
ConwayEraImp era =>
StrictMaybe GovActionId -> ImpTestM era (GovAction era)
mkMinFeeUpdateGovAction forall a. StrictMaybe a
SNothing forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era ()
submitGovAction_
        forall era. HasCallStack => EpochNo -> ImpTestM era ()
expectNumDormantEpochs forall a b. (a -> b) -> a -> b
$ Word64 -> EpochNo
EpochNo Word64
0
        NewEpochState era
nes2 <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
        DRepState
drepState2 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole -> NewEpochState era -> m DRepState
drepStateFromQuery Credential 'DRepRole
drep NewEpochState era
nes2
        let drepExpiry2 :: EpochNo
drepExpiry2 = EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo forall a b. (a -> b) -> a -> b
$ Word32 -> EpochInterval
EpochInterval (Word32
drepActivity forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
n forall a. Num a => a -> a -> a
+ Word32
1)
        DRepState
drepState2 forall s a. s -> Getting a s a -> a
^. Lens' DRepState EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo
drepExpiry2
        forall era.
HasCallStack =>
Credential 'DRepRole -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole
drep EpochNo
drepExpiry2
        forall era.
ShelleyEraImp era =>
Natural -> ImpTestM era () -> ImpTestM era ()
passNEpochsChecking (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
drepActivity) forall a b. (a -> b) -> a -> b
$ do
          forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        forall era.
HasCallStack =>
Credential 'DRepRole -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
True
  forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"Committee members hot key pre-authorization" forall a b. (a -> b) -> a -> b
$ do
    forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"authorized members not elected get removed in the next epoch" forall a b. (a -> b) -> a -> b
$ do
      forall era. EraGov era => ImpTestM era () -> ImpTestM era ()
whenPostBootstrap forall a b. (a -> b) -> a -> b
$ do
        Credential 'ColdCommitteeRole
c1 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
        forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era ()
submitGovAction_ forall a b. (a -> b) -> a -> b
$
          forall era.
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> UnitInterval
-> GovAction era
UpdateCommittee forall a. StrictMaybe a
SNothing forall a. Monoid a => a
mempty (forall k a. k -> a -> Map k a
Map.singleton Credential 'ColdCommitteeRole
c1 (Word64 -> EpochNo
EpochNo Word64
4321)) (Integer
1 forall r. (IsRatio r, HasCallStack) => Integer -> Integer -> r
%! Integer
1)
        Credential 'HotCommitteeRole
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c1
        HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
          [(Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)]
        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall k a. Map k a
Map.empty

    forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"members should remain authorized if authorized during the epoch after their election" forall a b. (a -> b) -> a -> b
$
      forall era. EraGov era => ImpTestM era () -> ImpTestM era ()
whenPostBootstrap forall a b. (a -> b) -> a -> b
$ do
        (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000
        (KeyHash 'StakePool
spoC, Credential 'Payment
_, Credential 'Staking
_) <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Coin
-> ImpTestM
     era (KeyHash 'StakePool, Credential 'Payment, Credential 'Staking)
setupPoolWithStake forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin Integer
42_000_000

        Credential 'ColdCommitteeRole
c1 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
        EpochNo
c1Expiry <- forall a b c. (a -> b -> c) -> b -> a -> c
flip EpochNo -> EpochInterval -> EpochNo
addEpochInterval (Word32 -> EpochInterval
EpochInterval Word32
10) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL

        Set (Credential 'ColdCommitteeRole)
initialCommitteeMembers <- forall era.
ConwayEraImp era =>
ImpTestM era (Set (Credential 'ColdCommitteeRole))
getCommitteeMembers
        GovPurposeId GovActionId
gid <-
          forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
            forall a. StrictMaybe a
SNothing
            Credential 'DRepRole
drep
            Set (Credential 'ColdCommitteeRole)
initialCommitteeMembers
            [(Credential 'ColdCommitteeRole
c1, EpochNo
c1Expiry)]
        forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter -> GovActionId -> ImpTestM era ()
submitYesVote_ (KeyHash 'StakePool -> Voter
StakePoolVoter KeyHash 'StakePool
spoC) GovActionId
gid

        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        Credential 'HotCommitteeRole
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c1
        HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
          [(Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)]
        forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
        HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
          [(Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)]

  forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"Committee queries" forall a b. (a -> b) -> a -> b
$ forall era. EraGov era => ImpTestM era () -> ImpTestM era ()
whenPostBootstrap forall a b. (a -> b) -> a -> b
$ do
    (Credential 'DRepRole
drep, Credential 'Staking
_, KeyPair 'Payment
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
     era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment)
setupSingleDRep Integer
1_000_000
    (KeyHash 'StakePool
spoC, Credential 'Payment
_, Credential 'Staking
_) <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Coin
-> ImpTestM
     era (KeyHash 'StakePool, Credential 'Payment, Credential 'Staking)
setupPoolWithStake forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin Integer
42_000_000
    EpochNo
curEpochNo <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall era. Lens' (NewEpochState era) EpochNo
nesELL
    let offsetEpochInterval :: Word32 -> EpochNo
offsetEpochInterval Word32
n = EpochNo -> EpochInterval -> EpochNo
addEpochInterval EpochNo
curEpochNo (Word32 -> EpochInterval
EpochInterval Word32
n)
    let cExpiry :: Word32
-> ImpM (LedgerSpec era) (Credential 'ColdCommitteeRole, EpochNo)
cExpiry Word32
n =
          (,)
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32 -> EpochNo
offsetEpochInterval Word32
n)
    (Credential 'ColdCommitteeRole
c1, EpochNo
c1Expiry) <- Word32
-> ImpM (LedgerSpec era) (Credential 'ColdCommitteeRole, EpochNo)
cExpiry Word32
12
    (Credential 'ColdCommitteeRole
c2, EpochNo
c2Expiry) <- Word32
-> ImpM (LedgerSpec era) (Credential 'ColdCommitteeRole, EpochNo)
cExpiry Word32
2
    (Credential 'ColdCommitteeRole
c3, EpochNo
c3Expiry) <- Word32
-> ImpM (LedgerSpec era) (Credential 'ColdCommitteeRole, EpochNo)
cExpiry Word32
7
    (Credential 'ColdCommitteeRole
c4, EpochNo
c4Expiry) <- Word32
-> ImpM (LedgerSpec era) (Credential 'ColdCommitteeRole, EpochNo)
cExpiry Word32
5
    Credential 'ColdCommitteeRole
c5 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
    Credential 'ColdCommitteeRole
c6 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
    Credential 'ColdCommitteeRole
c7 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
    Credential 'ColdCommitteeRole
c8 <- forall (kr :: KeyRole). KeyHash kr -> Credential kr
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r)
freshKeyHash
    let newMembers :: Map (Credential 'ColdCommitteeRole) EpochNo
newMembers =
          [ (Credential 'ColdCommitteeRole
c1, EpochNo
c1Expiry)
          , (Credential 'ColdCommitteeRole
c2, EpochNo
c2Expiry)
          , (Credential 'ColdCommitteeRole
c3, EpochNo
c3Expiry)
          , (Credential 'ColdCommitteeRole
c4, EpochNo
c4Expiry)
          ]
    Set (Credential 'ColdCommitteeRole)
initialMembers <- forall era.
ConwayEraImp era =>
ImpTestM era (Set (Credential 'ColdCommitteeRole))
getCommitteeMembers

    ga1 :: GovPurposeId 'CommitteePurpose era
ga1@(GovPurposeId GovActionId
gaid1) <-
      forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
        forall a. StrictMaybe a
SNothing
        Credential 'DRepRole
drep
        Set (Credential 'ColdCommitteeRole)
initialMembers
        Map (Credential 'ColdCommitteeRole) EpochNo
newMembers
    forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter -> GovActionId -> ImpTestM era ()
submitYesVote_ (KeyHash 'StakePool -> Voter
StakePoolVoter KeyHash 'StakePool
spoC) GovActionId
gaid1

    forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole) -> ImpTestM era ()
expectMembers Set (Credential 'ColdCommitteeRole)
initialMembers
    forall era. ShelleyEraImp era => Natural -> ImpTestM era ()
passNEpochs Natural
2 -- epoch 2
    forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole) -> ImpTestM era ()
expectMembers forall a b. (a -> b) -> a -> b
$ forall k a. Map k a -> Set k
Map.keysSet Map (Credential 'ColdCommitteeRole) EpochNo
newMembers
    -- members for which the expiration epoch is the current epoch are `ToBeExpired`
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
      ]
    -- hot cred status of members with registered hot keys becomes `MemberAuthorized`
    Credential 'HotCommitteeRole
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c1
    Credential 'HotCommitteeRole
hk2 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c2
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
      ]
    HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult
      [Credential 'ColdCommitteeRole
c2, Credential 'ColdCommitteeRole
c3, Credential 'ColdCommitteeRole
c5]
      forall a. Monoid a => a
mempty
      [MemberStatus
Active, MemberStatus
Unrecognized]
      [ (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
      ]

    Anchor
c3Anchor <- forall a (m :: * -> *). (Arbitrary a, MonadGen m) => m a
arbitrary
    Maybe (Credential 'HotCommitteeRole)
_ <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> StrictMaybe Anchor
-> ImpTestM era (Maybe (Credential 'HotCommitteeRole))
resignCommitteeColdKey Credential 'ColdCommitteeRole
c3 (forall a. a -> StrictMaybe a
SJust Anchor
c3Anchor)
    GovActionId
_ <-
      forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era GovActionId
submitGovAction forall a b. (a -> b) -> a -> b
$
        forall era.
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> UnitInterval
-> GovAction era
UpdateCommittee
          (forall a. a -> StrictMaybe a
SJust GovPurposeId 'CommitteePurpose era
ga1)
          forall a. Monoid a => a
mempty
          (forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Credential 'ColdCommitteeRole
c5, Word32 -> EpochNo
offsetEpochInterval Word32
10), (Credential 'ColdCommitteeRole
c8, Word32 -> EpochNo
offsetEpochInterval Word32
10)])
          (Integer
1 forall r. (IsRatio r, HasCallStack) => Integer -> Integer -> r
%! Integer
1)
    Credential 'HotCommitteeRole
hk5 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c5
    forall era. (HasCallStack, ShelleyEraImp era) => ImpTestM era ()
passTick
    -- hot cred status of resigned member becomes `Resigned`
    -- registering a hot key for a credential that's not part of the committee will yield `Unrecognized` member status
    -- and expected change of `ToBeRemoved`
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c5, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk5) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
      ]
    HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult
      [Credential 'ColdCommitteeRole
c2, Credential 'ColdCommitteeRole
c3, Credential 'ColdCommitteeRole
c5]
      [Credential 'HotCommitteeRole
hk5]
      [MemberStatus
Unrecognized]
      ( forall k a. k -> a -> Map k a
Map.singleton
          Credential 'ColdCommitteeRole
c5
          (HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk5) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
      )

    forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch -- epoch 3
    -- the `Unrecognized` member gets removed from the query result
    -- the member which in the previous epoch was expected `ToBeEpired`, has now MemberStatus `Expired` and `NoChangeExpected`
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
      ]

    -- elect new committee to be: c1 (term extended ), c3 (no changes), c4 (term shortened, expiring next epoch), c6, c7 (new)
    let c1NewExpiry :: EpochNo
c1NewExpiry = Word32 -> EpochNo
offsetEpochInterval Word32
13
        c4NewExpiry :: EpochNo
c4NewExpiry = Word32 -> EpochNo
offsetEpochInterval Word32
4
        c6Expiry :: EpochNo
c6Expiry = Word32 -> EpochNo
offsetEpochInterval Word32
6
        c7Expiry :: EpochNo
c7Expiry = Word32 -> EpochNo
offsetEpochInterval Word32
7
    ga2 :: GovPurposeId 'CommitteePurpose era
ga2@(GovPurposeId GovActionId
gaid2) <-
      forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
        (forall a. a -> StrictMaybe a
SJust GovPurposeId 'CommitteePurpose era
ga1)
        Credential 'DRepRole
drep
        [Credential 'ColdCommitteeRole
c2]
        [ (Credential 'ColdCommitteeRole
c1, EpochNo
c1NewExpiry)
        , (Credential 'ColdCommitteeRole
c4, EpochNo
c4NewExpiry)
        , (Credential 'ColdCommitteeRole
c6, EpochNo
c6Expiry)
        , (Credential 'ColdCommitteeRole
c7, EpochNo
c7Expiry)
        ]
    forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter -> GovActionId -> ImpTestM era ()
submitYesVote_ (KeyHash 'StakePool -> Voter
StakePoolVoter KeyHash 'StakePool
spoC) GovActionId
gaid2
    forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch -- epoch 4
    Credential 'HotCommitteeRole
hk6 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c6
    Credential 'HotCommitteeRole
hk8 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole
-> ImpTestM era (Credential 'HotCommitteeRole)
registerCommitteeHotKey Credential 'ColdCommitteeRole
c8

    -- in the next epoch after the election, the old committee is still in place
    forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole) -> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole
c1, Credential 'ColdCommitteeRole
c2, Credential 'ColdCommitteeRole
c3, Credential 'ColdCommitteeRole
c4]

    -- members that are not be part of the next committee are `ToBeRemoved`
    -- members that are part of both current and next committee have `NoChangeExpected` or `TermAdjusted`
    -- members that part of only next committee are `ToBeEnacted`
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c1NewExpiry))
      , (Credential 'ColdCommitteeRole
c2, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeRemoved)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , -- though its term was adjusted, `ToBeExpired` takes precedence
        (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
ToBeExpired)
      , (Credential 'ColdCommitteeRole
c6, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk6) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)
      , (Credential 'ColdCommitteeRole
c7, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)
      , (Credential 'ColdCommitteeRole
c8, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk8) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
      ]
    HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult
      [Credential 'ColdCommitteeRole
c1]
      forall a. Monoid a => a
mempty
      forall a. Monoid a => a
mempty
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c1NewExpiry))
      ]
    HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult
      [Credential 'ColdCommitteeRole
c2]
      [Credential 'HotCommitteeRole
hk2]
      [MemberStatus
Expired]
      ( forall k a. k -> a -> Map k a
Map.singleton
          Credential 'ColdCommitteeRole
c2
          (HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeRemoved)
      )

    forall era. ShelleyEraImp era => Natural -> ImpTestM era ()
passNEpochs Natural
2 -- epoch 6
    -- the new committee is in place with the adjusted terms
    forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole) -> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole
c1, Credential 'ColdCommitteeRole
c3, Credential 'ColdCommitteeRole
c4, Credential 'ColdCommitteeRole
c6, Credential 'ColdCommitteeRole
c7]
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1NewExpiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c3, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c4NewExpiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c6, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk6) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c6Expiry) NextEpochChange
ToBeExpired)
      , (Credential 'ColdCommitteeRole
c7, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
NoChangeExpected)
      ]
    HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult
      forall a. Set a
Set.empty
      forall a. Set a
Set.empty
      [MemberStatus
Unrecognized]
      forall k a. Map k a
Map.empty

    -- elect new committee to be:
    -- c4 (which is presently `Expired`, set a new term),
    -- c6 (which is presently `ToBeExpired`, set a new term)
    -- c7 (which will become `ToBeExpired` in the next epoch)
    -- c3 (which would become `ToBeExpired` in the next epoch, but set a new term)
    let c3NewExpiry :: EpochNo
c3NewExpiry = Word32 -> EpochNo
offsetEpochInterval Word32
9
        c4NewNewExpiry :: EpochNo
c4NewNewExpiry = Word32 -> EpochNo
offsetEpochInterval Word32
9
        c6NewExpiry :: EpochNo
c6NewExpiry = Word32 -> EpochNo
offsetEpochInterval Word32
9
    GovPurposeId GovActionId
gaid3 <-
      forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole
-> Set (Credential 'ColdCommitteeRole)
-> Map (Credential 'ColdCommitteeRole) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
        (forall a. a -> StrictMaybe a
SJust GovPurposeId 'CommitteePurpose era
ga2)
        Credential 'DRepRole
drep
        [Credential 'ColdCommitteeRole
c1]
        [ (Credential 'ColdCommitteeRole
c3, EpochNo
c3NewExpiry)
        , (Credential 'ColdCommitteeRole
c4, EpochNo
c4NewNewExpiry)
        , (Credential 'ColdCommitteeRole
c6, EpochNo
c6NewExpiry)
        ]
    forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter -> GovActionId -> ImpTestM era ()
submitYesVote_ (KeyHash 'StakePool -> Voter
StakePoolVoter KeyHash 'StakePool
spoC) GovActionId
gaid3
    forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch -- epoch 7
    -- members whose term changed have next epoch change `TermAdjusted`
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [ (Credential 'ColdCommitteeRole
c1, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1NewExpiry) NextEpochChange
ToBeRemoved)
      ,
        ( Credential 'ColdCommitteeRole
c3
        , HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState
            (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor))
            MemberStatus
Active
            (forall a. a -> Maybe a
Just EpochNo
c3Expiry)
            (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c3NewExpiry)
        )
      ,
        ( Credential 'ColdCommitteeRole
c4
        , HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c4NewExpiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c4NewNewExpiry)
        )
      , (Credential 'ColdCommitteeRole
c6, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk6) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c6Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c6NewExpiry))
      , (Credential 'ColdCommitteeRole
c7, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
ToBeExpired)
      ]
    forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch -- epoch 8
    forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole) -> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole
c3, Credential 'ColdCommitteeRole
c4, Credential 'ColdCommitteeRole
c6, Credential 'ColdCommitteeRole
c7]
    HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
      [
        ( Credential 'ColdCommitteeRole
c3
        , HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Maybe Anchor -> HotCredAuthStatus
MemberResigned (forall a. a -> Maybe a
Just Anchor
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3NewExpiry) NextEpochChange
NoChangeExpected
        )
      , (Credential 'ColdCommitteeRole
c4, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4NewNewExpiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c6, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState (Credential 'HotCommitteeRole -> HotCredAuthStatus
MemberAuthorized Credential 'HotCommitteeRole
hk6) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c6NewExpiry) NextEpochChange
NoChangeExpected)
      , (Credential 'ColdCommitteeRole
c7, HotCredAuthStatus
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState
CommitteeMemberState HotCredAuthStatus
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
NoChangeExpected)
      ]
  where
    expectQueryResult ::
      HasCallStack =>
      Set.Set (Credential 'ColdCommitteeRole) ->
      Set.Set (Credential 'HotCommitteeRole) ->
      Set.Set MemberStatus ->
      Map.Map (Credential 'ColdCommitteeRole) CommitteeMemberState ->
      ImpTestM era ()
    expectQueryResult :: HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult Set (Credential 'ColdCommitteeRole)
ckFilter Set (Credential 'HotCommitteeRole)
hkFilter Set MemberStatus
statusFilter Map (Credential 'ColdCommitteeRole) CommitteeMemberState
expResult = do
      NewEpochState era
nes <- forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
use forall era. Lens' (ImpTestState era) (NewEpochState era)
impNESL
      let CommitteeMembersState {Map (Credential 'ColdCommitteeRole) CommitteeMemberState
csCommittee :: CommitteeMembersState
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
csCommittee :: Map (Credential 'ColdCommitteeRole) CommitteeMemberState
csCommittee} =
            forall era.
ConwayEraGov era =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> NewEpochState era
-> CommitteeMembersState
queryCommitteeMembersState
              Set (Credential 'ColdCommitteeRole)
ckFilter
              Set (Credential 'HotCommitteeRole)
hkFilter
              Set MemberStatus
statusFilter
              NewEpochState era
nes
      forall a t. NFData a => String -> ImpM t a -> ImpM t a
impAnn String
"Expecting query result" forall a b. (a -> b) -> a -> b
$
        Map (Credential 'ColdCommitteeRole) CommitteeMemberState
csCommittee forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` Map (Credential 'ColdCommitteeRole) CommitteeMemberState
expResult

    expectNoFilterQueryResult ::
      HasCallStack =>
      Map.Map (Credential 'ColdCommitteeRole) CommitteeMemberState ->
      ImpTestM era ()
    expectNoFilterQueryResult :: HasCallStack =>
Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult =
      HasCallStack =>
Set (Credential 'ColdCommitteeRole)
-> Set (Credential 'HotCommitteeRole)
-> Set MemberStatus
-> Map (Credential 'ColdCommitteeRole) CommitteeMemberState
-> ImpM (LedgerSpec era) ()
expectQueryResult forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty