Skip to content

Commit 98432c5

Browse files
committed
Add debug points
1 parent fdc23db commit 98432c5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Control.Exception (IOException)
2121
import Control.Monad.Class.MonadThrow (Handler (Handler), catches)
2222
import Control.Tracer (Tracer, traceWith)
2323
import GHC.IO.Exception (IOErrorType (ResourceExhausted), IOException (ioe_type))
24+
import Hydra.Cardano.Api.Pretty (renderTx)
2425
import Hydra.Chain.CardanoClient (queryProtocolParameters)
2526
import Hydra.Chain.Direct.ScriptRegistry (
2627
publishHydraScripts,
@@ -112,16 +113,24 @@ returnFundsToFaucet tracer node@RunningNode{networkId, nodeSocket} sender = do
112113

113114
(senderVk, senderSk) <- keysFor sender
114115
utxo <- queryUTxOFor networkId nodeSocket QueryTip senderVk
116+
traceShowM ("RemainingFunds utxo:" <> renderUTxO utxo)
115117
retryOnExceptions tracer $ do
116118
let utxoValue = balance @Tx utxo
117119
let allLovelace = selectLovelace utxoValue
120+
traceShowM ("allLovelace:" <> show allLovelace)
118121
-- select tokens other than ADA here so we can burn it afterwards
119122
let otherTokens = filterValue (/= AdaAssetId) utxoValue
123+
traceShowM ("otherTokens:" <> renderValue otherTokens)
120124
-- XXX: Using a hard-coded high-enough value to satisfy the min utxo value.
121125
-- NOTE: We use the faucet address as the change deliberately here.
122-
fee <- calculateTxFee node senderSk utxo faucetAddress 1_500_000
126+
fee <- calculateTxFee node senderSk utxo faucetAddress 1_000_000
127+
traceShowM ("fee:" <> show fee)
123128
let returnBalance = allLovelace - fee
124-
tx <- sign senderSk <$> buildTxBody utxo faucetAddress returnBalance otherTokens
129+
traceShowM ("returnBalance:" <> show returnBalance)
130+
returnTxBody <- buildTxBody utxo faucetAddress returnBalance otherTokens
131+
traceShowM ("returnTxBody:" <> show returnTxBody)
132+
let tx = sign senderSk returnTxBody
133+
traceShowM ("tx:" <> renderTx tx)
125134
submitTransaction networkId nodeSocket tx
126135
void $ awaitTransaction networkId nodeSocket tx
127136
traceWith tracer $ ReturnedFunds{actor = actorName sender, returnAmount = returnBalance}

0 commit comments

Comments
 (0)