Skip to content

Commit

Permalink
Fix healthyCommitTx to use the same PubKeyHash
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jan 26, 2022
1 parent 208787e commit fb63447
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Expand Up @@ -162,7 +162,7 @@ mkInitialOutput networkId (Api.toPlutusKeyHash . Api.verificationKeyHash -> vkh)
initialDatum =
Api.mkTxOutDatum $ Initial.datum vkh

pubKeyHash :: VerificationKey PaymentKey -> PubKeyHash
pubKeyHash :: VerificationKey PaymentKey -> Plutus.PubKeyHash
pubKeyHash (PaymentVerificationKey vkey) = transKeyHash $ hashKey @StandardCrypto $ vkey

-- | Craft a commit transaction which includes the "committed" utxo as a datum.
Expand All @@ -179,7 +179,7 @@ commitTx ::
Maybe (Api.TxIn, Api.TxOut Api.CtxUTxO Api.Era) ->
-- | The inital output (sent to each party) which should contain the PT and is
-- locked by initial script
(TxIn StandardCrypto, PubKeyHash) ->
(TxIn StandardCrypto, Plutus.PubKeyHash) ->
ValidatedTx Era
commitTx networkId party utxo (initialInput, vkh) =
Api.toLedgerTx $
Expand Down
24 changes: 12 additions & 12 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Commit.hs
Expand Up @@ -5,7 +5,7 @@ module Hydra.Chain.Direct.Contract.Commit where
import Hydra.Prelude

import qualified Hydra.Chain.Direct.Fixture as Fixture
import Hydra.Chain.Direct.Tx (commitTx, mkInitialOutput)
import Hydra.Chain.Direct.Tx (commitTx, mkInitialOutput, pubKeyHash)
import Hydra.Ledger.Cardano (CardanoTx, CtxUTxO, Era, PaymentKey, TxIn, TxOut, Utxo, VerificationKey, adaOnly, fromLedgerTx, genOutput, singletonUtxo, toCtxUTxOTxOut, toLedgerTxIn)
import Hydra.Party (Party)

Expand All @@ -24,31 +24,31 @@ healthyCommitTx =
where
lookupUtxo =
singletonUtxo (initialInput, toCtxUTxOTxOut initialOutput)
<> singletonUtxo healthyCommittedUtxo
<> singletonUtxo committedUtxo

tx =
commitTx
Fixture.testNetworkId
healthyCommitParty
(Just healthyCommittedUtxo)
commitParty
(Just committedUtxo)
(toLedgerTxIn initialInput, initialPubKeyHash)

initialInput = generateWith arbitrary 42

initialOutput = mkInitialOutput Fixture.testNetworkId healthyCommitVerificationKey
initialOutput = mkInitialOutput Fixture.testNetworkId commitVerificationKey

initialPubKeyHash = generateWith arbitrary 42
initialPubKeyHash = pubKeyHash commitVerificationKey

-- NOTE: An ada-only output which is currently addressed to some arbitrary
-- public key.
healthyCommittedUtxo :: (TxIn, TxOut CtxUTxO Era)
healthyCommittedUtxo = flip generateWith 42 $ do
committedUtxo :: (TxIn, TxOut CtxUTxO Era)
committedUtxo = flip generateWith 42 $ do
txIn <- arbitrary
txOut <- adaOnly <$> (genOutput =<< arbitrary)
pure (txIn, txOut)

healthyCommitVerificationKey :: VerificationKey PaymentKey
healthyCommitVerificationKey = generateWith arbitrary 42
commitVerificationKey :: VerificationKey PaymentKey
commitVerificationKey = generateWith arbitrary 42

healthyCommitParty :: Party
healthyCommitParty = generateWith arbitrary 42
commitParty :: Party
commitParty = generateWith arbitrary 42

0 comments on commit fb63447

Please sign in to comment.