merge #74; add sample and spec of the governor
This commit is contained in:
parent
628894cc1c
commit
0f36d649c6
16 changed files with 81 additions and 46 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
{- |
|
{- |
|
||||||
Module : Spec.Sample.Effect.TreasuryWithdrawalEffect
|
Module : Sample.Effect.TreasuryWithdrawalEffect
|
||||||
Maintainer : seungheon.ooh@gmail.com
|
Maintainer : seungheon.ooh@gmail.com
|
||||||
Description: Sample based testing for Treasury Withdrawal Effect
|
Description: Sample based testing for Treasury Withdrawal Effect
|
||||||
|
|
||||||
This module provides smaples for Treasury Withdrawal Effect tests.
|
This module provides samples for Treasury Withdrawal Effect tests.
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Effect.TreasuryWithdrawal (
|
module Sample.Effect.TreasuryWithdrawal (
|
||||||
inputTreasury,
|
inputTreasury,
|
||||||
inputUser,
|
inputUser,
|
||||||
inputGAT,
|
inputGAT,
|
||||||
|
|
@ -5,7 +5,7 @@ Description: Sample based testing for Governor utxos
|
||||||
|
|
||||||
This module tests primarily the happy path for Governor interactions
|
This module tests primarily the happy path for Governor interactions
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Governor (
|
module Sample.Governor (
|
||||||
createProposal,
|
createProposal,
|
||||||
mutateState,
|
mutateState,
|
||||||
mintGATs,
|
mintGATs,
|
||||||
|
|
@ -65,7 +65,7 @@ import Agora.Stake (
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Spec.Sample.Shared (
|
import Sample.Shared (
|
||||||
authorityTokenSymbol,
|
authorityTokenSymbol,
|
||||||
defaultProposalThresholds,
|
defaultProposalThresholds,
|
||||||
govAssetClass,
|
govAssetClass,
|
||||||
|
|
@ -81,7 +81,7 @@ import Spec.Sample.Shared (
|
||||||
stakeAddress,
|
stakeAddress,
|
||||||
stakeAssetClass,
|
stakeAssetClass,
|
||||||
)
|
)
|
||||||
import Spec.Util (datumPair, toDatumHash)
|
import Test.Util (datumPair, toDatumHash)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{- |
|
{- |
|
||||||
Module : Spec.Sample.Proposal
|
Module : Sample.Proposal
|
||||||
Maintainer : emi@haskell.fyi
|
Maintainer : emi@haskell.fyi
|
||||||
Description: Sample based testing for Proposal utxos
|
Description: Sample based testing for Proposal utxos
|
||||||
|
|
||||||
This module tests primarily the happy path for Proposal interactions
|
This module tests primarily the happy path for Proposal interactions
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Proposal (
|
module Sample.Proposal (
|
||||||
-- * Script contexts
|
-- * Script contexts
|
||||||
proposalCreation,
|
proposalCreation,
|
||||||
cosignProposal,
|
cosignProposal,
|
||||||
|
|
@ -49,8 +49,8 @@ import Agora.Proposal (
|
||||||
import Agora.Stake (Stake (..), StakeDatum (StakeDatum))
|
import Agora.Stake (Stake (..), StakeDatum (StakeDatum))
|
||||||
import Plutarch.SafeMoney (Tagged (Tagged), untag)
|
import Plutarch.SafeMoney (Tagged (Tagged), untag)
|
||||||
import PlutusTx.AssocMap qualified as AssocMap
|
import PlutusTx.AssocMap qualified as AssocMap
|
||||||
import Spec.Sample.Shared
|
import Sample.Shared
|
||||||
import Spec.Util (datumPair, toDatumHash)
|
import Test.Util (datumPair, toDatumHash)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{- |
|
{- |
|
||||||
Module : Spec.Sample.Shared
|
Module : Sample.Shared
|
||||||
Maintainer : emi@haskell.fyi
|
Maintainer : emi@haskell.fyi
|
||||||
Description: Shared useful values for creating Samples for testing.
|
Description: Shared useful values for creating Samples for testing.
|
||||||
|
|
||||||
Shared useful values for creating Samples for testing.
|
Shared useful values for creating Samples for testing.
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Shared (
|
module Sample.Shared (
|
||||||
-- * Misc
|
-- * Misc
|
||||||
signer,
|
signer,
|
||||||
signer2,
|
signer2,
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{- |
|
{- |
|
||||||
Module : Spec.Sample.Stake
|
Module : Sample.Stake
|
||||||
Maintainer : emi@haskell.fyi
|
Maintainer : emi@haskell.fyi
|
||||||
Description: Sample based testing for Stake utxos
|
Description: Sample based testing for Stake utxos
|
||||||
|
|
||||||
This module tests primarily the happy path for Stake creation
|
This module tests primarily the happy path for Stake creation
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Stake (
|
module Sample.Stake (
|
||||||
stake,
|
stake,
|
||||||
stakeAssetClass,
|
stakeAssetClass,
|
||||||
stakeSymbol,
|
stakeSymbol,
|
||||||
|
|
@ -49,8 +49,8 @@ import Agora.SafeMoney (GTTag)
|
||||||
import Agora.Stake
|
import Agora.Stake
|
||||||
import Agora.Stake.Scripts (stakeValidator)
|
import Agora.Stake.Scripts (stakeValidator)
|
||||||
import Plutarch.SafeMoney
|
import Plutarch.SafeMoney
|
||||||
import Spec.Sample.Shared
|
import Sample.Shared
|
||||||
import Spec.Util (datumPair, toDatumHash)
|
import Test.Util (datumPair, toDatumHash)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
{- |
|
{- |
|
||||||
Module: Spec.Sample.Treasury
|
Module: Sample.Treasury
|
||||||
Description: Sample data for `Spec.Treasury`.
|
Description: Sample data for `Spec.Treasury`.
|
||||||
Maintainer: jack@mlabs.city
|
Maintainer: jack@mlabs.city
|
||||||
|
|
||||||
This module contains sample data, used in the tests written in
|
This module contains sample data, used in the tests written in
|
||||||
`Spec.Treasury`.
|
`Spec.Treasury`.
|
||||||
-}
|
-}
|
||||||
module Spec.Sample.Treasury (
|
module Sample.Treasury (
|
||||||
gatCs,
|
gatCs,
|
||||||
validCtx,
|
validCtx,
|
||||||
treasuryRef,
|
treasuryRef,
|
||||||
|
|
@ -38,7 +38,7 @@ import Plutus.V1.Ledger.Scripts (
|
||||||
ValidatorHash (ValidatorHash),
|
ValidatorHash (ValidatorHash),
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
import Spec.Sample.Shared (
|
import Sample.Shared (
|
||||||
gatCs,
|
gatCs,
|
||||||
gatTn,
|
gatTn,
|
||||||
minAda,
|
minAda,
|
||||||
|
|
@ -47,7 +47,7 @@ import Spec.Sample.Shared (
|
||||||
treasuryOut,
|
treasuryOut,
|
||||||
wrongEffHash,
|
wrongEffHash,
|
||||||
)
|
)
|
||||||
import Spec.Util (datumPair)
|
import Test.Util (datumPair)
|
||||||
|
|
||||||
{- | A `ScriptContext` that should be compatible with treasury
|
{- | A `ScriptContext` that should be compatible with treasury
|
||||||
transactions.
|
transactions.
|
||||||
|
|
@ -13,6 +13,7 @@ import Spec.Model.MultiSig qualified as MultiSig
|
||||||
import Spec.Proposal qualified as Proposal
|
import Spec.Proposal qualified as Proposal
|
||||||
import Spec.Stake qualified as Stake
|
import Spec.Stake qualified as Stake
|
||||||
import Spec.Treasury qualified as Treasury
|
import Spec.Treasury qualified as Treasury
|
||||||
|
import Spec.Utils qualified as Utils
|
||||||
|
|
||||||
-- | The Agora test suite.
|
-- | The Agora test suite.
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
|
@ -44,6 +45,9 @@ main =
|
||||||
, testGroup
|
, testGroup
|
||||||
"Governor tests"
|
"Governor tests"
|
||||||
Governor.tests
|
Governor.tests
|
||||||
|
, testGroup
|
||||||
|
"Utility functions tests"
|
||||||
|
Utils.tests
|
||||||
, testGroup
|
, testGroup
|
||||||
"Multisig tests"
|
"Multisig tests"
|
||||||
[ testGroup
|
[ testGroup
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import Plutus.V1.Ledger.Api (
|
||||||
import Plutus.V1.Ledger.Interval qualified as Interval
|
import Plutus.V1.Ledger.Interval qualified as Interval
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
import PlutusTx.AssocMap qualified as AssocMap
|
import PlutusTx.AssocMap qualified as AssocMap
|
||||||
import Spec.Util (scriptFails, scriptSucceeds)
|
import Test.Util (scriptFails, scriptSucceeds)
|
||||||
|
|
||||||
currencySymbol :: CurrencySymbol
|
currencySymbol :: CurrencySymbol
|
||||||
currencySymbol = "deadbeef"
|
currencySymbol = "deadbeef"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import Agora.Effect.TreasuryWithdrawal (
|
||||||
treasuryWithdrawalValidator,
|
treasuryWithdrawalValidator,
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
import Spec.Sample.Effect.TreasuryWithdrawal (
|
import Sample.Effect.TreasuryWithdrawal (
|
||||||
buildReceiversOutputFromDatum,
|
buildReceiversOutputFromDatum,
|
||||||
buildScriptContext,
|
buildScriptContext,
|
||||||
currSymbol,
|
currSymbol,
|
||||||
|
|
@ -25,8 +25,8 @@ import Spec.Sample.Effect.TreasuryWithdrawal (
|
||||||
treasuries,
|
treasuries,
|
||||||
users,
|
users,
|
||||||
)
|
)
|
||||||
import Spec.Util (effectFailsWith, effectSucceedsWith)
|
|
||||||
import Test.Tasty (TestTree, testGroup)
|
import Test.Tasty (TestTree, testGroup)
|
||||||
|
import Test.Util (effectFailsWith, effectSucceedsWith)
|
||||||
|
|
||||||
tests :: [TestTree]
|
tests :: [TestTree]
|
||||||
tests =
|
tests =
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ module Spec.Governor (tests) where
|
||||||
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (..))
|
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (..))
|
||||||
import Agora.Governor.Scripts (governorPolicy, governorValidator)
|
import Agora.Governor.Scripts (governorPolicy, governorValidator)
|
||||||
import Agora.Proposal (ProposalId (..))
|
import Agora.Proposal (ProposalId (..))
|
||||||
import Spec.Sample.Governor (createProposal, mintGATs, mintGST, mutateState)
|
import Sample.Governor (createProposal, mintGATs, mintGST, mutateState)
|
||||||
import Spec.Sample.Shared qualified as Shared
|
import Sample.Shared qualified as Shared
|
||||||
import Spec.Util (policySucceedsWith, validatorSucceedsWith)
|
|
||||||
import Test.Tasty (TestTree, testGroup)
|
import Test.Tasty (TestTree, testGroup)
|
||||||
|
import Test.Util (policySucceedsWith, validatorSucceedsWith)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ import Agora.Stake.Scripts (stakeValidator)
|
||||||
import Plutarch.SafeMoney (Tagged (Tagged))
|
import Plutarch.SafeMoney (Tagged (Tagged))
|
||||||
import Plutus.V1.Ledger.Api (ScriptContext (..), ScriptPurpose (..))
|
import Plutus.V1.Ledger.Api (ScriptContext (..), ScriptPurpose (..))
|
||||||
import PlutusTx.AssocMap qualified as AssocMap
|
import PlutusTx.AssocMap qualified as AssocMap
|
||||||
import Spec.Sample.Proposal qualified as Proposal
|
import Sample.Proposal qualified as Proposal
|
||||||
import Spec.Sample.Shared (signer, signer2)
|
import Sample.Shared (signer, signer2)
|
||||||
import Spec.Sample.Shared qualified as Shared
|
import Sample.Shared qualified as Shared
|
||||||
import Spec.Util (policySucceedsWith, validatorSucceedsWith)
|
|
||||||
import Test.Tasty (TestTree, testGroup)
|
import Test.Tasty (TestTree, testGroup)
|
||||||
|
import Test.Util (policySucceedsWith, validatorSucceedsWith)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import Agora.Stake.Scripts (stakePolicy, stakeValidator)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Spec.Sample.Stake (DepositWithdrawExample (DepositWithdrawExample, delta, startAmount), signer)
|
import Sample.Stake (DepositWithdrawExample (DepositWithdrawExample, delta, startAmount), signer)
|
||||||
import Spec.Sample.Stake qualified as Stake
|
import Sample.Stake qualified as Stake
|
||||||
import Spec.Util (policyFailsWith, policySucceedsWith, toDatum, validatorFailsWith, validatorSucceedsWith)
|
import Test.Util (policyFailsWith, policySucceedsWith, toDatum, validatorFailsWith, validatorSucceedsWith)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ import Plutus.V1.Ledger.Credential (
|
||||||
StakingCredential (StakingHash),
|
StakingCredential (StakingHash),
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
import Spec.Sample.Shared (
|
import Sample.Shared (
|
||||||
trCredential,
|
trCredential,
|
||||||
)
|
)
|
||||||
import Spec.Sample.Treasury (
|
import Sample.Treasury (
|
||||||
gatCs,
|
gatCs,
|
||||||
gatTn,
|
gatTn,
|
||||||
trCtxGATNameNotAddress,
|
trCtxGATNameNotAddress,
|
||||||
|
|
@ -48,8 +48,8 @@ import Spec.Sample.Treasury (
|
||||||
validCtx,
|
validCtx,
|
||||||
walletIn,
|
walletIn,
|
||||||
)
|
)
|
||||||
import Spec.Util (validatorFailsWith, validatorSucceedsWith)
|
|
||||||
import Test.Tasty (TestTree, testGroup)
|
import Test.Tasty (TestTree, testGroup)
|
||||||
|
import Test.Util (validatorFailsWith, validatorSucceedsWith)
|
||||||
|
|
||||||
tests :: [TestTree]
|
tests :: [TestTree]
|
||||||
tests =
|
tests =
|
||||||
|
|
|
||||||
13
agora-test/Spec/Utils.hs
Normal file
13
agora-test/Spec/Utils.hs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{- |
|
||||||
|
Module : Spec.Utils
|
||||||
|
Maintainer : emi@haskell.fyi
|
||||||
|
Description: Tests for utility functions in 'Agora.Utils'.
|
||||||
|
|
||||||
|
Tests for utility functions in 'Agora.Utils'.
|
||||||
|
-}
|
||||||
|
module Spec.Utils (tests) where
|
||||||
|
|
||||||
|
import Test.Tasty (TestTree)
|
||||||
|
|
||||||
|
tests :: [TestTree]
|
||||||
|
tests = []
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{- |
|
{- |
|
||||||
Module : Spec.Util
|
Module : Test.Util
|
||||||
Maintainer : emi@haskell.fyi
|
Maintainer : emi@haskell.fyi
|
||||||
Description: Utility functions for testing Plutarch scripts with ScriptContext
|
Description: Utility functions for testing Plutarch scripts with ScriptContext
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ Utility functions for testing Plutarch scripts with ScriptContext:
|
||||||
|
|
||||||
- 'scriptFails': checks that an arbitrary script `perror`s out.
|
- 'scriptFails': checks that an arbitrary script `perror`s out.
|
||||||
-}
|
-}
|
||||||
module Spec.Util (
|
module Test.Util (
|
||||||
-- * Testing utils
|
-- * Testing utils
|
||||||
scriptSucceeds,
|
scriptSucceeds,
|
||||||
scriptFails,
|
scriptFails,
|
||||||
34
agora.cabal
34
agora.cabal
|
|
@ -153,6 +153,27 @@ library pprelude
|
||||||
hs-source-dirs: agora
|
hs-source-dirs: agora
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
library agora-testlib
|
||||||
|
import: lang, deps, test-deps
|
||||||
|
exposed-modules: Test.Util
|
||||||
|
hs-source-dirs: agora-testlib
|
||||||
|
|
||||||
|
library agora-sample
|
||||||
|
import: lang, deps, test-deps
|
||||||
|
build-depends:
|
||||||
|
, agora
|
||||||
|
, agora-testlib
|
||||||
|
|
||||||
|
exposed-modules:
|
||||||
|
Sample.Effect.TreasuryWithdrawal
|
||||||
|
Sample.Governor
|
||||||
|
Sample.Proposal
|
||||||
|
Sample.Shared
|
||||||
|
Sample.Stake
|
||||||
|
Sample.Treasury
|
||||||
|
|
||||||
|
hs-source-dirs: agora-sample
|
||||||
|
|
||||||
test-suite agora-test
|
test-suite agora-test
|
||||||
import: lang, deps, test-deps
|
import: lang, deps, test-deps
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
|
|
@ -164,17 +185,14 @@ test-suite agora-test
|
||||||
Spec.Governor
|
Spec.Governor
|
||||||
Spec.Model.MultiSig
|
Spec.Model.MultiSig
|
||||||
Spec.Proposal
|
Spec.Proposal
|
||||||
Spec.Sample.Effect.TreasuryWithdrawal
|
|
||||||
Spec.Sample.Governor
|
|
||||||
Spec.Sample.Proposal
|
|
||||||
Spec.Sample.Shared
|
|
||||||
Spec.Sample.Stake
|
|
||||||
Spec.Sample.Treasury
|
|
||||||
Spec.Stake
|
Spec.Stake
|
||||||
Spec.Treasury
|
Spec.Treasury
|
||||||
Spec.Util
|
Spec.Utils
|
||||||
|
|
||||||
build-depends: agora
|
build-depends:
|
||||||
|
, agora
|
||||||
|
, agora-sample
|
||||||
|
, agora-testlib
|
||||||
|
|
||||||
benchmark agora-bench
|
benchmark agora-bench
|
||||||
import: lang, deps
|
import: lang, deps
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue