Applied Emily's suggestions
This commit is contained in:
parent
cddc6e8adf
commit
cb0f61eb2c
4 changed files with 36 additions and 42 deletions
|
|
@ -39,6 +39,7 @@ module Spec.Sample.Shared (
|
|||
gatCs,
|
||||
mockTrEffect,
|
||||
trCredential,
|
||||
wrongEffHash,
|
||||
) where
|
||||
|
||||
import Agora.Effect.NoOp (noOpValidator)
|
||||
|
|
@ -77,7 +78,7 @@ import Plutus.V1.Ledger.Api (
|
|||
import Plutus.V1.Ledger.Contexts (
|
||||
TxOut (..),
|
||||
)
|
||||
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash)
|
||||
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash (..))
|
||||
import Plutus.V1.Ledger.Value (TokenName, Value)
|
||||
import Plutus.V1.Ledger.Value qualified as Value
|
||||
|
||||
|
|
@ -179,6 +180,14 @@ gatTn = validatorHashToTokenName $ validatorHash mockTrEffect
|
|||
mockTrEffect :: Validator
|
||||
mockTrEffect = mkValidator $ noOpValidator gatCs
|
||||
|
||||
{- | A SHA-256 hash which (in all certainty) should not match the
|
||||
hash of the dummy effect script.
|
||||
-}
|
||||
wrongEffHash :: ValidatorHash
|
||||
wrongEffHash =
|
||||
ValidatorHash
|
||||
"a21bc4a1d95600f9fa0a00b97ed0fa49a152a72de76253cb706f90b4b40f837b"
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
minAda :: Value
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ module Spec.Sample.Treasury (
|
|||
treasuryRef,
|
||||
gatTn,
|
||||
walletIn,
|
||||
trCtxGATNameNotAddress,
|
||||
) where
|
||||
|
||||
import Plutarch.Api.V1 (validatorHash)
|
||||
|
|
@ -44,6 +45,7 @@ import Spec.Sample.Shared (
|
|||
signer,
|
||||
treasuryOut,
|
||||
withMinAda,
|
||||
wrongEffHash,
|
||||
)
|
||||
import Spec.Util (datumPair)
|
||||
|
||||
|
|
@ -133,3 +135,25 @@ walletIn =
|
|||
|
||||
addressBs :: BuiltinByteString
|
||||
(ValidatorHash addressBs) = validatorHash mockTrEffect
|
||||
|
||||
trCtxGATNameNotAddress :: ScriptContext
|
||||
trCtxGATNameNotAddress =
|
||||
let txInfo = validCtx.scriptContextTxInfo
|
||||
inputs = txInfo.txInfoInputs
|
||||
effectIn = inputs !! 1
|
||||
invalidEff =
|
||||
effectIn
|
||||
{ txInInfoResolved =
|
||||
effectIn.txInInfoResolved
|
||||
{ txOutAddress = Address (ScriptCredential wrongEffHash) Nothing
|
||||
}
|
||||
}
|
||||
in validCtx
|
||||
{ scriptContextTxInfo =
|
||||
txInfo
|
||||
{ txInfoInputs =
|
||||
[ head inputs
|
||||
, invalidEff
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,25 +25,17 @@ import Agora.Treasury (
|
|||
TreasuryRedeemer (SpendTreasuryGAT),
|
||||
treasuryValidator,
|
||||
)
|
||||
import Plutus.V1.Ledger.Address (Address (Address))
|
||||
import Plutus.V1.Ledger.Api (
|
||||
BuiltinByteString,
|
||||
DCert (DCertDelegRegKey),
|
||||
)
|
||||
import Plutus.V1.Ledger.Contexts (
|
||||
ScriptContext (scriptContextPurpose, scriptContextTxInfo),
|
||||
ScriptPurpose (Certifying, Rewarding, Spending),
|
||||
TxInfo (txInfoInputs, txInfoMint),
|
||||
txInInfoResolved,
|
||||
txOutAddress,
|
||||
)
|
||||
import Plutus.V1.Ledger.Credential (
|
||||
Credential (ScriptCredential),
|
||||
StakingCredential (StakingHash),
|
||||
)
|
||||
import Plutus.V1.Ledger.Scripts (
|
||||
ValidatorHash (ValidatorHash),
|
||||
)
|
||||
import Plutus.V1.Ledger.Value qualified as Value
|
||||
import Spec.Sample.Shared (
|
||||
trCredential,
|
||||
|
|
@ -51,6 +43,7 @@ import Spec.Sample.Shared (
|
|||
import Spec.Sample.Treasury (
|
||||
gatCs,
|
||||
gatTn,
|
||||
trCtxGATNameNotAddress,
|
||||
treasuryRef,
|
||||
validCtx,
|
||||
walletIn,
|
||||
|
|
@ -125,32 +118,7 @@ tests =
|
|||
(treasuryValidator gatCs)
|
||||
()
|
||||
SpendTreasuryGAT
|
||||
( let txInfo = validCtx.scriptContextTxInfo
|
||||
inputs = txInfo.txInfoInputs
|
||||
effectIn = inputs !! 1
|
||||
invalidEff =
|
||||
effectIn
|
||||
{ txInInfoResolved =
|
||||
effectIn.txInInfoResolved
|
||||
{ txOutAddress =
|
||||
Address
|
||||
( ScriptCredential $
|
||||
ValidatorHash
|
||||
wrongHash
|
||||
)
|
||||
Nothing
|
||||
}
|
||||
}
|
||||
in validCtx
|
||||
{ scriptContextTxInfo =
|
||||
txInfo
|
||||
{ txInfoInputs =
|
||||
[ head inputs
|
||||
, invalidEff
|
||||
]
|
||||
}
|
||||
}
|
||||
)
|
||||
trCtxGATNameNotAddress
|
||||
, validatorFailsWith
|
||||
"Fails with wallet as input"
|
||||
(treasuryValidator gatCs)
|
||||
|
|
@ -172,9 +140,3 @@ tests =
|
|||
]
|
||||
]
|
||||
]
|
||||
|
||||
{- | A SHA-256 hash which (in all certainty) should not match the
|
||||
hash of the dummy effect script.
|
||||
-}
|
||||
wrongHash :: BuiltinByteString
|
||||
wrongHash = "a21bc4a1d95600f9fa0a00b97ed0fa49a152a72de76253cb706f90b4b40f837b"
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ common test-deps
|
|||
, agora
|
||||
, apropos
|
||||
, apropos-tx
|
||||
, lens
|
||||
, QuickCheck
|
||||
, quickcheck-instances
|
||||
, tasty
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue