Skip to content

refactor: replace manual mocks with mockall in producer#3192

Open
raushan728 wants to merge 4 commits into
FuelLabs:masterfrom
raushan728:refactor/mockall-migration-producer
Open

refactor: replace manual mocks with mockall in producer#3192
raushan728 wants to merge 4 commits into
FuelLabs:masterfrom
raushan728:refactor/mockall-migration-producer

Conversation

@raushan728

Copy link
Copy Markdown

Migrated manual mock implementations in producer/src/mocks.rs to mockall to address internal TODOs and standardize testing infrastructure.

@fuel-cla-bot

fuel-cla-bot Bot commented Jan 27, 2026

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @raushan728 to sign the Fuel Labs Contributor License Agreement.

@cursor

cursor Bot commented Jan 27, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to test/mock infrastructure and minor syntax cleanup, with low risk to production behavior; main risk is test flakiness or compile issues under the test-helpers feature due to the new mock expectations/closures.

Overview
Refactors producer test infrastructure by replacing manual MockRelayer, MockTxPool, and MockExecutor (including FailingMockExecutor) with mockall-generated mocks behind the test-helpers feature, plus helper constructors like create_mock_relayer, create_mock_txpool, and create_failing_mock_executor to provide default behaviors.

Updates block_producer tests to use the new mock factories and removes direct construction of legacy mock structs; also includes a tiny syntax fix in produce_and_execute_predefined (missing semicolon after .into()).

Reviewed by Cursor Bugbot for commit 39ed219. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread crates/services/producer/src/mocks.rs

@xgreenx xgreenx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you please apply nightly formatting?

@raushan728

Copy link
Copy Markdown
Author

Applied nightly formatting as requested. All imports are now in vertical layout format.

Comment thread crates/services/producer/src/block_producer/tests.rs
@raushan728 raushan728 requested a review from xgreenx January 28, 2026 13:20
@MitchTurner

Copy link
Copy Markdown
Contributor

Hey @raushan728 !

Thanks for the contribution! It's a little bit of an internal debate whether or not we should use mockall in our code. I'm of mind that we should manually write our mocks as mockall encourages users to pay too much attention to implementation details, rather than just testing external apis.

It's not up to me alone, but that's my position.

@raushan728

Copy link
Copy Markdown
Author

Thanks @MitchTurner. I'll wait for the team's final decision on this before making further changes.

@raushan728 raushan728 force-pushed the refactor/mockall-migration-producer branch from 041a442 to 39ed219 Compare May 7, 2026 13:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 39ed219. Configure here.

pub struct MockTxPool(pub Vec<Transaction>);
// Re-export for backward compatibility during migration
#[cfg(feature = "test-helpers")]
pub use MockRelayer as MockRelayerLegacy;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused MockRelayerLegacy re-export is dead code

Low Severity

The pub use MockRelayer as MockRelayerLegacy re-export is introduced as "backward compatibility during migration" but is never referenced anywhere in the codebase. This is dead code that adds confusion without providing any value.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 39ed219. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants