refactor tests of the effect
* test both the effect and governor in the spec * test that the effect and governor will fail when try setting the governor state to a invalid one
This commit is contained in:
parent
fc050527a1
commit
ad33b0cbbc
3 changed files with 125 additions and 63 deletions
|
|
@ -1,30 +1,67 @@
|
|||
module Spec.Effect.GovernorMutation (tests) where
|
||||
|
||||
import Agora.Effect.GovernorMutation (MutateGovernorDatum (..), mutateGovernorValidator)
|
||||
import Agora.Governor (GovernorDatum (..))
|
||||
import Agora.Effect.GovernorMutation (mutateGovernorValidator)
|
||||
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (MutateGovernor))
|
||||
import Agora.Governor.Scripts (governorValidator)
|
||||
import Agora.Proposal (ProposalId (..))
|
||||
import Plutus.V1.Ledger.Api (TxOutRef (..))
|
||||
import Sample.Effect.GovernorMutation (validContext)
|
||||
import Sample.Shared (defaultProposalThresholds, governor)
|
||||
import Plutus.V1.Ledger.Api (ScriptContext (ScriptContext), ScriptPurpose (Spending))
|
||||
import Sample.Effect.GovernorMutation (
|
||||
effectRef,
|
||||
govRef,
|
||||
invalidNewGovernorDatum,
|
||||
mkEffectDatum,
|
||||
mkEffectTransaction,
|
||||
validNewGovernorDatum,
|
||||
)
|
||||
import Sample.Shared qualified as Shared
|
||||
import Test.Tasty (TestTree, testGroup)
|
||||
import Test.Util (effectSucceedsWith)
|
||||
import Test.Util (effectFailsWith, effectSucceedsWith, validatorFailsWith, validatorSucceedsWith)
|
||||
|
||||
tests :: [TestTree]
|
||||
tests =
|
||||
[ testGroup
|
||||
"validator"
|
||||
[ effectSucceedsWith
|
||||
"Simple"
|
||||
(mutateGovernorValidator governor)
|
||||
( MutateGovernorDatum
|
||||
{ governorRef = TxOutRef "614481d2159bfb72350222d61fce17e548e0fc00e5a1f841ff1837c431346ce7" 1
|
||||
, newDatum =
|
||||
GovernorDatum
|
||||
{ nextProposalId = ProposalId 42
|
||||
, proposalThresholds = defaultProposalThresholds
|
||||
}
|
||||
}
|
||||
)
|
||||
validContext
|
||||
[ testGroup
|
||||
"valid new governor datum"
|
||||
[ validatorSucceedsWith
|
||||
"governor"
|
||||
(governorValidator Shared.governor)
|
||||
( GovernorDatum
|
||||
{ proposalThresholds = Shared.defaultProposalThresholds
|
||||
, nextProposalId = ProposalId 0
|
||||
}
|
||||
)
|
||||
MutateGovernor
|
||||
( ScriptContext
|
||||
(mkEffectTransaction validNewGovernorDatum)
|
||||
(Spending govRef)
|
||||
)
|
||||
, effectSucceedsWith
|
||||
"effect"
|
||||
(mutateGovernorValidator Shared.governor)
|
||||
(mkEffectDatum validNewGovernorDatum)
|
||||
(ScriptContext (mkEffectTransaction validNewGovernorDatum) (Spending effectRef))
|
||||
]
|
||||
, testGroup
|
||||
"invalid new governor datum"
|
||||
[ validatorFailsWith
|
||||
"governor"
|
||||
(governorValidator Shared.governor)
|
||||
( GovernorDatum
|
||||
{ proposalThresholds = Shared.defaultProposalThresholds
|
||||
, nextProposalId = ProposalId 0
|
||||
}
|
||||
)
|
||||
MutateGovernor
|
||||
( ScriptContext
|
||||
(mkEffectTransaction invalidNewGovernorDatum)
|
||||
(Spending govRef)
|
||||
)
|
||||
, effectFailsWith
|
||||
"effect"
|
||||
(mutateGovernorValidator Shared.governor)
|
||||
(mkEffectDatum validNewGovernorDatum)
|
||||
(ScriptContext (mkEffectTransaction invalidNewGovernorDatum) (Spending effectRef))
|
||||
]
|
||||
]
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue