regression tests for proposal fast-forward attack
This commit is contained in:
parent
891e261657
commit
e5e896d978
2 changed files with 43 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ module Sample.Proposal.Advance (
|
|||
mkMintGATsWithoutTagBundle,
|
||||
mkBadGovernorOutputDatumBundle,
|
||||
mkUnexpectedOutputStakeBundles,
|
||||
mkFastforwardToFinishBundles,
|
||||
) where
|
||||
|
||||
import Agora.Governor (
|
||||
|
|
@ -278,7 +279,7 @@ mkVotes ps =
|
|||
|
||||
-- | The starting time of every generated proposal.
|
||||
proposalStartingTime :: POSIXTime
|
||||
proposalStartingTime = 0
|
||||
proposalStartingTime = 100
|
||||
|
||||
-- | Create the input proposal datum given the parameters.
|
||||
mkProposalInputDatum :: ProposalParameters -> ProposalDatum
|
||||
|
|
@ -1066,3 +1067,34 @@ mkBadGovernorOutputDatumBundle nCosigners nEffects =
|
|||
where
|
||||
template = mkValidFromLockedBundle nCosigners nEffects
|
||||
gov = GovernorParameters True
|
||||
|
||||
mkFastforwardToFinishBundles ::
|
||||
Word ->
|
||||
Word ->
|
||||
[ParameterBundle]
|
||||
mkFastforwardToFinishBundles nCosigners nEffects = updateTemplate <$> templates
|
||||
where
|
||||
templates = mkValidToFailedStateBundles nCosigners nEffects
|
||||
mkMaliciousTimRange =
|
||||
let lb = proposalStartingTime - 1
|
||||
dub =
|
||||
1
|
||||
+ proposalStartingTime
|
||||
+ (def :: ProposalTimingConfig).draftTime
|
||||
vub =
|
||||
dub
|
||||
+ (def :: ProposalTimingConfig).votingTime
|
||||
+ (def :: ProposalTimingConfig).lockingTime
|
||||
lub =
|
||||
vub
|
||||
+ (def :: ProposalTimingConfig).executingTime
|
||||
go Draft = (lb, dub)
|
||||
go VotingReady = (lb, vub)
|
||||
go Locked = (lb, lub)
|
||||
go Finished = error "cannot advance from Finished"
|
||||
in uncurry closedBoundedInterval . go
|
||||
updateTemplate template =
|
||||
template
|
||||
{ transactionTimeRange =
|
||||
mkMaliciousTimRange template.proposalParameters.fromStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,6 +327,16 @@ specs =
|
|||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree'
|
||||
"fastforward to finished"
|
||||
(\b -> unwords ["from", show b.proposalParameters.fromStatus])
|
||||
(Advance.mkFastforwardToFinishBundles cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
]
|
||||
]
|
||||
, group "unlocking" $
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue