Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-testnet-data: don't fail trying to create irrelevant READMEs #588

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Jan 24, 2024

Changelog

- description: |
    Avoid an internal crash of `create-testnet-data`
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - improvement    # QoL changes e.g. refactoring
  - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Fixes #587

When using create-testnet-data in IntersectMBO/cardano-node#5646, I was faced with the fact that it was crashing when omitting some flags, because it was trying to create the README for some keys, whose parent directory wasn't being created; because the concerned keys where not requested. This is #587.

When fixing that, I also noticed that create-testnet-data was looping when neither --stake-delegators nor --transient--stake-delegators was specified. This was due to a zipWith call with concat $ repeat ([]) as an argument (the crux is to pass [] to repeat). So this PR also fixes that.

On the way, I also noticed that create-staked and create-testnet-data were avoiding a division by zero because of laziness. I made this less brittle by avoiding the division by zero explicitly.

How to trust this PR

A test is introduced. The test fails before this PR and it succeeds after the PR.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@smelc smelc force-pushed the smelc/fix-create-testnet-data-readme-failures branch from 93f3929 to e83e4ec Compare January 25, 2024 13:16
@smelc smelc enabled auto-merge January 25, 2024 13:17
@smelc smelc added this pull request to the merge queue Jan 25, 2024
Merged via the queue into main with commit 826108c Jan 25, 2024
14 checks passed
@smelc smelc deleted the smelc/fix-create-testnet-data-readme-failures branch January 25, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create-testnet-data can fail internally when writing READMEs
2 participants