Skip to content

Commit 6fece23

Browse files
author
euonymos
committed
fix: dynamic test is green, but without mutations
1 parent 3774144 commit 6fece23

File tree

7 files changed

+259
-78
lines changed

7 files changed

+259
-78
lines changed

example/CEM/Example/Auction.hs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,23 @@ instance CEMScript SimpleAuction where
133133
)
134134
cEmptyValue
135135
)
136-
, output
137-
(userUtxo ctxParams.seller)
138-
(cMinLovelace @<> cMkAdaOnlyValue buyoutBid.betAmount)
139-
, output
140-
(userUtxo buyoutBid.better)
141-
(cMinLovelace @<> ctxParams.lot)
136+
, if'
137+
(ctxParams.seller `eq'` buyoutBid.better)
138+
( output
139+
(userUtxo ctxParams.seller)
140+
(cMinLovelace @<> ctxParams.lot)
141+
)
142+
( output
143+
(userUtxo buyoutBid.better)
144+
(cMinLovelace @<> ctxParams.lot)
145+
)
146+
, if'
147+
(ctxParams.seller `eq'` buyoutBid.better)
148+
noop
149+
( output
150+
(userUtxo ctxParams.seller)
151+
(cMinLovelace @<> cMkAdaOnlyValue buyoutBid.betAmount)
152+
)
142153
]
143154
)
144155
]

src/Cardano/CEM/DSL.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ getMainSigner cs = case mapMaybe f cs of
298298
[pkh] -> pkh
299299
_ ->
300300
error
301-
"Transition should have exactly one MainSignerCoinSelection constraint"
301+
"Transition should have exactly one MainSigner* constraint"
302302
where
303303
f (MainSignerNoValue pkh) = Just pkh
304304
f (MainSignerCoinSelect pkh _ _) = Just pkh

src/Cardano/CEM/Smart.hs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import Plutarch.Prelude (
1919
(#&&),
2020
)
2121
import PlutusLedgerApi.V2 (PubKeyHash, ToData (..), Value)
22-
import Prelude hiding (error)
23-
import Prelude qualified (error)
22+
import Prelude hiding (Eq, error)
23+
import Prelude qualified (Eq, error)
2424

2525
-- -----------------------------------------------------------------------------
2626
-- Helpers to be used in actual definitions
@@ -118,7 +118,7 @@ inState ::
118118
inState spine = UnsafeUpdateOfSpine ctxState spine []
119119

120120
(@==) ::
121-
(Eq x) => ConstraintDSL script x -> ConstraintDSL script x -> ConstraintDSL script Bool
121+
(Prelude.Eq x) => ConstraintDSL script x -> ConstraintDSL script x -> ConstraintDSL script Bool
122122
(@==) = Eq
123123

124124
(@<=) ::
@@ -254,3 +254,19 @@ match ::
254254
Map (Spine datatype) (TxConstraint resolved script) ->
255255
TxConstraint resolved script
256256
match = MatchBySpine
257+
258+
if' ::
259+
forall (resolved :: Bool) script.
260+
DSLPattern resolved script Bool ->
261+
TxConstraint resolved script ->
262+
TxConstraint resolved script ->
263+
TxConstraint resolved script
264+
if' = If
265+
266+
eq' ::
267+
forall x script.
268+
(Prelude.Eq x) =>
269+
ConstraintDSL script x ->
270+
ConstraintDSL script x ->
271+
ConstraintDSL script Bool
272+
eq' = Eq

0 commit comments

Comments
 (0)