Skip to content

Commit b4b6f97

Browse files
authored
Enable using amount for blueprint deposits (#2178)
fix #2177 --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
2 parents 8f94eb2 + 99e6d7f commit b4b6f97

File tree

3 files changed

+440
-316
lines changed

3 files changed

+440
-316
lines changed

hydra-cluster/src/Hydra/Cluster/Scenarios.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,9 @@ singlePartyCommitsScriptBlueprint tracer workDir backend hydraScriptsTxId =
805805
withHydraNode hydraTracer aliceChainConfig workDir hydraNodeId aliceSk [] [1] $ \n1 -> do
806806
send n1 $ input "Init" []
807807
headId <- waitMatch (10 * blockTime) n1 $ headIsInitializingWith (Set.fromList [alice])
808-
809-
(clientPayload, scriptUTxO) <- prepareScriptPayload 3_000_000
808+
-- NOTE: We don't use amount in _regular_ commits - the ones before the
809+
-- head is not yet opened - since we will remove this process soon.
810+
(clientPayload, scriptUTxO) <- prepareScriptPayload 7_000_000 0
810811

811812
res <-
812813
runReq defaultHttpConfig $
@@ -825,8 +826,12 @@ singlePartyCommitsScriptBlueprint tracer workDir backend hydraScriptsTxId =
825826
guard $ v ^? key "tag" == Just "HeadIsOpen"
826827
pure $ v ^? key "utxo"
827828
lockedUTxO `shouldBe` Just (toJSON scriptUTxO)
829+
828830
-- incrementally commit script to a running Head
829-
(clientPayload', scriptUTxO') <- prepareScriptPayload 2_000_000
831+
let commitAmount = 2_000_000
832+
(clientPayload', scriptUTxO') <- prepareScriptPayload 5_000_000 commitAmount
833+
834+
let toCommit = fst $ capUTxO scriptUTxO' (Coin commitAmount)
830835

831836
res' <-
832837
runReq defaultHttpConfig $
@@ -843,13 +848,12 @@ singlePartyCommitsScriptBlueprint tracer workDir backend hydraScriptsTxId =
843848
Backend.submitTransaction backend tx
844849

845850
waitFor hydraTracer (2 * realToFrac depositPeriod) [n1] $
846-
output "CommitApproved" ["headId" .= headId, "utxoToCommit" .= scriptUTxO']
851+
output "CommitApproved" ["headId" .= headId, "utxoToCommit" .= toCommit]
847852
waitFor hydraTracer (20 * blockTime) [n1] $
848853
output "CommitFinalized" ["headId" .= headId, "depositTxId" .= getTxId (getTxBody tx)]
849-
850-
getSnapshotUTxO n1 `shouldReturn` scriptUTxO <> scriptUTxO'
854+
getSnapshotUTxO n1 `shouldReturn` scriptUTxO <> toCommit
851855
where
852-
prepareScriptPayload lovelaceAmt = do
856+
prepareScriptPayload lovelaceAmt commitAmount = do
853857
networkId <- Backend.queryNetworkId backend
854858
let scriptAddress = mkScriptAddress networkId dummyValidatorScript
855859
let datumHash :: TxOutDatum ctx
@@ -869,6 +873,7 @@ singlePartyCommitsScriptBlueprint tracer workDir backend hydraScriptsTxId =
869873
( Aeson.object
870874
[ "blueprintTx" .= spendingTx
871875
, "utxo" .= scriptUTxO
876+
, "amount" .= Coin commitAmount
872877
]
873878
, scriptUTxO
874879
)

0 commit comments

Comments
 (0)