apply Emily's suggestions

* add `PMaxTimeRangeWidth`
* several `Default` instances for testing
* a bunch of docstrings
* fix the tests/samples
This commit is contained in:
fanghr 2022-05-25 21:07:09 +08:00
parent c6c93f587a
commit 6f9de51541
12 changed files with 142 additions and 75 deletions

View file

@ -4,6 +4,7 @@ import Agora.Effect.GovernorMutation (mutateGovernorValidator)
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (MutateGovernor))
import Agora.Governor.Scripts (governorValidator)
import Agora.Proposal (ProposalId (..))
import Data.Default.Class (Default (def))
import Plutus.V1.Ledger.Api (ScriptContext (ScriptContext), ScriptPurpose (Spending))
import Sample.Effect.GovernorMutation (
effectRef,
@ -29,8 +30,8 @@ tests =
( GovernorDatum
Shared.defaultProposalThresholds
(ProposalId 0)
Shared.defaultProposalTimingConfig
Shared.defaultCreateProposalTimeRangeMaxDuration
def
def
)
MutateGovernor
( ScriptContext
@ -51,8 +52,8 @@ tests =
( GovernorDatum
Shared.defaultProposalThresholds
(ProposalId 0)
Shared.defaultProposalTimingConfig
Shared.defaultCreateProposalTimeRangeMaxDuration
def
def
)
MutateGovernor
( ScriptContext

View file

@ -16,6 +16,7 @@ module Spec.Governor (tests) where
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (..))
import Agora.Governor.Scripts (governorPolicy, governorValidator)
import Agora.Proposal (ProposalId (..))
import Data.Default.Class (Default (def))
import Sample.Governor (createProposal, mintGATs, mintGST, mutateState)
import Sample.Shared qualified as Shared
import Test.Tasty (TestTree, testGroup)
@ -41,8 +42,8 @@ tests =
( GovernorDatum
Shared.defaultProposalThresholds
(ProposalId 0)
Shared.defaultProposalTimingConfig
Shared.defaultCreateProposalTimeRangeMaxDuration
def
def
)
CreateProposal
createProposal
@ -52,8 +53,8 @@ tests =
( GovernorDatum
Shared.defaultProposalThresholds
(ProposalId 5)
Shared.defaultProposalTimingConfig
Shared.defaultCreateProposalTimeRangeMaxDuration
def
def
)
MintGATs
mintGATs
@ -63,8 +64,8 @@ tests =
( GovernorDatum
Shared.defaultProposalThresholds
(ProposalId 5)
Shared.defaultProposalTimingConfig
Shared.defaultCreateProposalTimeRangeMaxDuration
def
def
)
MutateGovernor
mutateState

View file

@ -38,6 +38,7 @@ import Agora.Stake (
StakeRedeemer (PermitVote, WitnessStake),
)
import Agora.Stake.Scripts (stakeValidator)
import Data.Default.Class (Default (def))
import Plutarch.SafeMoney (Tagged (Tagged))
import Plutus.V1.Ledger.Api (ScriptContext (..), ScriptPurpose (..))
import PlutusTx.AssocMap qualified as AssocMap
@ -83,7 +84,7 @@ tests =
[ (ResultTag 0, AssocMap.empty)
, (ResultTag 1, AssocMap.empty)
]
, timingConfig = Shared.defaultProposalTimingConfig
, timingConfig = def
, startingTime = ProposalStartingTime 0
}
)
@ -118,7 +119,7 @@ tests =
, (ResultTag 1, 4242)
]
)
, timingConfig = Shared.defaultProposalTimingConfig
, timingConfig = def
, startingTime = ProposalStartingTime 0
}
)