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

Imptests - treasury withdrawals #4189

Merged
merged 7 commits into from
Apr 4, 2024

Conversation

teodanciu
Copy link
Contributor

@teodanciu teodanciu commented Mar 8, 2024

Description

This is the first part of @aniketd 's PR: https://github.com/IntersectMBO/cardano-ledger/pull/4179/commits, closing: #4133

I have re-arranged the test a little bit and added his commit that is actually adding the tests, and improved the tests with the comments from the review.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from c516b95 to 7d1c912 Compare March 12, 2024 16:49
@teodanciu teodanciu changed the base branch from master to td/fix-imp-epoch-check March 12, 2024 16:51
@teodanciu teodanciu marked this pull request as ready for review March 12, 2024 16:51
@teodanciu teodanciu changed the base branch from td/fix-imp-epoch-check to master March 13, 2024 16:57
@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch 5 times, most recently from c9ed97a to 46f7f22 Compare March 18, 2024 12:36
@teodanciu teodanciu assigned Soupstraw and unassigned Soupstraw Mar 18, 2024
@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 46f7f22 to 97b20cd Compare March 18, 2024 13:14
@teodanciu
Copy link
Contributor Author

Sorry, the last two commits were already reviewed as part of #4201, but the base branch was this one instead of master.

Lucsanszky
Lucsanszky previously approved these changes Mar 19, 2024
@Lucsanszky Lucsanszky dismissed their stale review March 19, 2024 18:49

Accidental approval

@Lucsanszky
Copy link
Contributor

I'm currently reviewing this and I intend to finish the review later today. I have some questions and minor suggestions.

Copy link
Contributor

@Lucsanszky Lucsanszky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it took me long enough! 😬 Overall, I quite like it but since I'm new to the codebase, I felt that some more comments and assertions could improve the readability of the tests. However, my additions might be a bit too verbose so feel free to change or ignore them. Especially, if I didn't get the jargon right. :)

I mainly looked at the Treasury withdrawals spec, here is the gist of my suggestions:
I felt that it might be useful to also assert for the presence/absence of both the current proposals and previous ones (so the ones that are in the pulser), so I added those assertions as suggestions and also added an expectNoChange assertion that checks multiple things when a Treasury Withdrawal governance action's pre-condition is not met and hence the proposal will not be enacted as a result. Hopefully, I did not misunderstand the state changes and my suggestions are indeed helpful rather than misleading.

It seems like GitHub doesn't support suggestions over deleted lines so sometimes I had to separate suggestions into Step 1 and Step 2.

I was thinking about reorganising and rewording the its and describes as I would have preferred something along the lines of this:

        describe "Treasury withdrawals"
          it "modify EnactState as expected"
          describe "in a single proposal"
            it "should only be enacted when treasury has sufficient funds"
            it "should not exceed maxBound Word64"
          describe "in several proposals within the same epoch"
            it "should only be enacted until treasury has sufficient funds"

However, it seems like we don't really use this style throughout the codebase, so I opted to leave things intact and I also try to avoid too many nested describes.

@teodanciu
Copy link
Contributor Author

@Lucsanszky Sorry I'm a bit lost about your comments with Step 1 and Step 2.
Do you mean, we should extract the check that the withdrawal proposal had no effect? So basically:

      getTreasury `shouldReturn` initialTreasury
      sumRewardAccounts withdrawals `shouldReturn` zero
```  ? 

@Lucsanszky
Copy link
Contributor

@Lucsanszky Sorry I'm a bit lost about your comments with Step 1 and Step 2. Do you mean, we should extract the check that the withdrawal proposal had no effect? So basically:

      getTreasury `shouldReturn` initialTreasury
      sumRewardAccounts withdrawals `shouldReturn` zero
```  ? 

Yes, exactly. I added it because I also added the proposal assertions and at that point I thought that it might worth extracting the whole thing.

@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 97b20cd to 0307419 Compare March 22, 2024 12:41
Copy link
Contributor

@aniketd aniketd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions for better test-naming than I originally thought.

Copy link
Contributor

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just needs to be finished up and comments need to be addressed

@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 0307419 to 36da6ef Compare April 3, 2024 13:07
@teodanciu teodanciu enabled auto-merge April 3, 2024 13:11
Copy link
Contributor

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!
I made a minor suggestion, but feel free to ignore it

@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 36da6ef to 9ba9078 Compare April 3, 2024 21:39
@teodanciu teodanciu disabled auto-merge April 3, 2024 21:51
@teodanciu teodanciu force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 9ba9078 to 8467b66 Compare April 3, 2024 21:53
@lehins lehins force-pushed the td/aniketd/more-imptests-treasury-withdrawals branch from 8467b66 to c57a6da Compare April 3, 2024 22:26
@lehins lehins enabled auto-merge April 3, 2024 22:26
@lehins lehins merged commit 304c71a into master Apr 4, 2024
19 checks passed
@lehins lehins deleted the td/aniketd/more-imptests-treasury-withdrawals branch April 4, 2024 03:03
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.

None yet

5 participants