prevent stake inclusion in AdvanceProposal
This commit is contained in:
parent
140105866d
commit
dcdc8803c8
4 changed files with 431 additions and 551 deletions
|
|
@ -35,6 +35,7 @@ module Sample.Proposal.Advance (
|
|||
mkGATsWithWrongDatumBundle,
|
||||
mkMintGATsWithoutTagBundle,
|
||||
mkBadGovernorOutputDatumBundle,
|
||||
mkUnexpectedOutputStakeBundles,
|
||||
) where
|
||||
|
||||
import Agora.Governor (
|
||||
|
|
@ -568,16 +569,19 @@ mkTestTree name pb val =
|
|||
(spend proposalRef)
|
||||
|
||||
stake =
|
||||
let idx = 0
|
||||
in singleton $
|
||||
testValidator
|
||||
val.forStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
(getStakeInputDatumAt pb.stakeParameters idx)
|
||||
stakeRedeemer
|
||||
( spend (mkStakeRef idx)
|
||||
)
|
||||
if pb.stakeParameters.numStake == 0
|
||||
then mempty
|
||||
else
|
||||
let idx = 0
|
||||
in singleton $
|
||||
testValidator
|
||||
val.forStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
(getStakeInputDatumAt pb.stakeParameters idx)
|
||||
stakeRedeemer
|
||||
( spend (mkStakeRef idx)
|
||||
)
|
||||
|
||||
governor =
|
||||
maybe [] singleton $
|
||||
|
|
@ -813,7 +817,7 @@ mkValidToNextStateBundle nCosigners nEffects authScript from =
|
|||
}
|
||||
, stakeParameters =
|
||||
StakeParameters
|
||||
{ numStake = 1
|
||||
{ numStake = 0
|
||||
, perStakeGTs =
|
||||
compPerStakeGTsForDraft $
|
||||
fromIntegral nCosigners
|
||||
|
|
@ -911,7 +915,7 @@ mkValidToFailedStateBundles nCosigners nEffects =
|
|||
}
|
||||
, stakeParameters =
|
||||
StakeParameters
|
||||
{ numStake = 1
|
||||
{ numStake = 0
|
||||
, perStakeGTs =
|
||||
compPerStakeGTsForDraft $
|
||||
fromIntegral nCosigners
|
||||
|
|
@ -977,6 +981,22 @@ mkInvalidOutputStakeBundles nCosigners nEffects =
|
|||
}
|
||||
}
|
||||
|
||||
mkUnexpectedOutputStakeBundles :: Word -> Word -> [ParameterBundle]
|
||||
mkUnexpectedOutputStakeBundles nCosigners nEffects =
|
||||
liftA2
|
||||
mkBundle
|
||||
[True, False]
|
||||
[VotingReady, Locked]
|
||||
where
|
||||
mkBundle authScript from =
|
||||
let template = mkValidToNextStateBundle nCosigners nEffects authScript from
|
||||
in template
|
||||
{ stakeParameters =
|
||||
template.stakeParameters
|
||||
{ numStake = 1
|
||||
}
|
||||
}
|
||||
|
||||
-- * From Draft
|
||||
|
||||
mkInsufficientCosignsBundle :: Word -> Word -> ParameterBundle
|
||||
|
|
|
|||
|
|
@ -244,6 +244,16 @@ specs =
|
|||
, forGovernorValidator = Just True
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree'
|
||||
"unexpected stake datum"
|
||||
(\b -> unwords ["from", show b.proposalParameters.fromStatus])
|
||||
(Advance.mkUnexpectedOutputStakeBundles cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just True
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"forget to mint GATs"
|
||||
(Advance.mkNoGATMintedBundle cs es)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ import Agora.Credential (authorizationContext, pauthorizedBy)
|
|||
import Agora.Proposal (
|
||||
PProposalDatum (PProposalDatum),
|
||||
PProposalRedeemer (PAdvanceProposal, PCosign, PUnlock, PVote),
|
||||
PProposalStatus (PDraft, PFinished, PLocked, PVotingReady),
|
||||
PProposalVotes (PProposalVotes),
|
||||
ProposalStatus (Draft, Finished, Locked, VotingReady),
|
||||
PProposalStatus (PDraft, PFinished, PLocked, PVotingReady),
|
||||
pretractVotes,
|
||||
pwinner',
|
||||
)
|
||||
|
|
@ -620,7 +620,7 @@ proposalValidator as maximumCosigners =
|
|||
)
|
||||
# pfromData txInfoF.inputs
|
||||
let toFailedState = unTermCont $ do
|
||||
-- * -> 'Finished'
|
||||
-- -> 'Finished'
|
||||
pguardC "Proposal should fail: not on time" $
|
||||
proposalOutStatus #== pconstant Finished
|
||||
|
||||
|
|
@ -652,6 +652,8 @@ proposalValidator as maximumCosigners =
|
|||
let notTooLate = inLockedPeriod
|
||||
notTooEarly = pnot # inVotingPeriod
|
||||
pguardC "Cannot advance ahead of time" notTooEarly
|
||||
-- FIXME: This should be checked by Stake, as opposed to here.
|
||||
pguardC "No stakes must be present" $ stakeInputNum #== 0
|
||||
pure $
|
||||
pif
|
||||
notTooLate
|
||||
|
|
@ -673,6 +675,7 @@ proposalValidator as maximumCosigners =
|
|||
let notTooLate = inExecutionPeriod
|
||||
notTooEarly = pnot # inLockedPeriod
|
||||
pguardC "Not too early" notTooEarly
|
||||
pguardC "No stakes must be present" $ stakeInputNum #== 0
|
||||
pure $
|
||||
pif
|
||||
notTooLate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue