Skip to content

Commit

Permalink
Fixed topology format generation in chairman tests.
Browse files Browse the repository at this point in the history
Increased the timeout seconds in hopes to fix the timeout issues but
without much success.
  • Loading branch information
bolt12 authored and coot committed May 13, 2021
1 parent 0e8bcf6 commit 2cae409
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 30 deletions.
22 changes: 16 additions & 6 deletions cardano-node-chairman/src/Testnet/Byron.hs
Expand Up @@ -13,6 +13,7 @@ module Testnet.Byron

import Control.Monad
import Data.Aeson (Value, (.=))
import Data.Bool (Bool(..))
import Data.Eq
import Data.Function
import Data.Functor
Expand Down Expand Up @@ -148,13 +149,22 @@ testnet testnetOptions H.Conf {..} = do

H.lbsWriteFile (tempAbsPath </> "topology-node-" <> si <> ".json") $ J.encode $
J.object
[ ( "Producers"
, J.toJSON $ flip fmap [0 .. numBftNodes testnetOptions - 2] $ \j -> J.object
[ ("addr", "127.0.0.1")
, ("valency", J.toJSON @Int 1)
, ("port", J.toJSON (otherPorts L.!! j))
[ "LocalRoots" .= J.object
[ "groups" .= J.toJSON
[ J.object
[ "localRoots" .= J.object
[ "addrs" .= J.toJSON
(flip fmap [0 .. numBftNodes testnetOptions - 2] (\j ->
J.object
[ ("addr", "127.0.0.1")
, ("port", J.toJSON (otherPorts L.!! j))
]))
, "advertise" .= J.toJSON @Bool False
]
, "valency" .= J.toJSON @Int 1
]
]
)
]
]

H.writeFile (tempAbsPath </> "config-" <> si <> ".yaml") . L.unlines . fmap (rewriteConfiguration i) . L.lines =<<
Expand Down
24 changes: 17 additions & 7 deletions cardano-node-chairman/src/Testnet/ByronShelley.hs
Expand Up @@ -18,7 +18,7 @@ module Testnet.ByronShelley
) where

#ifdef UNIX
import Prelude (map)
import Prelude (map, Bool(..))
#endif

import Control.Monad
Expand Down Expand Up @@ -177,15 +177,25 @@ testnet testnetOptions H.Conf {..} = do
let port = fromJust $ M.lookup node nodeToPort
H.lbsWriteFile (tempAbsPath </> node </> "topology.json") $ J.encode $
J.object
[ "Producers" .= J.toJSON
[ J.object
[ "addr" .= J.toJSON @String ifaceAddress
, "port" .= J.toJSON @Int peerPort
, "valency" .= J.toJSON @Int 1
[ "LocalRoots" .= J.object
[ "groups" .= J.toJSON
[ J.object
[ "localRoots" .= J.object
[ "addrs" .= J.toJSON
[ J.object
[ "addr" .= J.toJSON @String ifaceAddress
, "port" .= J.toJSON @Int peerPort
]
| peerPort <- allPorts \\ [port]
]
, "advertise" .= J.toJSON @Bool False
]
, "valency" .= J.toJSON @Int 1
]
]
| peerPort <- allPorts \\ [port]
]
]

H.writeFile (tempAbsPath </> node </> "port") (show port)

H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json") . J.encode $ J.object
Expand Down
24 changes: 17 additions & 7 deletions cardano-node-chairman/src/Testnet/Shelley.hs
Expand Up @@ -17,7 +17,7 @@ module Testnet.Shelley
) where

#ifdef UNIX
import Prelude (Integer, map)
import Prelude (Integer, map, Bool(..))
#else
import Prelude (Integer)
#endif
Expand Down Expand Up @@ -219,15 +219,25 @@ testnet testnetOptions H.Conf {..} = do
let port = fromJust $ M.lookup node nodeToPort
H.lbsWriteFile (tempAbsPath </> node </> "topology.json") $ J.encode $
J.object
[ "Producers" .= J.toJSON
[ J.object
[ "addr" .= J.toJSON @String ifaceAddress
, "port" .= J.toJSON @Int peerPort
, "valency" .= J.toJSON @Int 1
[ "LocalRoots" .= J.object
[ "groups" .= J.toJSON
[ J.object
[ "localRoots" .= J.object
[ "addrs" .= J.toJSON
[ J.object
[ "addr" .= J.toJSON @String ifaceAddress
, "port" .= J.toJSON @Int peerPort
]
| peerPort <- allPorts \\ [port]
]
, "advertise" .= J.toJSON @Bool False
]
, "valency" .= J.toJSON @Int 1
]
]
| peerPort <- allPorts \\ [port]
]
]

H.writeFile (tempAbsPath </> node </> "port") (show port)

-- Generated node operator keys (cold, hot) and operational certs
Expand Down
2 changes: 1 addition & 1 deletion cardano-node-chairman/test/Spec/Chairman/Byron.hs
Expand Up @@ -23,4 +23,4 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp
conf <- H.mkConf tempAbsPath' Nothing
allNodes <- H.testnet H.defaultTestnetOptions conf

chairmanOver 120 52 conf allNodes
chairmanOver 240 52 conf allNodes
2 changes: 1 addition & 1 deletion cardano-node-chairman/test/Spec/Chairman/ByronShelley.hs
Expand Up @@ -24,4 +24,4 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp

allNodes <- H.testnet H.defaultTestnetOptions conf

chairmanOver 120 50 conf allNodes
chairmanOver 240 50 conf allNodes
2 changes: 1 addition & 1 deletion cardano-node-chairman/test/Spec/Chairman/Shelley.hs
Expand Up @@ -24,4 +24,4 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp

allNodes <- H.testnet H.defaultTestnetOptions conf

chairmanOver 120 21 conf allNodes
chairmanOver 240 21 conf allNodes
23 changes: 16 additions & 7 deletions configuration/cardano/mainnet-topology.json
@@ -1,9 +1,18 @@
{
"Producers": [
{
"addr": "relays-new.cardano-mainnet.iohk.io",
"port": 3001,
"valency": 2
}
]
"LocalRoots": {
"groups": [
{
"localRoots": {
"addrs": [
{
"addr": "relays-new.cardano-mainnet.iohk.io",
"port": 3001
}
],
"advertise": false
},
"valency": 1
}
]
}
}

0 comments on commit 2cae409

Please sign in to comment.