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