Skip to content

Conversation

@graydon
Copy link
Contributor

@graydon graydon commented Nov 8, 2025

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.

Copilot AI review requested due to automatic review settings November 8, 2025 09:00
Copy link

Copilot AI left a 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 CovMark utility class for test-only coverage verification with atomic counters
  • Implements restore() method in ContractStorageTestClient for 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
Copy link

Copilot AI Nov 8, 2025

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'.

Suggested change
// 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

Copilot uses AI. Check for mistakes.
uint32_t threshold, uint32_t extendTo,
std::optional<SorobanInvocationSpec> spec = std::nullopt);

InvokeHostFunctionResultCode
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
InvokeHostFunctionResultCode
RestoreFootprintResultCode

Copilot uses AI. Check for mistakes.
spec->getResources(), spec->getInclusionFee(), spec->getResourceFee());

auto result = mContract.getTest().invokeTx(tx);
return result.result.results()[0].tr().invokeHostFunctionResult().code();
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
return result.result.results()[0].tr().invokeHostFunctionResult().code();
return result.result.results()[0].tr().restoreFootprintResult().code();

Copilot uses AI. Check for mistakes.
};

checklive(ExpirationStatus::LIVE);
closeLedger(test.getApp());
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
closeLedger(test.getApp());
closeLedger(test.getApp());

Copilot uses AI. Check for mistakes.
//
// 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.
Copy link

Copilot AI Nov 8, 2025

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'.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
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.

1 participant