-
Notifications
You must be signed in to change notification settings - Fork 380
test(storage-incentives): add synctest to TestAgent #5250
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
Conversation
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.
Pull Request Overview
This PR addresses timing issues in the storage incentives agent test by integrating Go's testing/synctest package to create deterministic test execution. The main change wraps the test logic in synctest.Test() to prevent flaky test failures caused by inconsistent timing.
- Adds synctest integration to create deterministic test timing
- Includes additional validation to ensure expected contract calls occur
- Removes unnecessary empty line for code cleanup
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pkg/storageincentives/agent_test.go
Outdated
| if len(contract.callsList) == 0 { | ||
| t.Fatal("expected calls but got none") | ||
| } |
Copilot
AI
Oct 15, 2025
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.
This validation contradicts the test logic above. When tc.expectedCalls is false (lines 129-135), the test expects no calls and fails if any are found. Adding this check means tests with expectedCalls: false will always fail since they expect zero calls but this code requires at least one call.
5b02541 to
f3e6c8d
Compare
Checklist
Description
The main issue was in the agent test where inconsistent timing would sometimes cause the test to fail.
This has been addressed by using synctest to wrap code that will create a bubble to help preventing timing issues.
Testing
Update test commands in
Makefile:$(GO) test -count=1 -run "TestAgent" github.com/ethersphere/bee/v2/pkg/storageincentivesCheck Attempts: https://github.com/ethersphere/bee/actions/runs/18543306676
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
#5232
Screenshots (if appropriate):