simple fixes suggested from review

This commit is contained in:
Seungheon Oh 2022-04-22 08:23:54 -04:00
parent 11a10bd4ec
commit 17817ba68b
2 changed files with 18 additions and 30 deletions

View file

@ -142,13 +142,7 @@ effectSucceedsWith ::
ScriptContext -> ScriptContext ->
TestTree TestTree
effectSucceedsWith tag eff datum scriptContext = effectSucceedsWith tag eff datum scriptContext =
scriptSucceeds tag $ validatorSucceedsWith tag eff datum () scriptContext
compile
( eff
# pforgetData (pconstantData datum)
# pforgetData (pconstantData ())
# pconstant scriptContext
)
-- | Check that a validator script fails, given a name and arguments. -- | Check that a validator script fails, given a name and arguments.
effectFailsWith :: effectFailsWith ::
@ -161,14 +155,8 @@ effectFailsWith ::
ScriptContext -> ScriptContext ->
TestTree TestTree
effectFailsWith tag eff datum scriptContext = effectFailsWith tag eff datum scriptContext =
scriptFails tag $ validatorFailsWith tag eff datum () scriptContext
compile
( eff
# pforgetData (pconstantData datum)
# pforgetData (pconstantData ())
# pconstant scriptContext
)
-- | Check that an arbitrary script doesn't error when evaluated, given a name. -- | Check that an arbitrary script doesn't error when evaluated, given a name.
scriptSucceeds :: String -> Script -> TestTree scriptSucceeds :: String -> Script -> TestTree
scriptSucceeds name script = testCase name $ do scriptSucceeds name script = testCase name $ do

View file

@ -67,18 +67,18 @@ deriving via
(PConstant TreasuryWithdrawalDatum) (PConstant TreasuryWithdrawalDatum)
{- | Withdraws given list of values to specific target addresses. {- | Withdraws given list of values to specific target addresses.
It can be evoked by burning GAT. The transaction should have correct It can be evoked by burning GAT. The transaction should have correct
outputs to the users and any left overs should be paid back to the treasury. outputs to the users and any left overs should be paid back to the treasury.
The validator does not accept any Redeemer as all "parameters" are provided The validator does not accept any Redeemer as all "parameters" are provided
via encoded Datum. via encoded Datum.
Note: Note:
It should check... It should check...
1. Transaction outputs should contain all of what Datum specified 1. Transaction outputs should contain all of what Datum specified
2. Left over assests should be redirected back to Treasury 2. Left over assests should be redirected back to Treasury
It can be more flexiable over... It can be more flexiable over...
- The number of outputs themselves - The number of outputs themselves
-} -}
treasuryWithdrawalValidator :: forall {s :: S}. CurrencySymbol -> Term s PValidator treasuryWithdrawalValidator :: forall {s :: S}. CurrencySymbol -> Term s PValidator
treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $
@ -104,11 +104,11 @@ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $
pdata $ ptuple # txOut.address # txOut.value pdata $ ptuple # txOut.address # txOut.value
) )
# txInfo.inputs # txInfo.inputs
treasuryInputValues = treasuryInputValues <- plet $
pfilter pfilter
# plam (\((pfield @"_0" #) . pfromData -> addr) -> pnot #$ addr #== effInput.address) # plam (\((pfield @"_0" #) . pfromData -> addr) -> pnot #$ addr #== effInput.address)
# inputValues # inputValues
treasuryCredentials = let treasuryCredentials =
pmap pmap
# plam ((pfield @"credential" #) . pfromData . (pfield @"_0" #) . pfromData) # plam ((pfield @"credential" #) . pfromData . (pfield @"_0" #) . pfromData)
# treasuryInputValues # treasuryInputValues