speed up test execution by precompiling scripts

x250 faster!
This commit is contained in:
Hongrui Fang 2022-08-10 17:38:21 +08:00
parent 3d9c447783
commit b6a30b9ea9
18 changed files with 299 additions and 282 deletions

View file

@ -19,16 +19,20 @@ module Sample.Governor.Initialize (
mkTestCase,
) where
import Agora.Bootstrap (agoraScripts)
import Agora.Governor (Governor (..), GovernorDatum (..))
import Agora.Governor.Scripts (
governorPolicy,
governorSTAssetClassFromGovernor,
import Agora.Proposal (ProposalId (..), ProposalThresholds (..))
import Agora.Proposal.Time (
MaxTimeRangeWidth (MaxTimeRangeWidth),
ProposalTimingConfig (ProposalTimingConfig),
)
import Agora.Scripts (
AgoraScripts (compiledGovernorPolicy),
governorSTAssetClass,
governorSTSymbol,
governorValidatorHash,
)
import Agora.Proposal (ProposalId (..), ProposalThresholds (..))
import Agora.Proposal.Time (MaxTimeRangeWidth (MaxTimeRangeWidth), ProposalTimingConfig (ProposalTimingConfig))
import Data.Default (Default (..))
import Plutarch.Api.V1 (mintingPolicySymbol, mkMintingPolicy)
import Plutarch.Context (
input,
mint,
@ -43,7 +47,6 @@ import Plutarch.Context (
)
import PlutusLedgerApi.V1 (
CurrencySymbol,
MintingPolicy,
TxOutRef (TxOutRef),
ValidatorHash,
)
@ -107,17 +110,17 @@ governor =
{ gstOutRef = witnessRef
}
scripts :: AgoraScripts
scripts = agoraScripts Shared.deterministicTracingConfing governor
govAssetClass :: AssetClass
govAssetClass = governorSTAssetClassFromGovernor governor
govAssetClass = governorSTAssetClass scripts
govValidatorHash :: ValidatorHash
govValidatorHash = governorValidatorHash governor
govPolicy :: MintingPolicy
govPolicy = mkMintingPolicy def (governorPolicy governor)
govValidatorHash = governorValidatorHash scripts
govSymbol :: CurrencySymbol
govSymbol = mintingPolicySymbol govPolicy
govSymbol = governorSTSymbol scripts
--------------------------------------------------------------------------------
@ -271,6 +274,6 @@ mkTestCase name ps valid =
testPolicy
valid
name
(governorPolicy governor)
scripts.compiledGovernorPolicy
()
(mkMinting mintGST ps govSymbol)

View file

@ -18,8 +18,8 @@ module Sample.Governor.Mutate (
import Agora.Effect.NoOp (noOpValidator)
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (MutateGovernor))
import Agora.Governor.Scripts (governorValidator)
import Agora.Proposal (ProposalId (ProposalId), ProposalThresholds (..))
import Agora.Scripts (AgoraScripts (..))
import Agora.Utils (validatorHashToTokenName)
import Data.Default (def)
import Plutarch.Api.V1 (PValidator, mkValidator, validatorHash)
@ -42,10 +42,10 @@ import PlutusLedgerApi.V1 (
)
import PlutusLedgerApi.V1.Value qualified as Value
import Sample.Shared (
agoraScripts,
authorityTokenSymbol,
govAssetClass,
govValidatorHash,
governor,
minAda,
)
import Test.Specification (SpecificationTree, testValidator)
@ -219,7 +219,7 @@ mkTestCase name pb (Validity forGov) =
testValidator
forGov
name
(governorValidator governor)
agoraScripts.compiledGovernorValidator
governorInputDatum
governorRedeemer
(mkSpending mutate pb governorRef)