fix broken tests

This commit is contained in:
fanghr 2022-04-30 19:24:01 +08:00
parent 1387cd19df
commit 89dd30b1d8
3 changed files with 14 additions and 6 deletions

View file

@ -193,7 +193,7 @@ cosignProposal newSigners =
mconcat mconcat
[ Value.singleton "" "" 10_000_000 [ Value.singleton "" "" 10_000_000
, Value.assetClassValue (untag stake.gtClassRef) 50_000_000 , Value.assetClassValue (untag stake.gtClassRef) 50_000_000
, Value.singleton stakeSymbol "" 1 , Value.assetClassValue stakeAssetClass 1
] ]
, txOutDatumHash = Just (toDatumHash stakeDatum) , txOutDatumHash = Just (toDatumHash stakeDatum)
} }
@ -214,7 +214,7 @@ cosignProposal newSigners =
mconcat mconcat
[ Value.singleton "" "" 10_000_000 [ Value.singleton "" "" 10_000_000
, Value.assetClassValue (untag stake.gtClassRef) 50_000_000 , Value.assetClassValue (untag stake.gtClassRef) 50_000_000
, Value.singleton stakeSymbol "" 1 , Value.assetClassValue stakeAssetClass 1
] ]
, txOutDatumHash = Just (toDatumHash stakeDatum) , txOutDatumHash = Just (toDatumHash stakeDatum)
} }

View file

@ -14,9 +14,10 @@ module Spec.Sample.Shared (
-- ** Stake -- ** Stake
stake, stake,
stakeSymbol, stakeAssetClass,
stakeValidatorHash, stakeValidatorHash,
stakeAddress, stakeAddress,
stakeSymbol,
-- ** Governor -- ** Governor
governor, governor,
@ -42,6 +43,7 @@ import Agora.Governor.Scripts (
proposalSTSymbolFromGovernor, proposalSTSymbolFromGovernor,
proposalValidatorHashFromGovernor, proposalValidatorHashFromGovernor,
stakeFromGovernor, stakeFromGovernor,
stakeSTAssetClassFromGovernor,
stakeSTSymbolFromGovernor, stakeSTSymbolFromGovernor,
stakeValidatorHashFromGovernor, stakeValidatorHashFromGovernor,
) )
@ -66,6 +68,7 @@ import Plutus.V1.Ledger.Api (
TxOutRef (TxOutRef), TxOutRef (TxOutRef),
) )
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash) import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash)
import Plutus.V1.Ledger.Value (AssetClass)
import Plutus.V1.Ledger.Value qualified as Value import Plutus.V1.Ledger.Value qualified as Value
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -76,6 +79,9 @@ stake = stakeFromGovernor governor
stakeSymbol :: CurrencySymbol stakeSymbol :: CurrencySymbol
stakeSymbol = stakeSTSymbolFromGovernor governor stakeSymbol = stakeSTSymbolFromGovernor governor
stakeAssetClass :: AssetClass
stakeAssetClass = stakeSTAssetClassFromGovernor governor
stakeValidatorHash :: ValidatorHash stakeValidatorHash :: ValidatorHash
stakeValidatorHash = stakeValidatorHashFromGovernor governor stakeValidatorHash = stakeValidatorHashFromGovernor governor
@ -85,7 +91,8 @@ stakeAddress = Address (ScriptCredential stakeValidatorHash) Nothing
governor :: Governor governor :: Governor
governor = Governor oref gt mc governor = Governor oref gt mc
where where
oref = TxOutRef "f28cd7145c24e66fd5bcd2796837aeb19a48a2656e7833c88c62a2d0450bd00d" 0 oref =
TxOutRef "f28cd7145c24e66fd5bcd2796837aeb19a48a2656e7833c88c62a2d0450bd00d" 0
gt = gt =
Tagged $ Tagged $
Value.assetClass Value.assetClass

View file

@ -7,6 +7,7 @@ This module tests primarily the happy path for Stake creation
-} -}
module Spec.Sample.Stake ( module Spec.Sample.Stake (
stake, stake,
stakeAssetClass,
stakeSymbol, stakeSymbol,
validatorHashTN, validatorHashTN,
signer, signer,
@ -60,7 +61,7 @@ validatorHashTN = let ValidatorHash vh = validatorHash (mkValidator $ stakeValid
-- | This script context should be a valid transaction. -- | This script context should be a valid transaction.
stakeCreation :: ScriptContext stakeCreation :: ScriptContext
stakeCreation = stakeCreation =
let st = Value.singleton stakeSymbol validatorHashTN 1 -- Stake ST let st = Value.assetClassValue stakeAssetClass 1 -- Stake ST
datum :: Datum datum :: Datum
datum = Datum (toBuiltinData $ StakeDatum 424242424242 signer []) datum = Datum (toBuiltinData $ StakeDatum 424242424242 signer [])
in ScriptContext in ScriptContext
@ -120,7 +121,7 @@ data DepositWithdrawExample = DepositWithdrawExample
-- | Create a ScriptContext that deposits or withdraws, given the config for it. -- | Create a ScriptContext that deposits or withdraws, given the config for it.
stakeDepositWithdraw :: DepositWithdrawExample -> ScriptContext stakeDepositWithdraw :: DepositWithdrawExample -> ScriptContext
stakeDepositWithdraw config = stakeDepositWithdraw config =
let st = Value.singleton stakeSymbol validatorHashTN 1 -- Stake ST let st = Value.assetClassValue stakeAssetClass 1 -- Stake ST
stakeBefore :: StakeDatum stakeBefore :: StakeDatum
stakeBefore = StakeDatum config.startAmount signer [] stakeBefore = StakeDatum config.startAmount signer []