Skip to content

Conversation

@pcw109550
Copy link
Contributor

@pcw109550 pcw109550 commented Dec 9, 2025

Adds one unit test which checks No attributes available but building unsealed payload triggered, leading critical error.

Moved test_builder helper to actor for reusability.

Part of #3070

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.9%. Comparing base (5faf212) to head (f06d2e5).
✅ All tests successful. No failed tests found.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pcw109550 pcw109550 changed the title test empty attr while building unsealed payload chore(node/actor): Unit Test for Empty Attributes while building unsealed payload Dec 9, 2025
@pcw109550 pcw109550 changed the title chore(node/actor): Unit Test for Empty Attributes while building unsealed payload chore(node/actor): Test: Empty Attributes while building unsealed payload Dec 9, 2025
@pcw109550 pcw109550 marked this pull request as ready for review December 9, 2025 15:43
Copy link
Collaborator

@op-will op-will left a comment

Choose a reason for hiding this comment

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

Looks good! You could merge as-is, but how do you feel about updating the test to handle all possible prepare_payload_attributes errors?

let err = result.unwrap_err();
assert!(matches!(
err,
SequencerActorError::AttributesBuilder(PipelineErrorKind::Critical(_))
Copy link
Collaborator

@op-will op-will Dec 9, 2025

Choose a reason for hiding this comment

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

While we can rely on the default error returned from the default TestAttributesBuilder, that may change, causing this test to break. It may be better to:

  1. Define different error types for TestAttributesBuilderError (Temporary, Critical, Reset) -- or even better, remove that error type and just use PipelineErrorKind
  2. Update TestAttributesBuilder.prepare_payload_attributes to return the PipelineErrorKind of the configured error
  3. Create and use a TestAttributesBuilder, add the exact error you want to receive to the attributes field
  4. Assert that the error exactly matches the returned error

Copy link
Collaborator

Choose a reason for hiding this comment

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

This also lets you parameterize this test to verify all error types (example) are handled how you expect them to be handled in a single test.

}
}

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you feel about creating an actor_test.rs file and moving these tests/utils to it?

There are many branches in this logic, so there will eventually be many lines of unit tests, so we can de-clutter the live logic by moving to a separate file.

Copy link
Member

Choose a reason for hiding this comment

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

The way I'd go about it would be to have a test folder which is feature gated with #[cfg(test)] and put all the tests there

use crate::actors::{MockBlockBuildingClient, MockOriginSelector};

#[tokio::test]
async fn test_build_unsealed_payload_no_attributes() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're really testing the handling of prepare_payload_attributes errors.

Suggested change
async fn test_build_unsealed_payload_no_attributes() {
async fn test_build_unsealed_payload_prepare_payload_attributes_error() {

use tokio_util::sync::CancellationToken;

// Returns a test SequencerActorBuilder with mocks that can be used or overridden.
pub(crate) fn test_builder() -> SequencerActorBuilder<
Copy link
Collaborator

@op-will op-will Dec 9, 2025

Choose a reason for hiding this comment

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

I think we would want to move this to a test_util.rs file since it's used in multiple files, but it is being removed soon: #3152

Although even without the builder, we'll still probably have some utils around creating the test SequencerActor.

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.

4 participants