Skip to content

Commit 10f259b

Browse files
committed
Fanout Mutation: Set utxoToDecommit in the fanout snapshot
Exercise the path where the fanout snapshot is created with something to decommit and then alter the outputs to add one more so the hash doesn't match with the fanout redeemer.
1 parent ee72e54 commit 10f259b

File tree

1 file changed

+10
-5
lines changed
  • hydra-node/test/Hydra/Chain/Direct/Contract

1 file changed

+10
-5
lines changed

hydra-node/test/Hydra/Chain/Direct/Contract/FanOut.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Cardano.Api.UTxO as UTxO
1010
import Hydra.Chain.Direct.Contract.Mutation (Mutation (..), SomeMutation (..), changeMintedTokens)
1111
import Hydra.Chain.Direct.Fixture (slotLength, systemStart, testNetworkId, testPolicyId, testSeedInput)
1212
import Hydra.Chain.Direct.ScriptRegistry (genScriptRegistry, registryUTxO)
13+
import Hydra.Chain.Direct.State (splitUTxO)
1314
import Hydra.Chain.Direct.Tx (fanoutTx, mkHeadOutput)
1415
import Hydra.Contract.Error (toErrorCode)
1516
import Hydra.Contract.HeadError (HeadError (..))
@@ -42,9 +43,8 @@ healthyFanoutTx =
4243
tx =
4344
fanoutTx
4445
scriptRegistry
45-
healthyFanoutUTxO
46-
-- TODO: add something to decommit here
47-
Nothing
46+
(fst healthyFanoutSnapshotUTxO)
47+
(Just $ snd healthyFanoutSnapshotUTxO)
4848
(headInput, headOutput)
4949
healthySlotNo
5050
headTokenScript
@@ -79,12 +79,15 @@ healthyContestationDeadline :: UTCTime
7979
healthyContestationDeadline =
8080
slotNoToUTCTime systemStart slotLength $ healthySlotNo - 1
8181

82+
healthyFanoutSnapshotUTxO :: (UTxO, UTxO)
83+
healthyFanoutSnapshotUTxO = generateWith (splitUTxO healthyFanoutUTxO) 42
84+
8285
healthyFanoutDatum :: Head.State
8386
healthyFanoutDatum =
8487
Head.Closed
8588
{ snapshotNumber = 1
86-
, utxoHash = toBuiltin $ hashUTxO @Tx healthyFanoutUTxO
87-
, utxoToDecommitHash = toBuiltin $ hashUTxO @Tx mempty
89+
, utxoHash = toBuiltin $ hashUTxO @Tx (fst healthyFanoutSnapshotUTxO)
90+
, utxoToDecommitHash = toBuiltin $ hashUTxO @Tx (snd healthyFanoutSnapshotUTxO)
8891
, parties =
8992
partyToChain <$> healthyParties
9093
, contestationDeadline = posixFromUTCTime healthyContestationDeadline
@@ -129,6 +132,8 @@ genFanoutMutation (tx, _utxo) =
129132
, SomeMutation (pure $ toErrorCode BurntTokenNumberMismatch) MutateThreadTokenQuantity <$> do
130133
(token, _) <- elements burntTokens
131134
changeMintedTokens tx (valueFromList [(token, 1)])
135+
, SomeMutation (pure $ toErrorCode FannedOutUtxoHashNotEqualToClosedUtxoHash) MutateAddUnexpectedOutput . PrependOutput <$> do
136+
arbitrary >>= genOutput
132137
]
133138
where
134139
burntTokens =

0 commit comments

Comments
 (0)