94 lines
2.9 KiB
Haskell
94 lines
2.9 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
{- |
|
|
Module : Spec.Proposal
|
|
Maintainer : emi@haskell.fyi
|
|
Description: Tests for Proposal policy and validator
|
|
|
|
Tests for Proposal policy and validator
|
|
-}
|
|
module Spec.Proposal (tests) where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Agora.Proposal (
|
|
Proposal (..),
|
|
ProposalDatum (..),
|
|
ProposalId (ProposalId),
|
|
ProposalRedeemer (Cosign),
|
|
ProposalStatus (Draft),
|
|
ResultTag (ResultTag),
|
|
cosigners,
|
|
effects,
|
|
emptyVotesFor,
|
|
proposalId,
|
|
status,
|
|
thresholds,
|
|
votes,
|
|
)
|
|
import Agora.Proposal.Scripts (
|
|
proposalPolicy,
|
|
proposalValidator,
|
|
)
|
|
import Agora.Stake (StakeDatum (StakeDatum), StakeRedeemer (WitnessStake))
|
|
import Agora.Stake.Scripts (stakeValidator)
|
|
import Plutarch.SafeMoney (Tagged (Tagged))
|
|
import Plutus.V1.Ledger.Api (ScriptContext (..), ScriptPurpose (..))
|
|
import PlutusTx.AssocMap qualified as AssocMap
|
|
import Sample.Proposal qualified as Proposal
|
|
import Sample.Shared (signer, signer2)
|
|
import Sample.Shared qualified as Shared
|
|
import Test.Tasty (TestTree, testGroup)
|
|
import Test.Util (policySucceedsWith, validatorSucceedsWith)
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | Stake tests.
|
|
tests :: [TestTree]
|
|
tests =
|
|
[ testGroup
|
|
"policy"
|
|
[ policySucceedsWith
|
|
"proposalCreation"
|
|
(proposalPolicy Shared.proposal.governorSTAssetClass)
|
|
()
|
|
Proposal.proposalCreation
|
|
]
|
|
, testGroup
|
|
"validator"
|
|
[ testGroup
|
|
"cosignature"
|
|
[ validatorSucceedsWith
|
|
"proposal"
|
|
(proposalValidator Shared.proposal)
|
|
( ProposalDatum
|
|
{ proposalId = ProposalId 0
|
|
, effects =
|
|
AssocMap.fromList
|
|
[ (ResultTag 0, AssocMap.empty)
|
|
, (ResultTag 1, AssocMap.empty)
|
|
]
|
|
, status = Draft
|
|
, cosigners = [signer]
|
|
, thresholds = Shared.defaultProposalThresholds
|
|
, votes =
|
|
emptyVotesFor $
|
|
AssocMap.fromList
|
|
[ (ResultTag 0, AssocMap.empty)
|
|
, (ResultTag 1, AssocMap.empty)
|
|
]
|
|
, timingConfig = Shared.proposalTimingConfig
|
|
, startingTime = Shared.tmpProposalStartingTime
|
|
}
|
|
)
|
|
(Cosign [signer2])
|
|
(ScriptContext (Proposal.cosignProposal [signer2]) (Spending Proposal.proposalRef))
|
|
, validatorSucceedsWith
|
|
"stake"
|
|
(stakeValidator Shared.stake)
|
|
(StakeDatum (Tagged 50_000_000) signer2 [])
|
|
WitnessStake
|
|
(ScriptContext (Proposal.cosignProposal [signer2]) (Spending Proposal.stakeRef))
|
|
]
|
|
]
|
|
]
|