diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs index c6d4e99ede..03ab48618d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs @@ -260,8 +260,12 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs createStakeDelegatorCredentials (stakeDelegatorsDir "delegator" <> show index) Transient _ -> pure () - let (delegsPerPool, delegsRemaining) = numStakeDelegators `divMod` numPools - delegsForPool poolIx = if delegsRemaining /= 0 && poolIx == numPools + let (delegsPerPool, delegsRemaining) = + if numPools == 0 + then (0, 0) + else numStakeDelegators `divMod` numPools + delegsForPool poolIx = + if delegsRemaining /= 0 && poolIx == numPools then delegsPerPool else delegsPerPool + delegsRemaining distribution = [pool | (pool, poolIx) <- zip poolParams [1 ..], _ <- [1 .. delegsForPool poolIx]] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index 9fa666a07c..94fae1370c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -596,8 +596,12 @@ runGenesisCreateStakedCmd forM_ (zip [ 1 .. numBulkPoolCredFiles ] bulkSlices) $ uncurry (writeBulkPoolCredentials pooldir) - let (delegsPerPool, delegsRemaining) = divMod numStakeDelegators numPools - delegsForPool poolIx = if delegsRemaining /= 0 && poolIx == numPools + let (delegsPerPool, delegsRemaining) = + if numPools == 0 + then (0, 0) + else numStakeDelegators `divMod` numPools + delegsForPool poolIx = + if delegsRemaining /= 0 && poolIx == numPools then delegsPerPool else delegsPerPool + delegsRemaining distribution = [pool | (pool, poolIx) <- zip poolParams [1 ..], _ <- [1 .. delegsForPool poolIx]]