regression tests for proposal fast-forward attack
This commit is contained in:
parent
25ae7ce820
commit
a200f4ee20
2 changed files with 43 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ module Sample.Proposal.Advance (
|
||||||
mkMintGATsWithoutTagBundle,
|
mkMintGATsWithoutTagBundle,
|
||||||
mkBadGovernorOutputDatumBundle,
|
mkBadGovernorOutputDatumBundle,
|
||||||
mkUnexpectedOutputStakeBundles,
|
mkUnexpectedOutputStakeBundles,
|
||||||
|
mkFastforwardToFinishBundles,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Agora.Governor (
|
import Agora.Governor (
|
||||||
|
|
@ -278,7 +279,7 @@ mkVotes ps =
|
||||||
|
|
||||||
-- | The starting time of every generated proposal.
|
-- | The starting time of every generated proposal.
|
||||||
proposalStartingTime :: POSIXTime
|
proposalStartingTime :: POSIXTime
|
||||||
proposalStartingTime = 0
|
proposalStartingTime = 100
|
||||||
|
|
||||||
-- | Create the input proposal datum given the parameters.
|
-- | Create the input proposal datum given the parameters.
|
||||||
mkProposalInputDatum :: ProposalParameters -> ProposalDatum
|
mkProposalInputDatum :: ProposalParameters -> ProposalDatum
|
||||||
|
|
@ -1066,3 +1067,34 @@ mkBadGovernorOutputDatumBundle nCosigners nEffects =
|
||||||
where
|
where
|
||||||
template = mkValidFromLockedBundle nCosigners nEffects
|
template = mkValidFromLockedBundle nCosigners nEffects
|
||||||
gov = GovernorParameters True
|
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
|
, forGovernorValidator = Just False
|
||||||
, forAuthorityTokenPolicy = Just True
|
, 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" $
|
, group "unlocking" $
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue