Skip to content

Commit

Permalink
Move external commit funds key to working dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Mar 27, 2024
1 parent 73aec63 commit c43adf9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
14 changes: 14 additions & 0 deletions hydra-cluster/src/Hydra/Cluster/Fixture.hs
Expand Up @@ -47,7 +47,9 @@ data Actor
= Alice
| AliceFunds
| Bob
| BobFunds
| Carol
| CarolFunds
| Faucet
deriving stock (Eq, Show)

Expand All @@ -56,9 +58,21 @@ actorName = \case
Alice -> "alice"
AliceFunds -> "alice-funds"
Bob -> "bob"
BobFunds -> "bob-funds"
Carol -> "carol"
CarolFunds -> "carol-funds"
Faucet -> "faucet"

toExternalCommitActor :: Actor -> Actor
toExternalCommitActor = \case
Alice -> AliceFunds
AliceFunds -> AliceFunds
Bob -> BobFunds
BobFunds -> BobFunds
Carol -> CarolFunds
CarolFunds -> CarolFunds
Faucet -> Faucet

-- | A network known to the hydra-cluster. That means we have configuration
-- files to connect to at least these networks.
data KnownNetwork
Expand Down
17 changes: 13 additions & 4 deletions hydra-cluster/src/Hydra/Cluster/Util.hs
Expand Up @@ -18,7 +18,7 @@ import Hydra.Cardano.Api (
deserialiseFromTextEnvelope,
textEnvelopeToJSON,
)
import Hydra.Cluster.Fixture (Actor, actorName)
import Hydra.Cluster.Fixture (Actor, actorName, toExternalCommitActor)
import Hydra.ContestationPeriod (ContestationPeriod)
import Hydra.Ledger.Cardano (genSigningKey)
import Hydra.Options (ChainConfig (..), DirectChainConfig (..), defaultDirectChainConfig)
Expand Down Expand Up @@ -75,10 +75,14 @@ chainConfigFor me targetDir nodeSocket hydraScriptsTxId them contestationPeriod
when (me `elem` them) $
failure $
show me <> " must not be in " <> show them
readConfigFile ("credentials" </> skName me) >>= writeFileBS (skTarget me)
readConfigFile ("credentials" </> vkName me) >>= writeFileBS (vkTarget me)

moveFile me "vk"
moveFile me "sk"
moveFile (toExternalCommitActor me) "vk"
moveFile (toExternalCommitActor me) "sk"

forM_ them $ \actor ->
readConfigFile ("credentials" </> vkName actor) >>= writeFileBS (vkTarget actor)
moveFile actor "vk"
pure $
Direct
defaultDirectChainConfig
Expand All @@ -89,6 +93,11 @@ chainConfigFor me targetDir nodeSocket hydraScriptsTxId them contestationPeriod
, contestationPeriod
}
where
moveFile actor fileType = do
let actorFileName = actorName actor <.> fileType
actorFilePath = targetDir </> actorFileName
readConfigFile ("credentials" </> actorFileName) >>= writeFileBS actorFilePath

skTarget x = targetDir </> skName x
vkTarget x = targetDir </> vkName x
skName x = actorName x <.> ".sk"
Expand Down

0 comments on commit c43adf9

Please sign in to comment.