Applied Emily's suggestions
This commit is contained in:
parent
a59ffb221d
commit
a8bb884eab
4 changed files with 36 additions and 42 deletions
|
|
@ -39,6 +39,7 @@ module Spec.Sample.Shared (
|
||||||
gatCs,
|
gatCs,
|
||||||
mockTrEffect,
|
mockTrEffect,
|
||||||
trCredential,
|
trCredential,
|
||||||
|
wrongEffHash,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Agora.Effect.NoOp (noOpValidator)
|
import Agora.Effect.NoOp (noOpValidator)
|
||||||
|
|
@ -77,7 +78,7 @@ import Plutus.V1.Ledger.Api (
|
||||||
import Plutus.V1.Ledger.Contexts (
|
import Plutus.V1.Ledger.Contexts (
|
||||||
TxOut (..),
|
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 (TokenName, Value)
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
|
|
||||||
|
|
@ -179,6 +180,14 @@ gatTn = validatorHashToTokenName $ validatorHash mockTrEffect
|
||||||
mockTrEffect :: Validator
|
mockTrEffect :: Validator
|
||||||
mockTrEffect = mkValidator $ noOpValidator gatCs
|
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
|
minAda :: Value
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ module Spec.Sample.Treasury (
|
||||||
treasuryRef,
|
treasuryRef,
|
||||||
gatTn,
|
gatTn,
|
||||||
walletIn,
|
walletIn,
|
||||||
|
trCtxGATNameNotAddress,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Plutarch.Api.V1 (validatorHash)
|
import Plutarch.Api.V1 (validatorHash)
|
||||||
|
|
@ -44,6 +45,7 @@ import Spec.Sample.Shared (
|
||||||
signer,
|
signer,
|
||||||
treasuryOut,
|
treasuryOut,
|
||||||
withMinAda,
|
withMinAda,
|
||||||
|
wrongEffHash,
|
||||||
)
|
)
|
||||||
import Spec.Util (datumPair)
|
import Spec.Util (datumPair)
|
||||||
|
|
||||||
|
|
@ -133,3 +135,25 @@ walletIn =
|
||||||
|
|
||||||
addressBs :: BuiltinByteString
|
addressBs :: BuiltinByteString
|
||||||
(ValidatorHash addressBs) = validatorHash mockTrEffect
|
(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),
|
TreasuryRedeemer (SpendTreasuryGAT),
|
||||||
treasuryValidator,
|
treasuryValidator,
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Address (Address (Address))
|
|
||||||
import Plutus.V1.Ledger.Api (
|
import Plutus.V1.Ledger.Api (
|
||||||
BuiltinByteString,
|
|
||||||
DCert (DCertDelegRegKey),
|
DCert (DCertDelegRegKey),
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Contexts (
|
import Plutus.V1.Ledger.Contexts (
|
||||||
ScriptContext (scriptContextPurpose, scriptContextTxInfo),
|
ScriptContext (scriptContextPurpose, scriptContextTxInfo),
|
||||||
ScriptPurpose (Certifying, Rewarding, Spending),
|
ScriptPurpose (Certifying, Rewarding, Spending),
|
||||||
TxInfo (txInfoInputs, txInfoMint),
|
TxInfo (txInfoInputs, txInfoMint),
|
||||||
txInInfoResolved,
|
|
||||||
txOutAddress,
|
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Credential (
|
import Plutus.V1.Ledger.Credential (
|
||||||
Credential (ScriptCredential),
|
|
||||||
StakingCredential (StakingHash),
|
StakingCredential (StakingHash),
|
||||||
)
|
)
|
||||||
import Plutus.V1.Ledger.Scripts (
|
|
||||||
ValidatorHash (ValidatorHash),
|
|
||||||
)
|
|
||||||
import Plutus.V1.Ledger.Value qualified as Value
|
import Plutus.V1.Ledger.Value qualified as Value
|
||||||
import Spec.Sample.Shared (
|
import Spec.Sample.Shared (
|
||||||
trCredential,
|
trCredential,
|
||||||
|
|
@ -51,6 +43,7 @@ import Spec.Sample.Shared (
|
||||||
import Spec.Sample.Treasury (
|
import Spec.Sample.Treasury (
|
||||||
gatCs,
|
gatCs,
|
||||||
gatTn,
|
gatTn,
|
||||||
|
trCtxGATNameNotAddress,
|
||||||
treasuryRef,
|
treasuryRef,
|
||||||
validCtx,
|
validCtx,
|
||||||
walletIn,
|
walletIn,
|
||||||
|
|
@ -125,32 +118,7 @@ tests =
|
||||||
(treasuryValidator gatCs)
|
(treasuryValidator gatCs)
|
||||||
()
|
()
|
||||||
SpendTreasuryGAT
|
SpendTreasuryGAT
|
||||||
( let txInfo = validCtx.scriptContextTxInfo
|
trCtxGATNameNotAddress
|
||||||
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
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
, validatorFailsWith
|
, validatorFailsWith
|
||||||
"Fails with wallet as input"
|
"Fails with wallet as input"
|
||||||
(treasuryValidator gatCs)
|
(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
|
, agora
|
||||||
, apropos
|
, apropos
|
||||||
, apropos-tx
|
, apropos-tx
|
||||||
, lens
|
|
||||||
, QuickCheck
|
, QuickCheck
|
||||||
, quickcheck-instances
|
, quickcheck-instances
|
||||||
, tasty
|
, tasty
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue