{-# 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.Core
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 (EraCrypto era) ->
NewEpochState era ->
m (DRepState (EraCrypto era))
drepStateFromQuery :: forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes =
case forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Credential 'DRepRole (EraCrypto era)
drep (forall era.
NewEpochState era
-> Set (Credential 'DRepRole (EraCrypto era))
-> Map
(Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era))
queryDRepState NewEpochState era
nes forall a. Monoid a => a
mempty) of
Maybe (DRepState (EraCrypto era))
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 (EraCrypto era)
drep forall a. [a] -> [a] -> [a]
++ String
" to be present in the query result"
Just DRepState (EraCrypto era)
state -> forall (f :: * -> *) a. Applicative f => a -> f a
pure DRepState (EraCrypto era)
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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
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 (EraCrypto era)
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes
DRepState (EraCrypto era)
drepState forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
forall era.
HasCallStack =>
Credential 'DRepRole (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era))
-> 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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
drep
DRepState (EraCrypto era)
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
drepState forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
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 (EraCrypto era)
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes
DRepState (EraCrypto era)
drepState forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
drep forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
m a -> a -> m ()
`shouldReturn` Bool
False
forall era.
HasCallStack =>
Credential 'DRepRole (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
drep EpochNo
actualExpiry
forall era.
HasCallStack =>
Credential 'DRepRole (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era))
-> 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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
drep EpochNo
actualExpiry
NewEpochState era
nes1 <- forall era a. SimpleGetter (NewEpochState era) a -> ImpTestM era a
getsNES forall a. a -> a
id
DRepState (EraCrypto era)
drepState1 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes1
DRepState (EraCrypto era)
drepState1 forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
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 (EraCrypto era)
drepState <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes
DRepState (EraCrypto era)
drepState forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> ImpTestM era ()
updateDRep Credential 'DRepRole (EraCrypto era)
drep
forall era.
HasCallStack =>
Credential 'DRepRole (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
drepState1 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
drep NewEpochState era
nes1
DRepState (EraCrypto era)
drepState1
forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) 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 (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era))
-> 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 (EraCrypto era)
drepState2 <- forall (m :: * -> *).
(HasCallStack, Monad m) =>
Credential 'DRepRole (EraCrypto era)
-> NewEpochState era -> m (DRepState (EraCrypto era))
drepStateFromQuery Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
drepState2 forall s a. s -> Getting a s a -> a
^. forall c. Lens' (DRepState c) EpochNo
drepExpiryL forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` EpochNo
drepExpiry2
forall era.
HasCallStack =>
Credential 'DRepRole (EraCrypto era) -> EpochNo -> ImpTestM era ()
expectActualDRepExpiry Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era) -> ImpTestM era Bool
isDRepExpired Credential 'DRepRole (EraCrypto era)
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 (EraCrypto era)
c1 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
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 (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) 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 (EraCrypto era)
c1 (Word64 -> EpochNo
EpochNo Word64
4321)) (Integer
1 forall r. (IsRatio r, HasCallStack) => Integer -> Integer -> r
%! Integer
1)
Credential 'HotCommitteeRole (EraCrypto era)
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c1
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole (EraCrypto era)
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
[(Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)]
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole (EraCrypto era)
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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
setupSingleDRep Integer
1_000_000
(KeyHash 'StakePool (EraCrypto era)
spoC, Credential 'Payment (EraCrypto era)
_, Credential 'Staking (EraCrypto era)
_) <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Coin
-> ImpTestM
era
(KeyHash 'StakePool (EraCrypto era),
Credential 'Payment (EraCrypto era),
Credential 'Staking (EraCrypto era))
setupPoolWithStake forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin Integer
42_000_000
Credential 'ColdCommitteeRole (EraCrypto era)
c1 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
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 (EraCrypto era))
initialCommitteeMembers <- forall era.
ConwayEraImp era =>
ImpTestM era (Set (Credential 'ColdCommitteeRole (EraCrypto era)))
getCommitteeMembers
GovPurposeId GovActionId (EraCrypto era)
gid <-
forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole (EraCrypto era)
-> Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
forall a. StrictMaybe a
SNothing
Credential 'DRepRole (EraCrypto era)
drep
Set (Credential 'ColdCommitteeRole (EraCrypto era))
initialCommitteeMembers
[(Credential 'ColdCommitteeRole (EraCrypto era)
c1, EpochNo
c1Expiry)]
forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter (EraCrypto era)
-> GovActionId (EraCrypto era) -> ImpTestM era ()
submitYesVote_ (forall c. KeyHash 'StakePool c -> Voter c
StakePoolVoter KeyHash 'StakePool (EraCrypto era)
spoC) GovActionId (EraCrypto era)
gid
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
Credential 'HotCommitteeRole (EraCrypto era)
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c1
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole (EraCrypto era)
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
[(Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)]
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult (forall a. a -> Set a
Set.singleton Credential 'ColdCommitteeRole (EraCrypto era)
c1) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a b. (a -> b) -> a -> b
$
[(Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
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 (EraCrypto era)
drep, Credential 'Staking (EraCrypto era)
_, KeyPair 'Payment (EraCrypto era)
_) <- forall era.
ConwayEraImp era =>
Integer
-> ImpTestM
era
(Credential 'DRepRole (EraCrypto era),
Credential 'Staking (EraCrypto era),
KeyPair 'Payment (EraCrypto era))
setupSingleDRep Integer
1_000_000
(KeyHash 'StakePool (EraCrypto era)
spoC, Credential 'Payment (EraCrypto era)
_, Credential 'Staking (EraCrypto era)
_) <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Coin
-> ImpTestM
era
(KeyHash 'StakePool (EraCrypto era),
Credential 'Payment (EraCrypto era),
Credential 'Staking (EraCrypto era))
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 (EraCrypto era), EpochNo)
cExpiry Word32
n =
(,)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
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 (EraCrypto era)
c1, EpochNo
c1Expiry) <- Word32
-> ImpM
(LedgerSpec era)
(Credential 'ColdCommitteeRole (EraCrypto era), EpochNo)
cExpiry Word32
12
(Credential 'ColdCommitteeRole (EraCrypto era)
c2, EpochNo
c2Expiry) <- Word32
-> ImpM
(LedgerSpec era)
(Credential 'ColdCommitteeRole (EraCrypto era), EpochNo)
cExpiry Word32
2
(Credential 'ColdCommitteeRole (EraCrypto era)
c3, EpochNo
c3Expiry) <- Word32
-> ImpM
(LedgerSpec era)
(Credential 'ColdCommitteeRole (EraCrypto era), EpochNo)
cExpiry Word32
7
(Credential 'ColdCommitteeRole (EraCrypto era)
c4, EpochNo
c4Expiry) <- Word32
-> ImpM
(LedgerSpec era)
(Credential 'ColdCommitteeRole (EraCrypto era), EpochNo)
cExpiry Word32
5
Credential 'ColdCommitteeRole (EraCrypto era)
c5 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
freshKeyHash
Credential 'ColdCommitteeRole (EraCrypto era)
c6 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
freshKeyHash
Credential 'ColdCommitteeRole (EraCrypto era)
c7 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
freshKeyHash
Credential 'ColdCommitteeRole (EraCrypto era)
c8 <- forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s c (m :: * -> *) g (r :: KeyRole).
(HasKeyPairs s c, MonadState s m, HasStatefulGen g m) =>
m (KeyHash r c)
freshKeyHash
let newMembers :: Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
newMembers =
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, EpochNo
c1Expiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, EpochNo
c2Expiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, EpochNo
c3Expiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, EpochNo
c4Expiry)
]
Set (Credential 'ColdCommitteeRole (EraCrypto era))
initialMembers <- forall era.
ConwayEraImp era =>
ImpTestM era (Set (Credential 'ColdCommitteeRole (EraCrypto era)))
getCommitteeMembers
ga1 :: GovPurposeId 'CommitteePurpose era
ga1@(GovPurposeId GovActionId (EraCrypto era)
gaid1) <-
forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole (EraCrypto era)
-> Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
forall a. StrictMaybe a
SNothing
Credential 'DRepRole (EraCrypto era)
drep
Set (Credential 'ColdCommitteeRole (EraCrypto era))
initialMembers
Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
newMembers
forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter (EraCrypto era)
-> GovActionId (EraCrypto era) -> ImpTestM era ()
submitYesVote_ (forall c. KeyHash 'StakePool c -> Voter c
StakePoolVoter KeyHash 'StakePool (EraCrypto era)
spoC) GovActionId (EraCrypto era)
gaid1
forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> ImpTestM era ()
expectMembers Set (Credential 'ColdCommitteeRole (EraCrypto era))
initialMembers
forall era. ShelleyEraImp era => Natural -> ImpTestM era ()
passNEpochs Natural
2
forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> ImpTestM era ()
expectMembers forall a b. (a -> b) -> a -> b
$ forall k a. Map k a -> Set k
Map.keysSet Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
newMembers
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
]
Credential 'HotCommitteeRole (EraCrypto era)
hk1 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c1
Credential 'HotCommitteeRole (EraCrypto era)
hk2 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c2
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
]
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult
[Credential 'ColdCommitteeRole (EraCrypto era)
c2, Credential 'ColdCommitteeRole (EraCrypto era)
c3, Credential 'ColdCommitteeRole (EraCrypto era)
c5]
forall a. Monoid a => a
mempty
[MemberStatus
Active, MemberStatus
Unrecognized]
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
]
Anchor (EraCrypto era)
c3Anchor <- forall a (m :: * -> *). (Arbitrary a, MonadGen m) => m a
arbitrary
Maybe (Credential 'HotCommitteeRole (EraCrypto era))
_ <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> StrictMaybe (Anchor (EraCrypto era))
-> ImpTestM
era (Maybe (Credential 'HotCommitteeRole (EraCrypto era)))
resignCommitteeColdKey Credential 'ColdCommitteeRole (EraCrypto era)
c3 (forall a. a -> StrictMaybe a
SJust Anchor (EraCrypto era)
c3Anchor)
GovActionId (EraCrypto era)
_ <-
forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
GovAction era -> ImpTestM era (GovActionId (EraCrypto era))
submitGovAction forall a b. (a -> b) -> a -> b
$
forall era.
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) 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 (EraCrypto era)
c5, Word32 -> EpochNo
offsetEpochInterval Word32
10), (Credential 'ColdCommitteeRole (EraCrypto era)
c8, Word32 -> EpochNo
offsetEpochInterval Word32
10)])
(Integer
1 forall r. (IsRatio r, HasCallStack) => Integer -> Integer -> r
%! Integer
1)
Credential 'HotCommitteeRole (EraCrypto era)
hk5 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c5
forall era. (HasCallStack, ShelleyEraImp era) => ImpTestM era ()
passTick
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeExpired)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c5, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk5) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
]
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult
[Credential 'ColdCommitteeRole (EraCrypto era)
c2, Credential 'ColdCommitteeRole (EraCrypto era)
c3, Credential 'ColdCommitteeRole (EraCrypto era)
c5]
[Credential 'HotCommitteeRole (EraCrypto era)
hk5]
[MemberStatus
Unrecognized]
( forall k a. k -> a -> Map k a
Map.singleton
Credential 'ColdCommitteeRole (EraCrypto era)
c5
(forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk5) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
)
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
NoChangeExpected)
]
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 (EraCrypto era)
gaid2) <-
forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole (EraCrypto era)
-> Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
(forall a. a -> StrictMaybe a
SJust GovPurposeId 'CommitteePurpose era
ga1)
Credential 'DRepRole (EraCrypto era)
drep
[Credential 'ColdCommitteeRole (EraCrypto era)
c2]
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, EpochNo
c1NewExpiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, EpochNo
c4NewExpiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, EpochNo
c6Expiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c7, EpochNo
c7Expiry)
]
forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter (EraCrypto era)
-> GovActionId (EraCrypto era) -> ImpTestM era ()
submitYesVote_ (forall c. KeyHash 'StakePool c -> Voter c
StakePoolVoter KeyHash 'StakePool (EraCrypto era)
spoC) GovActionId (EraCrypto era)
gaid2
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
Credential 'HotCommitteeRole (EraCrypto era)
hk6 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c6
Credential 'HotCommitteeRole (EraCrypto era)
hk8 <- forall era.
(ShelleyEraImp era, ConwayEraTxCert era) =>
Credential 'ColdCommitteeRole (EraCrypto era)
-> ImpTestM era (Credential 'HotCommitteeRole (EraCrypto era))
registerCommitteeHotKey Credential 'ColdCommitteeRole (EraCrypto era)
c8
forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole (EraCrypto era)
c1, Credential 'ColdCommitteeRole (EraCrypto era)
c2, Credential 'ColdCommitteeRole (EraCrypto era)
c3, Credential 'ColdCommitteeRole (EraCrypto era)
c4]
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c1NewExpiry))
, (Credential 'ColdCommitteeRole (EraCrypto era)
c2, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeRemoved)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
,
(Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4Expiry) NextEpochChange
ToBeExpired)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk6) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c7, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeEnacted)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c8, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk8) MemberStatus
Unrecognized forall a. Maybe a
Nothing NextEpochChange
ToBeRemoved)
]
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult
[Credential 'ColdCommitteeRole (EraCrypto era)
c1]
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c1NewExpiry))
]
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult
[Credential 'ColdCommitteeRole (EraCrypto era)
c2]
[Credential 'HotCommitteeRole (EraCrypto era)
hk2]
[MemberStatus
Expired]
( forall k a. k -> a -> Map k a
Map.singleton
Credential 'ColdCommitteeRole (EraCrypto era)
c2
(forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk2) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c2Expiry) NextEpochChange
ToBeRemoved)
)
forall era. ShelleyEraImp era => Natural -> ImpTestM era ()
passNEpochs Natural
2
forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole (EraCrypto era)
c1, Credential 'ColdCommitteeRole (EraCrypto era)
c3, Credential 'ColdCommitteeRole (EraCrypto era)
c4, Credential 'ColdCommitteeRole (EraCrypto era)
c6, Credential 'ColdCommitteeRole (EraCrypto era)
c7]
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1NewExpiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c3, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3Expiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c4NewExpiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk6) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c6Expiry) NextEpochChange
ToBeExpired)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c7, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
NoChangeExpected)
]
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> 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
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 (EraCrypto era)
gaid3 <-
forall era.
(HasCallStack, ConwayEraImp era) =>
StrictMaybe (GovPurposeId 'CommitteePurpose era)
-> Credential 'DRepRole (EraCrypto era)
-> Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Map (Credential 'ColdCommitteeRole (EraCrypto era)) EpochNo
-> ImpTestM era (GovPurposeId 'CommitteePurpose era)
electCommittee
(forall a. a -> StrictMaybe a
SJust GovPurposeId 'CommitteePurpose era
ga2)
Credential 'DRepRole (EraCrypto era)
drep
[Credential 'ColdCommitteeRole (EraCrypto era)
c1]
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c3, EpochNo
c3NewExpiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, EpochNo
c4NewNewExpiry)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, EpochNo
c6NewExpiry)
]
forall era.
(ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) =>
Voter (EraCrypto era)
-> GovActionId (EraCrypto era) -> ImpTestM era ()
submitYesVote_ (forall c. KeyHash 'StakePool c -> Voter c
StakePoolVoter KeyHash 'StakePool (EraCrypto era)
spoC) GovActionId (EraCrypto era)
gaid3
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[ (Credential 'ColdCommitteeRole (EraCrypto era)
c1, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk1) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c1NewExpiry) NextEpochChange
ToBeRemoved)
,
( Credential 'ColdCommitteeRole (EraCrypto era)
c3
, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState
(forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor))
MemberStatus
Active
(forall a. a -> Maybe a
Just EpochNo
c3Expiry)
(EpochNo -> NextEpochChange
TermAdjusted EpochNo
c3NewExpiry)
)
,
( Credential 'ColdCommitteeRole (EraCrypto era)
c4
, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c4NewExpiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c4NewNewExpiry)
)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk6) MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c6Expiry) (EpochNo -> NextEpochChange
TermAdjusted EpochNo
c6NewExpiry))
, (Credential 'ColdCommitteeRole (EraCrypto era)
c7, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
ToBeExpired)
]
forall era. (ShelleyEraImp era, HasCallStack) => ImpTestM era ()
passEpoch
forall era.
(HasCallStack, ConwayEraGov era) =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> ImpTestM era ()
expectMembers [Credential 'ColdCommitteeRole (EraCrypto era)
c3, Credential 'ColdCommitteeRole (EraCrypto era)
c4, Credential 'ColdCommitteeRole (EraCrypto era)
c6, Credential 'ColdCommitteeRole (EraCrypto era)
c7]
HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult
[
( Credential 'ColdCommitteeRole (EraCrypto era)
c3
, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Maybe (Anchor c) -> HotCredAuthStatus c
MemberResigned (forall a. a -> Maybe a
Just Anchor (EraCrypto era)
c3Anchor)) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c3NewExpiry) NextEpochChange
NoChangeExpected
)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c4, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c4NewNewExpiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c6, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState (forall c. Credential 'HotCommitteeRole c -> HotCredAuthStatus c
MemberAuthorized Credential 'HotCommitteeRole (EraCrypto era)
hk6) MemberStatus
Active (forall a. a -> Maybe a
Just EpochNo
c6NewExpiry) NextEpochChange
NoChangeExpected)
, (Credential 'ColdCommitteeRole (EraCrypto era)
c7, forall c.
HotCredAuthStatus c
-> MemberStatus
-> Maybe EpochNo
-> NextEpochChange
-> CommitteeMemberState c
CommitteeMemberState forall c. HotCredAuthStatus c
MemberNotAuthorized MemberStatus
Expired (forall a. a -> Maybe a
Just EpochNo
c7Expiry) NextEpochChange
NoChangeExpected)
]
where
expectQueryResult ::
HasCallStack =>
Set.Set (Credential 'ColdCommitteeRole (EraCrypto era)) ->
Set.Set (Credential 'HotCommitteeRole (EraCrypto era)) ->
Set.Set MemberStatus ->
Map.Map (Credential 'ColdCommitteeRole (EraCrypto era)) (CommitteeMemberState (EraCrypto era)) ->
ImpTestM era ()
expectQueryResult :: HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult Set (Credential 'ColdCommitteeRole (EraCrypto era))
ckFilter Set (Credential 'HotCommitteeRole (EraCrypto era))
hkFilter Set MemberStatus
statusFilter Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
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 (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
csCommittee :: forall c.
CommitteeMembersState c
-> Map (Credential 'ColdCommitteeRole c) (CommitteeMemberState c)
csCommittee :: Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
csCommittee} =
forall era.
ConwayEraGov era =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> NewEpochState era
-> CommitteeMembersState (EraCrypto era)
queryCommitteeMembersState
Set (Credential 'ColdCommitteeRole (EraCrypto era))
ckFilter
Set (Credential 'HotCommitteeRole (EraCrypto era))
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 (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
csCommittee forall (m :: * -> *) a.
(HasCallStack, MonadIO m, Show a, Eq a) =>
a -> a -> m ()
`shouldBe` Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
expResult
expectNoFilterQueryResult ::
HasCallStack =>
Map.Map (Credential 'ColdCommitteeRole (EraCrypto era)) (CommitteeMemberState (EraCrypto era)) ->
ImpTestM era ()
expectNoFilterQueryResult :: HasCallStack =>
Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectNoFilterQueryResult =
HasCallStack =>
Set (Credential 'ColdCommitteeRole (EraCrypto era))
-> Set (Credential 'HotCommitteeRole (EraCrypto era))
-> Set MemberStatus
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeMemberState (EraCrypto era))
-> ImpM (LedgerSpec era) ()
expectQueryResult forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty