Skip to content

Commit

Permalink
Remove addChangeOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Feb 6, 2023
1 parent 2b59244 commit 302939a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
3 changes: 1 addition & 2 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Expand Up @@ -86,7 +86,6 @@ import Hydra.Chain.Direct.Tx (
observeFanoutTx,
observeInitTx,
)
import Hydra.Chain.Direct.Util (addChangeOutput)
import Hydra.ContestationPeriod (ContestationPeriod)
import Hydra.Crypto (HydraKey, generateSigningKey)
import Hydra.Data.ContestationPeriod (posixToUTCTime)
Expand Down Expand Up @@ -851,7 +850,7 @@ genCollectComTx = do
commits <- genCommits ctx txInit
cctx <- pickChainContext ctx
let (committedUTxO, stInitialized) = unsafeObserveInitAndCommits cctx txInit commits
pure (cctx, committedUTxO, stInitialized, addChangeOutput $ collect cctx stInitialized)
pure (cctx, committedUTxO, stInitialized, collect cctx stInitialized)

genCloseTx :: Int -> Gen (ChainContext, OpenState, Tx, ConfirmedSnapshot Tx)
genCloseTx numParties = do
Expand Down
10 changes: 0 additions & 10 deletions hydra-node/src/Hydra/Chain/Direct/Util.hs
Expand Up @@ -201,16 +201,6 @@ isMarkedOutput = \case
-- TEST RELATED FUNCTIONS
-----------------------------------------------------------------------------

-- NOTE: Add one output containing 0 ada to make sure we have the right number
-- of outputs (2). In practise the change should cover the fees and here they
-- are zero.
addChangeOutput :: Tx -> Tx
addChangeOutput transaction =
alterTxOuts (\outs -> outs <> [changeOutput{txOutValue = lovelaceToValue 0}]) transaction
where
changeOutput =
generateWith genTxOutAdaOnly 42

-- | Apply some mapping function over a transaction's outputs.
alterTxOuts ::
([TxOut CtxTx] -> [TxOut CtxTx]) ->
Expand Down
14 changes: 6 additions & 8 deletions hydra-node/test/Hydra/Chain/Direct/Contract/CollectCom.hs
Expand Up @@ -32,7 +32,6 @@ import Hydra.Chain.Direct.Tx (
mkHeadOutput,
mkInitialOutput,
)
import Hydra.Chain.Direct.Util (addChangeOutput)
import qualified Hydra.Contract.Commit as Commit
import qualified Hydra.Contract.Head as Head
import qualified Hydra.Contract.HeadState as Head
Expand All @@ -59,13 +58,12 @@ healthyCollectComTx =
UTxO.singleton (healthyHeadInput, healthyHeadResolvedInput) <> UTxO (txOut <$> healthyCommits)

tx =
addChangeOutput $
collectComTx
testNetworkId
somePartyCardanoVerificationKey
initialThreadOutput
((txOut &&& scriptData) <$> healthyCommits)
(mkHeadId testPolicyId)
collectComTx
testNetworkId
somePartyCardanoVerificationKey
initialThreadOutput
((txOut &&& scriptData) <$> healthyCommits)
(mkHeadId testPolicyId)

somePartyCardanoVerificationKey = flip generateWith 42 $ do
genForParty genVerificationKey <$> elements healthyParties
Expand Down

0 comments on commit 302939a

Please sign in to comment.