Skip to content

Commit

Permalink
Try to generate key for signing CollectCom tx #284
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly-iohk committed Mar 28, 2022
1 parent 239f0bc commit 0b1e47c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions hydra-node/test/Hydra/Chain/Direct/Contract/CollectCom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import qualified Hydra.Contract.Head as Head
import qualified Hydra.Contract.HeadState as Head
import qualified Hydra.Data.Party as OnChain
import qualified Hydra.Data.Party as Party
import Hydra.Ledger.Cardano (genAdaOnlyUTxO, genVerificationKey)
import Hydra.Ledger.Cardano (genAdaOnlyUTxO, genKeyPair, genVerificationKey)
import Hydra.Party (Party, vkey)
import Plutus.Orphans ()
import Plutus.V1.Ledger.Api (fromData, toBuiltin, toData)
Expand All @@ -55,10 +55,13 @@ healthyCollectComTx =
UTxO.singleton (healthyHeadInput, healthyHeadResolvedInput) <> UTxO (fst <$> commits)

tx =
collectComTx
testNetworkId
(healthyHeadInput, healthyHeadResolvedInput, headDatum, healthyOnChainParties)
commits
signTransaction
( collectComTx
testNetworkId
(healthyHeadInput, healthyHeadResolvedInput, headDatum, healthyOnChainParties)
commits
)
cardanoKey

committedUTxO =
generateWith
Expand Down Expand Up @@ -116,9 +119,9 @@ healthyCommitOutput party committed =
)
)
where
Party.UnsafeParty (fromIntegral -> seed) = Party.partyFromVerKey (vkey party)
(Party.partyFromVerKey . vkey -> (Party.UnsafeParty (fromIntegral -> seed))) = party

cardanoVk = generateWith genVerificationKey seed
(cardanoVk, _) = generateKeyPair party

commitScript =
fromPlutusScript Commit.validatorScript
Expand All @@ -133,6 +136,10 @@ healthyCommitOutput party committed =
commitDatum =
mkCommitDatum party Head.validatorHash (Just committed)

generateKeyPair :: Party -> (VerificationKey PaymentKey, SigningKey PaymentKey)
generateKeyPair (Party.partyFromVerKey . vkey -> (Party.UnsafeParty (fromIntegral -> seed))) =
generateWith genKeyPair seed

data CollectComMutation
= MutateOpenUTxOHash
| MutateHeadScriptInput
Expand Down

0 comments on commit 0b1e47c

Please sign in to comment.