-
Notifications
You must be signed in to change notification settings - Fork 1k
Add CovMark and a test that uses it. #5012
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
base: master
Are you sure you want to change the base?
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 introduces a new coverage marking utility (CovMark) to verify hard-to-observe code paths in tests, adds support for restore operations in ContractStorageTestClient, and includes a test to verify that eviction is properly deferred when TTL is modified concurrently. The PR also clarifies comments in the BucketManager eviction logic.
- Adds new
CovMarkutility class for test-only coverage verification with atomic counters - Implements
restore()method inContractStorageTestClientfor testing restore operations - Adds test case for concurrent TTL modification during eviction with coverage verification
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/CovMark.h | Defines new test-only coverage marking utility with macros and guard class |
| src/test/CovMark.cpp | Implements CovMark functionality including hit tracking and guard validation |
| src/transactions/test/SorobanTxTestUtils.h | Adds restore() method declaration to ContractStorageTestClient |
| src/transactions/test/SorobanTxTestUtils.cpp | Implements restore() method for test client |
| src/transactions/test/SorobanEvictionTests.cpp | New test case for eviction deferral with concurrent TTL modifications |
| src/bucket/BucketManager.cpp | Adds coverage mark and clarifies eviction iterator update comments |
| // times, or different marks sum up to some value, etc. | ||
| // | ||
| // 4. It also allows us to hash all the marks together to get a trajectory | ||
| // summmary for a run, which we can feed to a fuzzer to explore different |
Copilot
AI
Nov 8, 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.
Corrected spelling of 'summmary' to 'summary'.
| // summmary for a run, which we can feed to a fuzzer to explore different | |
| // summary for a run, which we can feed to a fuzzer to explore different |
| uint32_t threshold, uint32_t extendTo, | ||
| std::optional<SorobanInvocationSpec> spec = std::nullopt); | ||
|
|
||
| InvokeHostFunctionResultCode |
Copilot
AI
Nov 8, 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.
The restore() method should return RestoreFootprintResultCode instead of InvokeHostFunctionResultCode, as restore operations use RESTORE_FOOTPRINT operation type, not INVOKE_HOST_FUNCTION.
| InvokeHostFunctionResultCode | |
| RestoreFootprintResultCode |
| spec->getResources(), spec->getInclusionFee(), spec->getResourceFee()); | ||
|
|
||
| auto result = mContract.getTest().invokeTx(tx); | ||
| return result.result.results()[0].tr().invokeHostFunctionResult().code(); |
Copilot
AI
Nov 8, 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.
Incorrect result accessor used. Restore operations should use restoreFootprintResult().code() instead of invokeHostFunctionResult().code(). This will cause a runtime error when accessing the wrong union member.
| return result.result.results()[0].tr().invokeHostFunctionResult().code(); | |
| return result.result.results()[0].tr().restoreFootprintResult().code(); |
| }; | ||
|
|
||
| checklive(ExpirationStatus::LIVE); | ||
| closeLedger(test.getApp()); |
Copilot
AI
Nov 8, 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.
Remove trailing whitespace at end of line.
| closeLedger(test.getApp()); | |
| closeLedger(test.getApp()); |
| // | ||
| // If remainingEntriesToEvict == 0, we _did_ hit our limit, but there's | ||
| // nothing to do in that case: we already updated newEvictionIterator to | ||
| // after the the last scanned eligible entry in the body of the loop. |
Copilot
AI
Nov 8, 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.
Remove duplicate word 'the' - should be 'after the last scanned eligible entry'.
| // after the the last scanned eligible entry in the body of the loop. | |
| // after the last scanned eligible entry in the body of the loop. |
This adds a mechanism for coverage markers in tests similar to https://ferrous-systems.com/blog/coverage-marks but with a few differences to make it more useful in fuzzing (if we get there).
I also got half way through writing a test that uses it related to a hard-to-trigger code path in the bucketlist. I did not get this working yet and I ran out of time tonight; I'll leave it here in case @SirTyson wants to take a look. Otherwise I'll pick it up when I'm back from break.