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

fix(tests): fix simulation test invalid genesis state #220

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

RiccardoM
Copy link
Contributor

@RiccardoM RiccardoM commented Dec 17, 2024

Description

This PR fixes the simulation tests by removing invalid x/rewards genesis accumulated commissions initialization.

The previous code created random accumulated commissions for random targets. However, this caused the following error when running some simulations:

Simulating... block 2/100, operation 100/237. Logs to writing to $HOME/.simapp/simulations/1734395338592.log
    simulate.go:345: error on block  2/100, operation (138/237) from x/operators:
        recovered: negative coin amount

This error was raised while trying to execute a MsgDeleteOperator on an operator that had some accumulated commissions, but whose outstanding rewards were empty. When running the clean up code, the error would be raised since the outstanding would be zero:

// Subtract from outstanding
outstanding = outstanding.Sub(commission)

This could be verified running the determinism tests with seed 2282874401958575228:

go test -mod=readonly ./app -run TestAppStateDeterminism -Enabled=true \
	-Seed 2282874401958575228 -NumBlocks=100 -BlockSize=200 \
	-Commit=true -Period=0 -v -timeout 24h

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Copy link

github-actions bot commented Dec 17, 2024

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedDec 17, 2024, 1:08 AM

@RiccardoM RiccardoM force-pushed the riccardom/fix-simulation-tests branch from 5dc5b85 to 91ae758 Compare December 17, 2024 01:08
Copy link
Contributor

@hallazzang hallazzang left a comment

Choose a reason for hiding this comment

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

LGTM

@RiccardoM RiccardoM merged commit b534d85 into main Dec 17, 2024
19 checks passed
@RiccardoM RiccardoM deleted the riccardom/fix-simulation-tests branch December 17, 2024 02:51
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.

2 participants