add sample test && fix broken tests

This commit is contained in:
fanghr 2022-05-18 21:33:42 +08:00
parent 3741759717
commit ce09d05dff
6 changed files with 238 additions and 25 deletions

View file

@ -230,24 +230,18 @@ proposalValidator proposal =
-- TODO: maybe we can move this outside of the pmatch block.
-- Filter out own output with own address and PST.
ownOutput <-
tclet $
mustBePJust # "Own output not found" #$ pfind
# plam
( \input -> unTermCont $ do
inputF <- tcont $ pletFields @'["address", "value"] input
pure $
inputF.address #== ownAddress
#&& psymbolValueOf # stCurrencySymbol # inputF.value #== 1
)
# pfromData txInfoF.outputs
let ownOutput =
mustBePJust # "Own output not found" #$ pfind
# plam
( \input -> unTermCont $ do
inputF <- tcont $ pletFields @'["address", "value"] input
pure $
inputF.address #== ownAddress
#&& psymbolValueOf # stCurrencySymbol # inputF.value #== 1
)
# pfromData txInfoF.outputs
ownOutputF <- tcont $ pletFields @'["datumHash", "value"] ownOutput
-- TODO: is this really necessary?
tcassert "Own output value should be correct" $ ownOutputF.value #== pdata txOutF.value
let proposalOut :: Term _ PProposalDatum
proposalOut :: Term _ PProposalDatum
proposalOut = mustFindDatum' # (pfield @"datumHash" # ownOutput) # txInfoF.datums
let -- Update the vote counter of the proposal, and leave other stuff as is.