-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(simsx): allow RunWithSeeds with custom randAccFn #23197
Conversation
📝 WalkthroughWalkthroughThe pull request introduces two new functions, Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
simsx/runner.go (1)
Line range hint
165-191
: Apply gofumpt with -extra for consistent formatting.
According to the pipeline warning, the file is not gofumpt-ed with the-extra
flag. Please run:gofumpt -w -extra ./simsx/runner.go
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
simsx/runner.go
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
simsx/runner.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🪛 golangci-lint (1.62.2)
simsx/runner.go
133-133: File is not gofumpt
-ed with -extra
(gofumpt)
🪛 GitHub Actions: Lint
simsx/runner.go
[warning] 133-133: File is not gofumpt
-ed with -extra
[error] 99-99: test helper function should start from t.Helper()
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: tests (00)
- GitHub Check: test-simapp-v2
- GitHub Check: test-integration
- GitHub Check: test-system-v2
- GitHub Check: Analyze
- GitHub Check: build (amd64)
- GitHub Check: Summary
🔇 Additional comments (1)
simsx/runner.go (1)
113-115
: Bridging function usage looks good.
This function simply delegates toRunWithSeedsAndRandAcc
with the defaultsimtypes.RandomAccounts
. The logic appears valid.
simsx/runner.go
Outdated
) { | ||
RunWithSeedAndRandAcc(tb, cfg, appFactory, setupStateFactory, seed, fuzzSeed, simtypes.RandomAccounts, postRunActions...) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark the function as a helper function.
The pipeline explicitly requires test helper functions to start with tb.Helper()
.
Apply this diff to add tb.Helper()
:
func RunWithSeed[T SimulationApp](
tb testing.TB,
cfg simtypes.Config,
...
) {
+ tb.Helper()
RunWithSeedAndRandAcc(tb, cfg, appFactory, setupStateFactory, seed, fuzzSeed, simtypes.RandomAccounts, postRunActions...)
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
) { | |
RunWithSeedAndRandAcc(tb, cfg, appFactory, setupStateFactory, seed, fuzzSeed, simtypes.RandomAccounts, postRunActions...) | |
} | |
) { | |
tb.Helper() | |
RunWithSeedAndRandAcc(tb, cfg, appFactory, setupStateFactory, seed, fuzzSeed, simtypes.RandomAccounts, postRunActions...) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make the linter happy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
simsx/runner.go (1)
Line range hint
166-192
: LGTM! Consider enhancing documentation.The implementation correctly integrates custom account generation into the simulation flow. The error handling and cleanup are comprehensive.
Consider adding a doc comment explaining the purpose of
randAccFn
parameter and its impact on the simulation:-// RunWithSeedAndRandAcc calls RunWithSeed with randAccFn +// RunWithSeedAndRandAcc runs a simulation test with a custom random account generation function. +// The randAccFn parameter allows customization of how test accounts are generated during simulation, +// enabling more flexible testing scenarios. If specific account properties or distributions are needed, +// they can be achieved by providing a custom implementation of simtypes.RandomAccountFn. func RunWithSeedAndRandAcc[T SimulationApp](
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
simsx/runner.go
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
simsx/runner.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: tests (00)
- GitHub Check: test-system-v2
- GitHub Check: Analyze
- GitHub Check: Summary
🔇 Additional comments (3)
simsx/runner.go (3)
113-116
: LGTM! Clean implementation maintaining backward compatibility.The function correctly delegates to
RunWithSeedsAndRandAcc
while preserving the default behavior usingsimtypes.RandomAccounts
.
161-164
: LGTM! Clean implementation maintaining backward compatibility.The function correctly delegates to
RunWithSeedAndRandAcc
while preserving the default behavior usingsimtypes.RandomAccounts
.
118-133
:⚠️ Potential issueFix incorrect function call that ignores custom randAccFn.
The function calls
RunWithSeed
instead ofRunWithSeedAndRandAcc
, which causes the customrandAccFn
to be ignored. This breaks the intended functionality of allowing custom random account generation.Apply this diff to fix the issue:
t.Run(fmt.Sprintf("seed: %d", seed), func(t *testing.T) { t.Parallel() - RunWithSeed(t, cfg, appFactory, setupStateFactory, seed, fuzzSeed, postRunActions...) + RunWithSeedAndRandAcc(t, cfg, appFactory, setupStateFactory, seed, fuzzSeed, randAccFn, postRunActions...) })Likely invalid or redundant comment.
(cherry picked from commit 51f9809)
… (#23199) Co-authored-by: mmsqe <[email protected]>
Description
Closes: #XXXX
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit