Skip to content

Commit cfe15c7

Browse files
committed
wip
1 parent 220fdae commit cfe15c7

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

cardano-testnet/cardano-testnet.cabal

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ library
5050
, cardano-ledger-shelley
5151
, cardano-node
5252
, cardano-ping ^>= 0.4
53-
, contra-tracer
54-
, containers
55-
, data-default-class
5653
, cborg
5754
, containers
5855
, contra-tracer
@@ -63,6 +60,7 @@ library
6360
, filepath
6461
, hedgehog
6562
, hedgehog-extras ^>= 0.6.4
63+
, iproute
6664
, lens-aeson
6765
, microlens
6866
, mtl

cardano-testnet/src/Testnet/Start/Cardano.hs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ import Cardano.Api.Ledger (StandardCrypto)
3030
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis)
3131
import Cardano.Ledger.Conway.Genesis (ConwayGenesis)
3232
import Cardano.Node.Configuration.Topology
33+
import qualified Cardano.Node.Configuration.TopologyP2P as P2P
34+
import qualified Ouroboros.Network.PeerSelection.Bootstrap as P2P
35+
import qualified Ouroboros.Network.PeerSelection.LedgerPeers as P2P
36+
import qualified Ouroboros.Network.PeerSelection.PeerTrustable as P2P
3337

3438
import Prelude hiding (lines)
3539

@@ -40,6 +44,7 @@ import qualified Data.Aeson as Aeson
4044
import Data.Bifunctor (first)
4145
import qualified Data.ByteString.Lazy as LBS
4246
import Data.Either
47+
import Data.IP as IP
4348
import qualified Data.List as L
4449
import Data.Maybe
4550
import qualified Data.Text as Text
@@ -49,6 +54,7 @@ import qualified Data.Time.Clock as DTC
4954
import Data.Word (Word64)
5055
import GHC.Stack
5156
import qualified GHC.Stack as GHC
57+
import qualified System.Directory as IO
5258
import System.FilePath ((</>))
5359
import qualified System.Info as OS
5460
import Text.Printf (printf)
@@ -191,8 +197,7 @@ cardanoTestnet
191197
let (CardanoTestnetOptions _cardanoNodes asbe maxSupply _p2p nodeLoggingFormat _numDReps newEpochStateLogging) = testnetOptions
192198
startTime = sgSystemStart shelleyGenesis
193199
testnetMagic = fromIntegral $ sgNetworkMagic shelleyGenesis
194-
numPoolNodes = length $ cardanoNodes testnetOptions
195-
nPools = numPools testnetOptions
200+
nPools@(NumPools numPoolNodes) = numPools testnetOptions
196201
nDReps = numDReps testnetOptions
197202
AnyShelleyBasedEra sbe <- pure asbe
198203

@@ -231,15 +236,15 @@ cardanoTestnet
231236

232237
configurationFile <- H.noteShow . File $ tmpAbsPath </> "configuration.yaml"
233238

234-
_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
239+
_ <- createSPOGenesisAndFiles 1 nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
235240

236241
-- TODO: This should come from the configuration!
237242
let poolKeyDir :: Int -> FilePath
238243
poolKeyDir i = "pools-keys" </> mkNodeName i
239244
mkNodeName :: Int -> String
240245
mkNodeName i = "pool" <> show i
241246

242-
poolKeys <- H.noteShow $ flip fmap [1..numPoolNodes] $ \n ->
247+
poolKeys <- H.noteShow $ flip fmap [1..1] $ \n ->
243248
-- TODO: use Testnet.Defaults.defaultSpoKeys here
244249
PoolNodeKeys
245250
{ poolNodeKeysCold =
@@ -308,8 +313,10 @@ cardanoTestnet
308313
-- Byron related
309314
forM_ (zip [1..] portNumbers) $ \(i, portNumber) -> do
310315
let iStr = printf "%03d" (i - 1)
311-
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegate-keys." <> iStr <> ".key") (tmpAbsPath </> poolKeyDir i </> "byron-delegate.key")
312-
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </> "byron-delegation.cert")
316+
when (i == 1) $ do
317+
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegate-keys." <> iStr <> ".key") (tmpAbsPath </> poolKeyDir i </> "byron-delegate.key")
318+
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </> "byron-delegation.cert")
319+
H.evalIO $ IO.createDirectoryIfMissing True $ tmpAbsPath </> poolKeyDir i
313320
H.writeFile (tmpAbsPath </> poolKeyDir i </> "port") (show portNumber)
314321

315322
-- Make topology files
@@ -320,9 +327,21 @@ cardanoTestnet
320327
, raPort = otherProducerPort
321328
, raValency = 1
322329
}
323-
324330
H.lbsWriteFile (tmpAbsPath </> poolKeyDir i </> "topology.json") . encode $
325331
RealNodeTopology producers
332+
-- P2P.RelayAccessAddress
333+
-- (IP.IPv4 $ IP.fromHostAddress testnetDefaultIpv4Address)
334+
-- otherProducerPort
335+
-- rootConfig = P2P.RootConfig peers P2P.DoNotAdvertisePeer
336+
-- peersGroup = P2P.LocalRootPeersGroup rootConfig 2 2 P2P.IsTrustable
337+
-- H.lbsWriteFile (tmpAbsPath </> poolKeyDir i </> "topology.json") . encode $
338+
-- P2P.RealNodeTopology
339+
-- (P2P.LocalRootPeersGroups [peersGroup])
340+
-- []
341+
-- (if i == 1
342+
-- then P2P.DontUseLedgerPeers
343+
-- else P2P.UseLedgerPeers P2P.Always)
344+
-- P2P.DontUseBootstrapPeers
326345

327346
let keysWithPorts = L.zip3 [1..] poolKeys portNumbers
328347
ePoolNodes <- H.forConcurrently keysWithPorts $ \(i, key, port) -> do
@@ -393,7 +412,7 @@ cardanoTestnet
393412

394413
stakePoolsFp <- H.note $ tmpAbsPath </> "current-stake-pools.json"
395414

396-
assertExpectedSposInLedgerState stakePoolsFp nPools execConfig
415+
assertExpectedSposInLedgerState stakePoolsFp 1 execConfig
397416

398417
when newEpochStateLogging $
399418
TR.startLedgerNewEpochStateLogging runtime tempBaseAbsPath

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasur
4848
}
4949

5050
TestnetRuntime{testnetMagic, configurationFile, poolNodes} <- cardanoTestnetDefault options shelleyOptions conf
51+
H.failure
5152

5253
(execConfig, socketPathAbs) <- do
5354
PoolNode{poolRuntime} <- H.headM poolNodes

0 commit comments

Comments
 (0)