Skip to content

Conversation

@sappenin
Copy link
Collaborator

@sappenin sappenin commented Dec 17, 2025

High Level Overview of Change

  • Add mockall mocking framework.
  • Introduce a new trait that defineds all host functions (host_bindings_trait.rs)
  • Wire-in proper host function definitions for different build profiles.
  • Add sample test in error_code.rs
  • Update host function audit script to use correct repo and check all host function definitions in each profile.

Context of Change

This PR is number-1 in a series of three PRs that offers an alternative design to the proposal in #102. In particular:

  • PR #117 (this PR): Adds initial mocking support using the mockall framework.
  • PR #118: Updates existing unit tests to use the new mocking framework, where appropriate.
  • PR #119: Adds new unit test coverage to a variety of host-function usages in the library.

Note on LOC in this PR

The astute observer will notice that this PR has a reasonably large number of lines-of-code changed. There are two primary culprits here, mostly falling into the changes required for host_bindings_wasm.rs. Overall, to pull off our current design (where all host functions are accessible from the host:: namespace), we need to replicate the host functions (there are quite a lot of them on their own) three times. The first is to define the C abstraction (required by rippled/WASM VM). The second is to implement the trait, which delegates to the C abstraction (trait is required for mocking), and the third is to hide the overall implementation of the first two (to maintain the host:: namespace).

While this is a large changeset, the changes are mostly just boilerplate. I've tried to reduce this boilerplate as much as possible using macros. This helped, but not everything can be macro'd.

- Add mockall mocking framework.
- Introduce a new trait that defineds all host functions (host_bindings_trait.rs)
- Wire-in proper host function definitions for different build profiles.
- Add sample test in error_code.rs
- Update host function audit script to use correct repo and check all host function definitions in each profile.
@sappenin sappenin self-assigned this Dec 17, 2025
@sappenin sappenin changed the title Add Alternate Mocking Framework Add Alternate Mocking Framework (1-out-of-3 / Initial Scaffolding) Dec 17, 2025
@sappenin sappenin changed the title Add Alternate Mocking Framework (1-out-of-3 / Initial Scaffolding) Add Alternate Mocking Framework (1-of-3 / Initial Scaffolding) Dec 17, 2025
@sappenin sappenin requested a review from mvadari December 17, 2025 16:02
@sappenin sappenin marked this pull request as ready for review December 17, 2025 16:02
Co-authored-by: Mayukha Vadari <[email protected]>
@sappenin sappenin requested a review from mvadari December 17, 2025 22:47
@sappenin sappenin merged commit ee861a7 into main Dec 18, 2025
15 checks passed
@sappenin sappenin deleted the df/mock-all/1-initial-scaffolding branch December 18, 2025 00:35
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.

3 participants