add tests for GAT minting
no more propsoal T_T
This commit is contained in:
parent
f6cf4f01db
commit
c450e1252d
12 changed files with 1544 additions and 751 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -327,7 +327,7 @@ mkTestTree name ps isValid = group name [proposal, stake]
|
|||
let proposalInputDatum = mkProposalInputDatum ps
|
||||
in testValidator
|
||||
isValid
|
||||
"propsoal"
|
||||
"proposal"
|
||||
(proposalValidator Shared.proposal)
|
||||
proposalInputDatum
|
||||
(mkProposalRedeemer ps)
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ mkTimeRange ps =
|
|||
in closedBoundedInterval s $ o + di
|
||||
else always
|
||||
|
||||
-- | Get the starting time of the propsoal.
|
||||
-- | Get the starting time of the proposal.
|
||||
mkProposalStartingTime :: Parameters -> ProposalStartingTime
|
||||
mkProposalStartingTime ps =
|
||||
if ps.timeRangeClosed
|
||||
|
|
@ -413,7 +413,7 @@ invalidProposalStatusParameters =
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
{- | Create a test tree that runs the propsoal minting policy, the governor
|
||||
{- | Create a test tree that runs the proposal minting policy, the governor
|
||||
validator and the stake validator to test the functionalities of creting
|
||||
proposals
|
||||
-}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
{- |
|
||||
Module : Sample.Proposal.Shared
|
||||
Maintainer : connor@mlabs.city
|
||||
Description: Shared constants for propsoal samples
|
||||
Description: Shared constants for proposal samples
|
||||
|
||||
Shared constants for propsoal samples.
|
||||
Shared constants for proposal samples.
|
||||
-}
|
||||
module Sample.Proposal.Shared (proposalTxRef, stakeTxRef, governorTxRef) where
|
||||
|
||||
import PlutusLedgerApi.V1 (TxId)
|
||||
|
||||
-- | 'TxId' of all the propsoal inputs in the samples.
|
||||
-- | 'TxId' of all the proposal inputs in the samples.
|
||||
proposalTxRef :: TxId
|
||||
proposalTxRef = "0b2086cbf8b6900f8cb65e012de4516cb66b5cb08a9aaba12a8b88be"
|
||||
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ mkTestTree name ps isValid = group name [stake, proposal]
|
|||
ref = mkProposalRef idx
|
||||
in testValidator
|
||||
isValid
|
||||
"propsoal"
|
||||
"proposal"
|
||||
(proposalValidator Shared.proposal)
|
||||
(mkProposalInputDatum ps pid)
|
||||
proposalRedeemer
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ mkTestTree name ps isValid = group name [proposal, stake]
|
|||
proposal =
|
||||
testValidator
|
||||
isValid
|
||||
"propsoal"
|
||||
"proposal"
|
||||
(proposalValidator Shared.proposal)
|
||||
proposalInputDatum
|
||||
(mkProposalRedeemer ps)
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ instance Default ProposalThresholds where
|
|||
ProposalThresholds
|
||||
{ execute = Tagged 1000
|
||||
, create = Tagged 1
|
||||
, vote = Tagged 10
|
||||
, vote = Tagged 100
|
||||
}
|
||||
|
||||
authorityToken :: AuthorityToken
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ specs =
|
|||
|
||||
mkLegalGroup nCosigners =
|
||||
Cosign.mkTestTree
|
||||
("with " <> show nCosigners <> " cosigners")
|
||||
(unwords ["with", show nCosigners, "cosigners"])
|
||||
(Cosign.validCosignNParameters nCosigners)
|
||||
True
|
||||
legalGroup =
|
||||
|
|
@ -101,7 +101,7 @@ specs =
|
|||
map mkLegalGroup cosignerCases
|
||||
|
||||
mkIllegalStatusNotDraftGroup nCosigners =
|
||||
group ("with " <> show nCosigners <> " cosigners") $
|
||||
group (unwords ["with", show nCosigners, "cosigners"]) $
|
||||
map
|
||||
( \ps ->
|
||||
Cosign.mkTestTree
|
||||
|
|
@ -133,99 +133,164 @@ specs =
|
|||
[ Vote.mkTestTree "legal" Vote.validVoteParameters True
|
||||
-- TODO: add negative test cases
|
||||
]
|
||||
, group "advancing" $
|
||||
let mkFromDraft nCosigners =
|
||||
let name = "with " <> show nCosigners <> " cosigner(s)"
|
||||
, group
|
||||
"advancing"
|
||||
$ let possibleCosigners = [1, 5, 10]
|
||||
possibleEffects = [1, 2, 5]
|
||||
in do
|
||||
cs <- possibleCosigners
|
||||
es <- possibleEffects
|
||||
|
||||
legalGroup =
|
||||
group
|
||||
"legal"
|
||||
[ Advance.mkTestTree
|
||||
"to next state"
|
||||
( head $
|
||||
Advance.advanceToNextStateInTimeParameters
|
||||
nCosigners
|
||||
)
|
||||
True
|
||||
Nothing
|
||||
, Advance.mkTestTree
|
||||
"to failed state"
|
||||
( head $
|
||||
Advance.advanceToFailedStateDueToTimeoutParameters
|
||||
nCosigners
|
||||
)
|
||||
True
|
||||
Nothing
|
||||
]
|
||||
let groupName =
|
||||
unwords
|
||||
[ "with"
|
||||
, show cs
|
||||
, "cosigners"
|
||||
, "and"
|
||||
, show es
|
||||
, "effects"
|
||||
]
|
||||
|
||||
illegalGroup =
|
||||
group
|
||||
"illegal"
|
||||
[ Advance.mkTestTree
|
||||
"insufficient cosigns"
|
||||
(Advance.insufficientCosignsParameters nCosigners)
|
||||
False
|
||||
Nothing
|
||||
, Advance.mkTestTree
|
||||
"invalid stake output"
|
||||
(head $ Advance.invalidOutputStakeParameters nCosigners)
|
||||
False
|
||||
Nothing
|
||||
]
|
||||
in group name [legalGroup, illegalGroup]
|
||||
|
||||
draftGroup = group "from draft" $ map mkFromDraft [1, 5, 10]
|
||||
|
||||
legalGroup =
|
||||
group
|
||||
"legal"
|
||||
[ group "advance to next state" $
|
||||
map
|
||||
( \ps ->
|
||||
let name = "from: " <> show ps.fromStatus
|
||||
in Advance.mkTestTree name ps True (Just True)
|
||||
)
|
||||
(tail $ Advance.advanceToNextStateInTimeParameters 1)
|
||||
, group "advance to failed state" $
|
||||
map
|
||||
( \ps ->
|
||||
let name = "from: " <> show ps.fromStatus
|
||||
in Advance.mkTestTree name ps True (Just True)
|
||||
)
|
||||
(tail $ Advance.advanceToFailedStateDueToTimeoutParameters 1)
|
||||
]
|
||||
|
||||
illegalGroup =
|
||||
group
|
||||
"illegal"
|
||||
[ Advance.mkTestTree
|
||||
"insufficient votes"
|
||||
Advance.insufficientVotesParameters
|
||||
False
|
||||
Nothing
|
||||
, Advance.mkTestTree
|
||||
"initial state is Finished"
|
||||
Advance.advanceFromFinishedParameters
|
||||
False
|
||||
Nothing
|
||||
, group
|
||||
"invalid stake output"
|
||||
$ do
|
||||
nStake <- [1, 5]
|
||||
ps <- tail $ Advance.invalidOutputStakeParameters nStake
|
||||
|
||||
let name =
|
||||
"from " <> show ps.fromStatus <> "with "
|
||||
<> show nStake
|
||||
<> " stakes"
|
||||
|
||||
pure $ Advance.mkTestTree name ps False (Just True)
|
||||
]
|
||||
in [draftGroup, legalGroup, illegalGroup]
|
||||
pure $
|
||||
group
|
||||
groupName
|
||||
[ group
|
||||
"legal"
|
||||
$ let allValid =
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just True
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
mkName b =
|
||||
unwords
|
||||
[ "from"
|
||||
, show b.proposalParameters.fromStatus
|
||||
, "to"
|
||||
, show b.proposalParameters.toStatus
|
||||
]
|
||||
in [ Advance.mkTestTree'
|
||||
"to next state"
|
||||
mkName
|
||||
(Advance.mkValidToNextStateBundles cs es)
|
||||
allValid
|
||||
, Advance.mkTestTree'
|
||||
"to failed state"
|
||||
mkName
|
||||
(Advance.mkValidToFailedStateBundles cs es)
|
||||
allValid
|
||||
]
|
||||
, group
|
||||
"illegal"
|
||||
[ Advance.mkTestTree'
|
||||
"advance finished proposals"
|
||||
(const "(negative test)")
|
||||
(Advance.mkFromFinishedBundles cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"insufficient cosigns"
|
||||
(Advance.mkInsufficientCosignsBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Nothing
|
||||
, forAuthorityTokenPolicy = Nothing
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"insufficient votes"
|
||||
(Advance.mkInsufficientVotesBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Nothing
|
||||
, forAuthorityTokenPolicy = Nothing
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"ambiguous winning effect"
|
||||
(Advance.mkAmbiguousWinnerBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Nothing
|
||||
, forAuthorityTokenPolicy = Nothing
|
||||
}
|
||||
, Advance.mkTestTree'
|
||||
"to next state too late"
|
||||
(\b -> unwords ["from", show b.proposalParameters.fromStatus])
|
||||
(Advance.mkToNextStateTooLateBundles cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just True
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree'
|
||||
"altered output stake datum"
|
||||
(\b -> unwords ["from", show b.proposalParameters.fromStatus])
|
||||
(Advance.mkInvalidOutputStakeBundles cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = False
|
||||
, forStakeValidator = False
|
||||
, forGovernorValidator = Just True
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"forget to mint GATs"
|
||||
(Advance.mkNoGATMintedBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Nothing
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"mint GATs for wrong validators"
|
||||
(Advance.mkMintGATsForWrongEffectsBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"mint GATs with bad token name"
|
||||
(Advance.mkMintGATsWithoutTagBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just False
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"wrong GAT datum"
|
||||
(Advance.mkGATsWithWrongDatumBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
, Advance.mkTestTree
|
||||
"invalid governor output datum"
|
||||
(Advance.mkBadGovernorOutputDatumBundle cs es)
|
||||
Advance.Validity
|
||||
{ forProposalValidator = True
|
||||
, forStakeValidator = True
|
||||
, forGovernorValidator = Just False
|
||||
, forAuthorityTokenPolicy = Just True
|
||||
}
|
||||
]
|
||||
]
|
||||
, group "unlocking" $
|
||||
let proposalCountCases = [1, 5, 10, 42]
|
||||
|
||||
mkSubgroupName nProposals = "with " <> show nProposals <> " proposals"
|
||||
mkSubgroupName nProposals = unwords ["with", show nProposals, "proposals"]
|
||||
|
||||
mkLegalGroup nProposals =
|
||||
group
|
||||
|
|
@ -266,9 +331,13 @@ specs =
|
|||
map
|
||||
( \ps ->
|
||||
let name =
|
||||
"role: " <> show ps.stakeRole
|
||||
<> ", status: "
|
||||
<> show ps.proposalStatus
|
||||
unwords
|
||||
[ "role:"
|
||||
, show ps.stakeRole
|
||||
, ","
|
||||
, "status:"
|
||||
, show ps.proposalStatus
|
||||
]
|
||||
in UnlockStake.mkTestTree name ps False
|
||||
)
|
||||
(UnlockStake.mkRetractVotesWhileNotVoting nProposals)
|
||||
|
|
@ -276,9 +345,12 @@ specs =
|
|||
map
|
||||
( \ps ->
|
||||
let name =
|
||||
"status: " <> show ps.proposalStatus
|
||||
<> "retract votes: "
|
||||
<> show ps.retractVotes
|
||||
unwords
|
||||
[ "status:"
|
||||
, show ps.proposalStatus
|
||||
, "retract votes:"
|
||||
, show ps.retractVotes
|
||||
]
|
||||
in UnlockStake.mkTestTree name ps False
|
||||
)
|
||||
(UnlockStake.mkUnockIrrelevantStakeParameters nProposals)
|
||||
|
|
@ -286,7 +358,8 @@ specs =
|
|||
map
|
||||
( \ps ->
|
||||
let name =
|
||||
"status: " <> show ps.proposalStatus
|
||||
unwords
|
||||
["status:", show ps.proposalStatus]
|
||||
in UnlockStake.mkTestTree name ps False
|
||||
)
|
||||
(UnlockStake.mkRemoveCreatorLockBeforeFinishedParameters nProposals)
|
||||
|
|
@ -298,9 +371,13 @@ specs =
|
|||
map
|
||||
( \ps ->
|
||||
let name =
|
||||
"role: " <> show ps.stakeRole
|
||||
<> ", status: "
|
||||
<> show ps.proposalStatus
|
||||
unwords
|
||||
[ "role:"
|
||||
, show ps.stakeRole
|
||||
, ","
|
||||
, "status:"
|
||||
, show ps.proposalStatus
|
||||
]
|
||||
in UnlockStake.mkTestTree name ps False
|
||||
)
|
||||
(UnlockStake.mkAlterStakeParameters nProposals)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue